Skip to content

Commit bbc09e7

Browse files
dcarattidavem330
authored andcommitted
net/sched: fix idr leak on the error path of tcf_bpf_init()
when the following command sequence is entered # tc action add action bpf bytecode '4,40 0 0 12,31 0 1 2048,6 0 0 262144,6 0 0 0' index 100 RTNETLINK answers: Invalid argument We have an error talking to the kernel # tc action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel act_bpf correctly refuses to install the first TC rule, because 31 is not a valid instruction. However, it refuses to install the second TC rule, even if the BPF code is correct. Furthermore, it's no more possible to install any other rule having the same value of 'index' until act_bpf module is unloaded/inserted again. After the idr has been reserved, call tcf_idr_release() instead of tcf_idr_cleanup(), to fix this issue. Fixes: 65a206c ("net/sched: Change act_api and act_xxx modules to use IDR") Acked-by: Jamal Hadi Salim <[email protected]> Signed-off-by: Davide Caratti <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3f2176d commit bbc09e7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/sched/act_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla,
352352
return res;
353353
out:
354354
if (res == ACT_P_CREATED)
355-
tcf_idr_cleanup(*act, est);
355+
tcf_idr_release(*act, bind);
356356

357357
return ret;
358358
}

0 commit comments

Comments
 (0)