* [PATCH net] net/sched: act_skbedit: fix refcount leak when replace fails
@ 2019-02-22 11:33 Davide Caratti
2019-02-25 1:32 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Davide Caratti @ 2019-02-22 11:33 UTC (permalink / raw)
To: Vlad Buslov, Cong Wang, Jamal Hadi Salim, Jiri Pirko, David S. Miller
Cc: netdev
when act_skbedit was converted to use RCU in the data plane, we added an
error path, but we forgot to drop the action refcount in case of failure
during a 'replace' operation:
# tc actions add action skbedit ptype otherhost pass index 100
# tc action show action skbedit
total acts 1
action order 0: skbedit ptype otherhost pass
index 100 ref 1 bind 0
# tc actions replace action skbedit ptype otherhost drop index 100
RTNETLINK answers: Cannot allocate memory
We have an error talking to the kernel
# tc action show action skbedit
total acts 1
action order 0: skbedit ptype otherhost pass
index 100 ref 2 bind 0
Ensure we call tcf_idr_release(), in case 'params_new' allocation failed,
also when the action is being replaced.
Fixes: c749cdda9089 ("net/sched: act_skbedit: don't use spinlock in the data path")
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
net/sched/act_skbedit.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
index 64dba3708fce..cfceed28c333 100644
--- a/net/sched/act_skbedit.c
+++ b/net/sched/act_skbedit.c
@@ -189,8 +189,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
params_new = kzalloc(sizeof(*params_new), GFP_KERNEL);
if (unlikely(!params_new)) {
- if (ret == ACT_P_CREATED)
- tcf_idr_release(*a, bind);
+ tcf_idr_release(*a, bind);
return -ENOMEM;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net/sched: act_skbedit: fix refcount leak when replace fails
2019-02-22 11:33 [PATCH net] net/sched: act_skbedit: fix refcount leak when replace fails Davide Caratti
@ 2019-02-25 1:32 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-02-25 1:32 UTC (permalink / raw)
To: dcaratti; +Cc: vladbu, xiyou.wangcong, jhs, jiri, netdev
From: Davide Caratti <dcaratti@redhat.com>
Date: Fri, 22 Feb 2019 12:33:26 +0100
> when act_skbedit was converted to use RCU in the data plane, we added an
> error path, but we forgot to drop the action refcount in case of failure
> during a 'replace' operation:
>
> # tc actions add action skbedit ptype otherhost pass index 100
> # tc action show action skbedit
> total acts 1
>
> action order 0: skbedit ptype otherhost pass
> index 100 ref 1 bind 0
> # tc actions replace action skbedit ptype otherhost drop index 100
> RTNETLINK answers: Cannot allocate memory
> We have an error talking to the kernel
> # tc action show action skbedit
> total acts 1
>
> action order 0: skbedit ptype otherhost pass
> index 100 ref 2 bind 0
>
> Ensure we call tcf_idr_release(), in case 'params_new' allocation failed,
> also when the action is being replaced.
>
> Fixes: c749cdda9089 ("net/sched: act_skbedit: don't use spinlock in the data path")
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Also applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-25 1:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 11:33 [PATCH net] net/sched: act_skbedit: fix refcount leak when replace fails Davide Caratti
2019-02-25 1:32 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.