linux-brain/net/sched
Christoph Paasch d7519c01c9 net: Prevent invalid access to skb->prev in __qdisc_drop_all
[ Upstream commit 9410d386d0 ]

__qdisc_drop_all() accesses skb->prev to get to the tail of the
segment-list.

With commit 68d2f84a13 ("net: gro: properly remove skb from list")
the skb-list handling has been changed to set skb->next to NULL and set
the list-poison on skb->prev.

With that change, __qdisc_drop_all() will panic when it tries to
dereference skb->prev.

Since commit 992cba7e27 ("net: Add and use skb_list_del_init().")
__list_del_entry is used, leaving skb->prev unchanged (thus,
pointing to the list-head if it's the first skb of the list).
This will make __qdisc_drop_all modify the next-pointer of the list-head
and result in a panic later on:

[   34.501053] general protection fault: 0000 [#1] SMP KASAN PTI
[   34.501968] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.20.0-rc2.mptcp #108
[   34.502887] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.5.1 01/01/2011
[   34.504074] RIP: 0010:dev_gro_receive+0x343/0x1f90
[   34.504751] Code: e0 48 c1 e8 03 42 80 3c 30 00 0f 85 4a 1c 00 00 4d 8b 24 24 4c 39 65 d0 0f 84 0a 04 00 00 49 8d 7c 24 38 48 89 f8 48 c1 e8 03 <42> 0f b6 04 30 84 c0 74 08 3c 04
[   34.507060] RSP: 0018:ffff8883af507930 EFLAGS: 00010202
[   34.507761] RAX: 0000000000000007 RBX: ffff8883970b2c80 RCX: 1ffff11072e165a6
[   34.508640] RDX: 1ffff11075867008 RSI: ffff8883ac338040 RDI: 0000000000000038
[   34.509493] RBP: ffff8883af5079d0 R08: ffff8883970b2d40 R09: 0000000000000062
[   34.510346] R10: 0000000000000034 R11: 0000000000000000 R12: 0000000000000000
[   34.511215] R13: 0000000000000000 R14: dffffc0000000000 R15: ffff8883ac338008
[   34.512082] FS:  0000000000000000(0000) GS:ffff8883af500000(0000) knlGS:0000000000000000
[   34.513036] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   34.513741] CR2: 000055ccc3e9d020 CR3: 00000003abf32000 CR4: 00000000000006e0
[   34.514593] Call Trace:
[   34.514893]  <IRQ>
[   34.515157]  napi_gro_receive+0x93/0x150
[   34.515632]  receive_buf+0x893/0x3700
[   34.516094]  ? __netif_receive_skb+0x1f/0x1a0
[   34.516629]  ? virtnet_probe+0x1b40/0x1b40
[   34.517153]  ? __stable_node_chain+0x4d0/0x850
[   34.517684]  ? kfree+0x9a/0x180
[   34.518067]  ? __kasan_slab_free+0x171/0x190
[   34.518582]  ? detach_buf+0x1df/0x650
[   34.519061]  ? lapic_next_event+0x5a/0x90
[   34.519539]  ? virtqueue_get_buf_ctx+0x280/0x7f0
[   34.520093]  virtnet_poll+0x2df/0xd60
[   34.520533]  ? receive_buf+0x3700/0x3700
[   34.521027]  ? qdisc_watchdog_schedule_ns+0xd5/0x140
[   34.521631]  ? htb_dequeue+0x1817/0x25f0
[   34.522107]  ? sch_direct_xmit+0x142/0xf30
[   34.522595]  ? virtqueue_napi_schedule+0x26/0x30
[   34.523155]  net_rx_action+0x2f6/0xc50
[   34.523601]  ? napi_complete_done+0x2f0/0x2f0
[   34.524126]  ? kasan_check_read+0x11/0x20
[   34.524608]  ? _raw_spin_lock+0x7d/0xd0
[   34.525070]  ? _raw_spin_lock_bh+0xd0/0xd0
[   34.525563]  ? kvm_guest_apic_eoi_write+0x6b/0x80
[   34.526130]  ? apic_ack_irq+0x9e/0xe0
[   34.526567]  __do_softirq+0x188/0x4b5
[   34.527015]  irq_exit+0x151/0x180
[   34.527417]  do_IRQ+0xdb/0x150
[   34.527783]  common_interrupt+0xf/0xf
[   34.528223]  </IRQ>

This patch makes sure that skb->prev is set to NULL when entering
netem_enqueue.

Cc: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Cc: Tyler Hicks <tyhicks@canonical.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Fixes: 68d2f84a13 ("net: gro: properly remove skb from list")
Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Christoph Paasch <cpaasch@apple.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-17 21:55:09 +01:00
..
Kconfig net: add CONFIG_NET_INGRESS to enable ingress filtering 2015-05-14 01:10:05 -04:00
Makefile tc: introduce Flower classifier 2015-05-13 15:19:48 -04:00
act_api.c net sched actions: fix dumping which requires several messages to user space 2018-04-13 19:50:27 +02:00
act_bpf.c net/sched: fix NULL dereference in the error path of tcf_bpf_init() 2018-04-13 19:50:25 +02:00
act_connmark.c act_connmark: avoid crashing on malformed nlattrs with null parms 2017-03-22 12:04:16 +01:00
act_csum.c sched: act_csum: don't mangle TCP and UDP GSO packets 2018-03-22 09:23:22 +01:00
act_gact.c net_sched: act_gact: remove spinlock in fast path 2015-07-08 13:50:42 -07:00
act_ipt.c net: sched: fix NULL pointer dereference when action calls some targets 2017-08-30 10:19:21 +02:00
act_mirred.c net_sched: close another race condition in tcf_mirred_release() 2017-05-02 21:19:49 -07:00
act_nat.c bpf: try harder on clones when writing into skb 2016-07-11 09:31:12 -07:00
act_pedit.c net/sched: pedit: make sure that offset is valid 2016-12-10 19:07:23 +01:00
act_police.c sched: fix act file names in header comment 2014-11-06 15:04:41 -05:00
act_simple.c net: sched: add percpu stats to actions 2015-07-08 13:50:41 -07:00
act_skbedit.c net: sched: add percpu stats to actions 2015-07-08 13:50:41 -07:00
act_vlan.c net/sched: act_vlan: Push skb->data to mac_header prior calling skb_vlan_*() functions 2016-11-15 07:46:37 +01:00
cls_api.c net, sched: fix soft lockup in tc_classify 2017-01-15 13:41:34 +01:00
cls_basic.c net, sched: respect rcu grace period on cls destruction 2016-12-10 19:07:23 +01:00
cls_bpf.c net, sched: respect rcu grace period on cls destruction 2016-12-10 19:07:23 +01:00
cls_cgroup.c net, sched: respect rcu grace period on cls destruction 2016-12-10 19:07:23 +01:00
cls_flow.c net, sched: respect rcu grace period on cls destruction 2016-12-10 19:07:23 +01:00
cls_flower.c net, sched: respect rcu grace period on cls destruction 2016-12-10 19:07:23 +01:00
cls_fw.c net: revert "net_sched: move tp->root allocation into fw_init()" 2015-09-24 14:33:30 -07:00
cls_route.c net_sched: destroy proto tp when all filters are gone 2015-03-09 15:35:55 -04:00
cls_rsvp.c
cls_rsvp.h net, sched: respect rcu grace period on cls destruction 2016-12-10 19:07:23 +01:00
cls_rsvp6.c
cls_tcindex.c net_sched: fix NULL pointer dereference when delete tcindex filter 2018-08-22 07:48:35 +02:00
cls_u32.c cls_u32: complete the check for non-forced case in u32_destroy() 2015-08-25 17:02:48 -07:00
em_canid.c net: sched: remove tcf_proto from ematch calls 2014-10-06 18:02:32 -04:00
em_cmp.c net_sched: cleanups 2011-01-19 23:31:12 -08:00
em_ipset.c netfilter: x_tables: Pass struct net in xt_action_param 2015-09-18 21:58:14 +02:00
em_meta.c net_sched: em_meta: use skb_to_full_sk() helper 2015-11-08 20:56:39 -05:00
em_nbyte.c net: sched: remove tcf_proto from ematch calls 2014-10-06 18:02:32 -04:00
em_text.c net: Remove state argument from skb_find_text() 2015-02-22 15:59:54 -05:00
em_u32.c net_sched: cleanups 2011-01-19 23:31:12 -08:00
ematch.c ematch: Fix auto-loading of ematch modules. 2015-02-20 15:30:56 -05:00
sch_api.c net: sched: Fix one possible panic when no destroy callback 2017-07-21 07:44:54 +02:00
sch_atm.c net: sched: consolidate tc_classify{,_compat} 2015-08-27 14:18:48 -07:00
sch_blackhole.c net_sched: blackhole: tell upper qdisc about dropped packets 2018-07-22 14:25:53 +02:00
sch_cbq.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_choke.c net_sched: red: Avoid illegal values 2018-02-25 11:03:40 +01:00
sch_codel.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_drr.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_dsmark.c sch_dsmark: fix invalid skb_cow() usage 2017-12-25 14:22:10 +01:00
sch_fifo.c net_sched: fix pfifo_head_drop behavior vs backlog 2016-07-11 09:31:11 -07:00
sch_fq.c net_sched: fq: take care of throttled flows before reuse 2018-05-26 08:48:47 +02:00
sch_fq_codel.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_generic.c net: sched: do not requeue a NULL skb 2016-05-18 17:06:35 -07:00
sch_gred.c net: sched: gred: pass the right attribute to gred_change_table_def() 2018-11-10 07:41:41 -08:00
sch_hfsc.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_hhf.c sch_hhf: fix null pointer dereference on init failure 2018-09-15 09:40:41 +02:00
sch_htb.c sch_htb: fix crash on init failure 2018-09-15 09:40:41 +02:00
sch_ingress.c net: sched: further simplify handle_ing 2015-05-11 11:10:35 -04:00
sch_mq.c net_sched: fix error recovery at qdisc creation 2017-07-21 07:44:54 +02:00
sch_mqprio.c net_sched: fix error recovery at qdisc creation 2017-07-21 07:44:54 +02:00
sch_multiq.c sch_multiq: fix double free on init failure 2018-09-15 09:40:41 +02:00
sch_netem.c net: Prevent invalid access to skb->prev in __qdisc_drop_all 2018-12-17 21:55:09 +01:00
sch_pie.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_plug.c net: sched: drop all special handling of tx_queue_len == 0 2015-08-18 11:55:08 -07:00
sch_prio.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_qfq.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_red.c sch_red: update backlog as well 2018-11-10 07:41:37 -08:00
sch_sfb.c net_sched: update hierarchical backlog too 2016-05-18 17:06:39 -07:00
sch_sfq.c net_sched: red: Avoid illegal values 2018-02-25 11:03:40 +01:00
sch_tbf.c sch_tbf: fix two null pointer dereferences on init failure 2018-09-15 09:40:42 +02:00
sch_teql.c net: sched: fix skb->protocol use in case of accelerated vlan path 2015-01-13 17:51:08 -05:00