• Sheng Lan's avatar
    net: netem: fix skb length BUG_ON in __skb_to_sgvec · 5845f706
    Sheng Lan authored
    It can be reproduced by following steps:
    1. virtio_net NIC is configured with gso/tso on
    2. configure nginx as http server with an index file bigger than 1M bytes
    3. use tc netem to produce duplicate packets and delay:
       tc qdisc add dev eth0 root netem delay 100ms 10ms 30% duplicate 90%
    4. continually curl the nginx http server to get index file on client
    5. BUG_ON is seen quickly
    
    [10258690.371129] kernel BUG at net/core/skbuff.c:4028!
    [10258690.371748] invalid opcode: 0000 [#1] SMP PTI
    [10258690.372094] CPU: 5 PID: 0 Comm: swapper/5 Tainted: G        W         5.0.0-rc6 #2
    [10258690.372094] RSP: 0018:ffffa05797b43da0 EFLAGS: 00010202
    [10258690.372094] RBP: 00000000000005ea R08: 0000000000000000 R09: 00000000000005ea
    [10258690.372094] R10: ffffa0579334d800 R11: 00000000000002c0 R12: 0000000000000002
    [10258690.372094] R13: 0000000000000000 R14: ffffa05793122900 R15: ffffa0578f7cb028
    [10258690.372094] FS:  0000000000000000(0000) GS:ffffa05797b40000(0000) knlGS:0000000000000000
    [10258690.372094] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [10258690.372094] CR2: 00007f1a6dc00868 CR3: 000000001000e000 CR4: 00000000000006e0
    [10258690.372094] Call Trace:
    [10258690.372094]  <IRQ>
    [10258690.372094]  skb_to_sgvec+0x11/0x40
    [10258690.372094]  start_xmit+0x38c/0x520 [virtio_net]
    [10258690.372094]  dev_hard_start_xmit+0x9b/0x200
    [10258690.372094]  sch_direct_xmit+0xff/0x260
    [10258690.372094]  __qdisc_run+0x15e/0x4e0
    [10258690.372094]  net_tx_action+0x137/0x210
    [10258690.372094]  __do_softirq+0xd6/0x2a9
    [10258690.372094]  irq_exit+0xde/0xf0
    [10258690.372094]  smp_apic_timer_interrupt+0x74/0x140
    [10258690.372094]  apic_timer_interrupt+0xf/0x20
    [10258690.372094]  </IRQ>
    
    In __skb_to_sgvec(), the skb->len is not equal to the sum of the skb's
    linear data size and nonlinear data size, thus BUG_ON triggered.
    Because the skb is cloned and a part of nonlinear data is split off.
    
    Duplicate packet is cloned in netem_enqueue() and may be delayed
    some time in qdisc. When qdisc len reached the limit and returns
    NET_XMIT_DROP, the skb will be retransmit later in write queue.
    the skb will be fragmented by tso_fragment(), the limit size
    that depends on cwnd and mss decrease, the skb's nonlinear
    data will be split off. The length of the skb cloned by netem
    will not be updated. When we use virtio_net NIC and invoke skb_to_sgvec(),
    the BUG_ON trigger.
    
    To fix it, netem returns NET_XMIT_SUCCESS to upper stack
    when it clones a duplicate packet.
    
    Fixes: 35d889d1 ("sch_netem: fix skb leak in netem_enqueue()")
    Signed-off-by: default avatarSheng Lan <lansheng@huawei.com>
    Reported-by: default avatarQin Ji <jiqin.ji@huawei.com>
    Suggested-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    5845f706
Name
Last commit
Last update
..
Kconfig Loading commit data...
Makefile Loading commit data...
act_api.c Loading commit data...
act_bpf.c Loading commit data...
act_connmark.c Loading commit data...
act_csum.c Loading commit data...
act_gact.c Loading commit data...
act_ife.c Loading commit data...
act_ipt.c Loading commit data...
act_meta_mark.c Loading commit data...
act_meta_skbprio.c Loading commit data...
act_meta_skbtcindex.c Loading commit data...
act_mirred.c Loading commit data...
act_nat.c Loading commit data...
act_pedit.c Loading commit data...
act_police.c Loading commit data...
act_sample.c Loading commit data...
act_simple.c Loading commit data...
act_skbedit.c Loading commit data...
act_skbmod.c Loading commit data...
act_tunnel_key.c Loading commit data...
act_vlan.c Loading commit data...
cls_api.c Loading commit data...
cls_basic.c Loading commit data...
cls_bpf.c Loading commit data...
cls_cgroup.c Loading commit data...
cls_flow.c Loading commit data...
cls_flower.c Loading commit data...
cls_fw.c Loading commit data...
cls_matchall.c Loading commit data...
cls_route.c Loading commit data...
cls_rsvp.c Loading commit data...
cls_rsvp.h Loading commit data...
cls_rsvp6.c Loading commit data...
cls_tcindex.c Loading commit data...
cls_u32.c Loading commit data...
em_canid.c Loading commit data...
em_cmp.c Loading commit data...
em_ipset.c Loading commit data...
em_ipt.c Loading commit data...
em_meta.c Loading commit data...
em_nbyte.c Loading commit data...
em_text.c Loading commit data...
em_u32.c Loading commit data...
ematch.c Loading commit data...
sch_api.c Loading commit data...
sch_atm.c Loading commit data...
sch_blackhole.c Loading commit data...
sch_cake.c Loading commit data...
sch_cbq.c Loading commit data...
sch_cbs.c Loading commit data...
sch_choke.c Loading commit data...
sch_codel.c Loading commit data...
sch_drr.c Loading commit data...
sch_dsmark.c Loading commit data...
sch_etf.c Loading commit data...
sch_fifo.c Loading commit data...
sch_fq.c Loading commit data...
sch_fq_codel.c Loading commit data...
sch_generic.c Loading commit data...
sch_gred.c Loading commit data...
sch_hfsc.c Loading commit data...
sch_hhf.c Loading commit data...
sch_htb.c Loading commit data...
sch_ingress.c Loading commit data...
sch_mq.c Loading commit data...
sch_mqprio.c Loading commit data...
sch_multiq.c Loading commit data...
sch_netem.c Loading commit data...
sch_pie.c Loading commit data...
sch_plug.c Loading commit data...
sch_prio.c Loading commit data...
sch_qfq.c Loading commit data...
sch_red.c Loading commit data...
sch_sfb.c Loading commit data...
sch_sfq.c Loading commit data...
sch_skbprio.c Loading commit data...
sch_taprio.c Loading commit data...
sch_tbf.c Loading commit data...
sch_teql.c Loading commit data...