Skip to content

Commit 6a5b044

Browse files
Roman Mashakgregkh
authored andcommitted
net sched actions: fix refcnt leak in skbmod
[ Upstream commit a52956d ] 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: 86da71b ("net_sched: Introduce skbmod action") Signed-off-by: Roman Mashak <[email protected]> Acked-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1abd8c5 commit 6a5b044

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/sched/act_skbmod.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla,
131131
if (exists && bind)
132132
return 0;
133133

134-
if (!lflags)
134+
if (!lflags) {
135+
if (exists)
136+
tcf_idr_release(*a, bind);
135137
return -EINVAL;
138+
}
136139

137140
if (!exists) {
138141
ret = tcf_idr_create(tn, parm->index, est, a,

0 commit comments

Comments
 (0)