]> git.baikalelectronics.ru Git - kernel.git/commit
net/sched: fix idr leak on the error path of tcf_bpf_init()
authorDavide Caratti <dcaratti@redhat.com>
Mon, 19 Mar 2018 14:31:22 +0000 (15:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Mar 2018 22:11:46 +0000 (18:11 -0400)
commitb631013891c24630955752e9df49ebad864f8d08
treeeafb8fa4764448bbb04cf638c5d6a1f2e872e94c
parent2e708f74271cd93b95ff619e894a533a59711a35
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: de823360b9cf ("net/sched: Change act_api and act_xxx modules to use IDR")
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_bpf.c