kernel_optimize_test/net/sched
Davide Caratti f29cdfbe33 net/sched: fix idr leak in the error path of tcf_skbmod_init()
tcf_skbmod_init() can fail after the idr has been successfully reserved.
When this happens, every subsequent attempt to configure skbmod rules
using the same idr value will systematically fail with -ENOSPC, unless
the first attempt was done using the 'replace' keyword:

 # tc action add action skbmod swap mac index 100
 RTNETLINK answers: Cannot allocate memory
 We have an error talking to the kernel
 # tc action add action skbmod swap mac index 100
 RTNETLINK answers: No space left on device
 We have an error talking to the kernel
 # tc action add action skbmod swap mac index 100
 RTNETLINK answers: No space left on device
 We have an error talking to the kernel
 ...

Fix this in tcf_skbmod_init(), ensuring that tcf_idr_release() is called
on the error path when the idr has been reserved, but not yet inserted.
Also, don't test 'ovr' in the error path, to avoid a 'replace' failure
implicitly become a 'delete' that leaks refcount in act_skbmod module:

 # rmmod act_skbmod; modprobe act_skbmod
 # tc action add action skbmod swap mac index 100
 # tc action add action skbmod swap mac continue index 100
 RTNETLINK answers: File exists
 We have an error talking to the kernel
 # tc action replace action skbmod swap mac continue index 100
 RTNETLINK answers: Cannot allocate memory
 We have an error talking to the kernel
 # tc action list action skbmod
 #
 # rmmod  act_skbmod
 rmmod: ERROR: Module act_skbmod is in use

Fixes: 65a206c01e ("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>
2018-03-21 18:12:37 -04:00
..
act_api.c idr: Rename idr_for_each_entry_ext 2018-02-06 16:41:28 -05:00
act_bpf.c net/sched: fix idr leak on the error path of tcf_bpf_init() 2018-03-21 18:11:46 -04:00
act_connmark.c
act_csum.c net/sched: fix NULL dereference in the error path of tcf_csum_init() 2018-03-17 19:53:28 -04:00
act_gact.c
act_ife.c
act_ipt.c net/sched: fix idr leak in the error path of __tcf_ipt_init() 2018-03-21 18:12:16 -04:00
act_meta_mark.c
act_meta_skbprio.c
act_meta_skbtcindex.c
act_mirred.c
act_nat.c
act_pedit.c net/sched: fix idr leak in the error path of tcp_pedit_init() 2018-03-21 18:12:08 -04:00
act_police.c net/sched: fix idr leak in the error path of tcf_act_police_init() 2018-03-21 18:12:00 -04:00
act_sample.c net/sched: fix NULL dereference in the error path of tcf_sample_init() 2018-03-17 19:53:28 -04:00
act_simple.c net/sched: fix idr leak in the error path of tcf_simp_init() 2018-03-21 18:11:53 -04:00
act_skbedit.c
act_skbmod.c net/sched: fix idr leak in the error path of tcf_skbmod_init() 2018-03-21 18:12:37 -04:00
act_tunnel_key.c net/sched: fix NULL dereference in the error path of tunnel_key_init() 2018-03-17 19:53:28 -04:00
act_vlan.c net/sched: fix idr leak in the error path of tcf_vlan_init() 2018-03-21 18:12:27 -04:00
cls_api.c net: sched: report if filter is too large to dump 2018-02-20 21:57:17 -05:00
cls_basic.c cls_basic: Convert to use idr_alloc_u32 2018-02-06 16:41:26 -05:00
cls_bpf.c cls_bpf: Convert to use idr_alloc_u32 2018-02-06 16:41:26 -05:00
cls_cgroup.c net: sched: propagate extack to cls->destroy callbacks 2018-01-24 16:01:09 -05:00
cls_flow.c net: sched: propagate extack to cls->destroy callbacks 2018-01-24 16:01:09 -05:00
cls_flower.c cls_flower: Convert to idr_alloc_u32 2018-02-06 16:41:26 -05:00
cls_fw.c net: sched: propagate extack to cls->destroy callbacks 2018-01-24 16:01:09 -05:00
cls_matchall.c cls_matchall: propagate extack to delete callback 2018-01-24 16:01:10 -05:00
cls_route.c net: sched: propagate extack to cls->destroy callbacks 2018-01-24 16:01:09 -05:00
cls_rsvp6.c
cls_rsvp.c
cls_rsvp.h net: sched: propagate extack to cls->destroy callbacks 2018-01-24 16:01:09 -05:00
cls_tcindex.c net: sched: propagate extack to cls->destroy callbacks 2018-01-24 16:01:09 -05:00
cls_u32.c net: sched: fix tc_u_common lookup 2018-02-13 12:29:02 -05:00
em_canid.c
em_cmp.c
em_ipset.c
em_meta.c
em_nbyte.c net: sched: em_nbyte: don't add the data offset twice 2018-01-24 14:52:40 -05:00
em_text.c
em_u32.c
ematch.c
Kconfig net/sched: kconfig: Remove blank help texts 2018-01-31 10:26:30 -05:00
Makefile
sch_api.c
sch_atm.c
sch_blackhole.c
sch_cbq.c
sch_cbs.c
sch_choke.c
sch_codel.c
sch_drr.c
sch_dsmark.c
sch_fifo.c
sch_fq_codel.c
sch_fq.c
sch_generic.c net: sched: fix uses after free 2018-03-17 17:03:45 -04:00
sch_gred.c
sch_hfsc.c
sch_hhf.c
sch_htb.c
sch_ingress.c
sch_mq.c
sch_mqprio.c
sch_multiq.c
sch_netem.c sch_netem: fix skb leak in netem_enqueue() 2018-03-07 11:18:14 -05:00
sch_pie.c
sch_plug.c
sch_prio.c net/sched/sch_prio.c: work around gcc-4.4.4 union initializer issues 2018-01-18 21:11:31 -05:00
sch_qfq.c
sch_red.c
sch_sfb.c
sch_sfq.c
sch_tbf.c net: sched: tbf: handle GSO_BY_FRAGS case in enqueue 2018-03-04 17:49:17 -05:00
sch_teql.c