linux-stable/net/sched
Paolo Abeni 44a5cd436e cls_flower: fix use after free in flower S/W path
If flower filter is created without the skip_sw flag, fl_mask_put()
can race with fl_classify() and we can destroy the mask rhashtable
while a lookup operation is accessing it.

 BUG: unable to handle kernel paging request at 00000000000911d1
 PGD 0 P4D 0
 SMP PTI
 CPU: 3 PID: 5582 Comm: vhost-5541 Not tainted 4.18.0-rc1.vanilla+ #1950
 Hardware name: Dell Inc. PowerEdge R730/072T6D, BIOS 2.1.7 06/16/2016
 RIP: 0010:rht_bucket_nested+0x20/0x60
 Code: 31 c8 c1 c1 18 29 c8 c3 66 90 8b 4f 04 ba 01 00 00 00 8b 07 48 8b bf 80 00 00 0
 RSP: 0018:ffffafc5cfbb7a48 EFLAGS: 00010206
 RAX: 0000000000001978 RBX: ffff9f12dff88a00 RCX: 00000000ffff9f12
 RDX: 00000000000911d1 RSI: 0000000000000148 RDI: 0000000000000001
 RBP: ffff9f12dff88a00 R08: 000000005f1cc119 R09: 00000000a715fae2
 R10: ffffafc5cfbb7aa8 R11: ffff9f1cb4be804e R12: ffff9f1265e13000
 R13: 0000000000000000 R14: ffffafc5cfbb7b48 R15: ffff9f12dff88b68
 FS:  0000000000000000(0000) GS:ffff9f1d3f0c0000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 00000000000911d1 CR3: 0000001575a94006 CR4: 00000000001626e0
 Call Trace:
  fl_lookup+0x134/0x140 [cls_flower]
  fl_classify+0xf3/0x180 [cls_flower]
  tcf_classify+0x78/0x150
  __netif_receive_skb_core+0x69e/0xa50
  netif_receive_skb_internal+0x42/0xf0
  tun_get_user+0xdd5/0xfd0 [tun]
  tun_sendmsg+0x52/0x70 [tun]
  handle_tx+0x2b3/0x5f0 [vhost_net]
  vhost_worker+0xab/0x100 [vhost]
  kthread+0xf8/0x130
  ret_from_fork+0x35/0x40
 Modules linked in: act_mirred act_gact cls_flower vhost_net vhost tap sch_ingress
 CR2: 00000000000911d1

Fix the above waiting for a RCU grace period before destroying the
rhashtable: we need to use tcf_queue_work(), as rhashtable_destroy()
must run in process context, as pointed out by Cong Wang.

v1 -> v2: use tcf_queue_work to run rhashtable_destroy().

