summaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorRoman Mashak <mrv@mojatatu.com>2018-05-11 14:35:33 -0400
committerDavid S. Miller <davem@davemloft.net>2018-05-11 16:37:03 -0400
commita52956dfc503f8cc5cfe6454959b7049fddb4413 (patch)
treef00a5558d6d47ff70b07ac0ce7c772ec11f9edb8 /net/sched
parentd68d75fdc34b0253c2bded7ed18cd60eb5a9599b (diff)
net sched actions: fix refcnt leak in skbmod
When application fails to pass flags in netlink TLV when replacing existing skbmod action, the kernel will leak refcnt: $ tc actions get action skbmod index 1 total acts 0 action order 0: skbmod pipe set smac 00:11:22:33:44:55 index 1 ref 1 bind 0 For example, at this point a buggy application replaces the action with index 1 with new smac 00:aa:22:33:44:55, it fails because of zero flags, however refcnt gets bumped: $ tc actions get actions skbmod index 1 total acts 0 action order 0: skbmod pipe set smac 00:11:22:33:44:55 index 1 ref 2 bind 0 $ Tha patch fixes this by calling tcf_idr_release() on existing actions. Fixes: 86da71b57383d ("net_sched: Introduce skbmod action") Signed-off-by: Roman Mashak <mrv@mojatatu.com> Acked-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/act_skbmod.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c
index bbcbdce732cc..ad050d7d4b46 100644
--- a/net/sched/act_skbmod.c
+++ b/net/sched/act_skbmod.c
@@ -131,8 +131,11 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla,
131 if (exists && bind) 131 if (exists && bind)
132 return 0; 132 return 0;
133 133
134 if (!lflags) 134 if (!lflags) {
135 if (exists)
136 tcf_idr_release(*a, bind);
135 return -EINVAL; 137 return -EINVAL;
138 }
136 139
137 if (!exists) { 140 if (!exists) {
138 ret = tcf_idr_create(tn, parm->index, est, a, 141 ret = tcf_idr_create(tn, parm->index, est, a,