]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
net/sched: fix idr leak in the error path of tcf_act_police_init()
authorDavide Caratti <dcaratti@redhat.com>
Mon, 19 Mar 2018 14:31:24 +0000 (15:31 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 27 Aug 2018 14:40:05 +0000 (16:40 +0200)
commit0208626ca0ad9a47dac0f8f235f1e73370050795
treefe93e5f29ebcfed68b63af683ff913c4d7b96596
parent6617f8933f440efeda4bbdea45706aff6a15fc3c
net/sched: fix idr leak in the error path of tcf_act_police_init()

BugLink: http://bugs.launchpad.net/bugs/1786352
[ Upstream commit 5bf7f8185f7c7112decdfe3d3e5c5d5e67f099a1 ]

tcf_act_police_init() can fail after the idr has been successfully
reserved (e.g., qdisc_get_rtab() may return NULL). When this happens,
subsequent attempts to configure a police rule using the same idr value
systematiclly fail with -ENOSPC:

 # tc action add action police rate 1000 burst 1000 drop index 100
 RTNETLINK answers: Cannot allocate memory
 We have an error talking to the kernel
 # tc action add action police rate 1000 burst 1000 drop index 100
 RTNETLINK answers: No space left on device
 We have an error talking to the kernel
 # tc action add action police rate 1000 burst 1000 drop index 100
 RTNETLINK answers: No space left on device
 ...

Fix this in the error path of tcf_act_police_init(), calling
tcf_idr_release() in place of tcf_idr_cleanup().

Fixes: 65a206c01e8e ("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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/sched/act_police.c