Fixes: 05cd271fd6 ("cls_flower: Support multiple masks per priority")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-06-22 07:24:07 +09:00
..
act_api.c net: sched: don't disable bh when accessing action idr 2018-05-22 15:34:34 -04:00
act_bpf.c net/sched: fix NULL dereference in the error path of tcf_bpf_init() 2018-04-05 22:26:06 -04:00
act_connmark.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_csum.c net sched: Implemented get_fill_size routine for act_csum. 2018-05-03 11:15:58 -04:00
act_gact.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_ife.c net/sched: act_ife: preserve the action control in case of error 2018-06-20 09:03:58 +09:00
act_ipt.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_meta_mark.c net: remove duplicate includes 2017-12-13 13:18:46 -05:00
act_meta_skbprio.c net sched actions: change IFE modules alias names 2017-10-12 22:13:20 -07:00
act_meta_skbtcindex.c net: remove duplicate includes 2017-12-13 13:18:46 -05:00
act_mirred.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_nat.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_pedit.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_police.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_sample.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_simple.c net/sched: act_simple: fix parsing of TCA_DEF_DATA 2018-06-08 18:49:19 -04:00
act_skbedit.c net sched actions: fix invalid pointer dereferencing if skbedit flags missing 2018-05-11 15:52:43 -04:00
act_skbmod.c net sched actions: fix refcnt leak in skbmod 2018-05-11 16:37:03 -04:00
act_tunnel_key.c net: Drop pernet_operations::async 2018-03-27 13:18:09 -04:00
act_vlan.c net/sched: fix refcnt leak in the error path of tcf_vlan_init() 2018-05-16 14:41:44 -04:00
cls_api.c Revert "net: sched: cls: Fix offloading when ingress dev is vxlan" 2018-06-06 13:55:47 -04:00
cls_basic.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_bpf.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_cgroup.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_flow.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_flower.c cls_flower: fix use after free in flower S/W path 2018-06-22 07:24:07 +09:00
cls_fw.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_matchall.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_route.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_rsvp.c
cls_rsvp.h net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_rsvp6.c
cls_tcindex.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
cls_u32.c net_sched: switch to rcu_work 2018-05-24 22:56:15 -04:00
em_canid.c
em_cmp.c
em_ipset.c netfilter: x_tables: move hook state into xt_action_param structure 2016-11-03 10:56:21 +01:00
em_ipt.c net: sched: add em_ipt ematch for calling xtables matches 2018-02-21 13:15:33 -05:00
em_meta.c net: convert sock.sk_refcnt from atomic_t to refcount_t 2017-07-01 07:39:08 -07:00
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 net: sched: ematch: obtain net pointer from blocks 2017-10-16 21:00:40 +01:00
Kconfig net: sched: add em_ipt ematch for calling xtables matches 2018-02-21 13:15:33 -05:00
Makefile net: sched: add em_ipt ematch for calling xtables matches 2018-02-21 13:15:33 -05:00
sch_api.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
sch_atm.c net: sch: api: add extack support in qdisc_create_dflt 2017-12-21 12:32:51 -05:00
sch_blackhole.c net_sched: blackhole: tell upper qdisc about dropped packets 2018-06-17 08:42:33 +09:00
sch_cbq.c net: sch: sch_cbq: add extack support 2017-12-21 12:32:51 -05:00
sch_cbs.c net: sch: sch_cbs: add extack support 2017-12-21 12:32:51 -05:00
sch_choke.c net: sched: sch: add extack for change qdisc ops 2017-12-21 12:32:50 -05:00
sch_codel.c net: sched: sch: add extack for change qdisc ops 2017-12-21 12:32:50 -05:00
sch_drr.c net: sch: sch_drr: add extack support 2017-12-21 12:32:51 -05:00
sch_dsmark.c net: sch: api: add extack support in qdisc_create_dflt 2017-12-21 12:32:51 -05:00
sch_fifo.c net: sch: api: add extack support in qdisc_create_dflt 2017-12-21 12:32:51 -05:00
sch_fq.c net_sched: fq: take care of throttled flows before reuse 2018-05-02 16:37:38 -04:00
sch_fq_codel.c treewide: kvzalloc() -> kvcalloc() 2018-06-12 16:19:22 -07:00
sch_generic.c net: remove bypassed check in sch_direct_xmit() 2018-05-31 13:26:19 -04:00
sch_gred.c net: sched: sch: add extack for change qdisc ops 2017-12-21 12:32:50 -05:00
sch_hfsc.c net: sch: api: add extack support in qdisc_create_dflt 2017-12-21 12:32:51 -05:00
sch_hhf.c treewide: kvzalloc() -> kvcalloc() 2018-06-12 16:19:22 -07:00
sch_htb.c net: sched: do not emit messages while holding spinlock 2018-04-01 20:53:50 -04:00
sch_ingress.c net: sched: allow ingress and clsact qdiscs to share filter blocks 2018-01-17 14:53:57 -05:00
sch_mq.c net: sched: mq: request stats from offloads 2018-05-29 09:49:16 -04:00
sch_mqprio.c net: sch: api: add extack support in qdisc_create_dflt 2017-12-21 12:32:51 -05:00
sch_multiq.c net: sch: api: add extack support in qdisc_create_dflt 2017-12-21 12:32:51 -05:00
sch_netem.c sch_netem: fix skb leak in netem_enqueue() 2018-03-07 11:18:14 -05:00
sch_pie.c net: sched: sch: add extack for change qdisc ops 2017-12-21 12:32:50 -05:00
sch_plug.c net: sched: sch: add extack for change qdisc ops 2017-12-21 12:32:50 -05:00
sch_prio.c net: sch: prio: Add offload ability for grafting a child 2018-02-28 12:06:01 -05:00
sch_qfq.c net: sch: api: add extack support in qdisc_create_dflt 2017-12-21 12:32:51 -05:00
sch_red.c net: sched: red: avoid hashing NULL child 2018-05-18 13:52:32 -04:00
sch_sfb.c net: sch: api: add extack support in qdisc_create_dflt 2017-12-21 12:32:51 -05:00
sch_sfq.c net: sch: api: add extack support in tcf_block_get 2017-12-21 12:32:51 -05:00
sch_tbf.c net: sched: red: avoid hashing NULL child 2018-05-18 13:52:32 -04:00
sch_teql.c net: sched: sch: add extack for init callback 2017-12-21 12:32:50 -05:00