• Eric Dumazet's avatar
    net: sched: fix uses after free · cce6294c
    Eric Dumazet authored
    syzbot reported one use-after-free in pfifo_fast_enqueue() [1]
    
    Issue here is that we can not reuse skb after a successful skb_array_produce()
    since another cpu might have consumed it already.
    
    I believe a similar problem exists in try_bulk_dequeue_skb_slow()
    in case we put an skb into qdisc_enqueue_skb_bad_txq() for lockless qdisc.
    
    [1]
    BUG: KASAN: use-after-free in qdisc_pkt_len include/net/sch_generic.h:610 [inline]
    BUG: KASAN: use-after-free in qdisc_qstats_cpu_backlog_inc include/net/sch_generic.h:712 [inline]
    BUG: KASAN: use-after-free in pfifo_fast_enqueue+0x4bc/0x5e0 net/sched/sch_generic.c:639
    Read of size 4 at addr ffff8801cede37e8 by task syzkaller717588/5543
    
    CPU: 1 PID: 5543 Comm: syzkaller717588 Not tainted 4.16.0-rc4+ #265
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     __dump_stack lib/dump_stack.c:17 [inline]
     dump_stack+0x194/0x24d lib/dump_stack.c:53
     print_address_description+0x73/0x250 mm/kasan/report.c:256
     kasan_report_error mm/kasan/report.c:354 [inline]
     kasan_report+0x23c/0x360 mm/kasan/report.c:412
     __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
     qdisc_pkt_len include/net/sch_generic.h:610 [inline]
     qdisc_qstats_cpu_backlog_inc include/net/sch_generic.h:712 [inline]
     pfifo_fast_enqueue+0x4bc/0x5e0 net/sched/sch_generic.c:639
     __dev_xmit_skb net/core/dev.c:3216 [inline]
    
    Fixes: c5ad119f ("net: sched: pfifo_fast use skb_array")
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Reported-by: syzbot+ed43b6903ab968b16f54@syzkaller.appspotmail.com
    Cc: John Fastabend <john.fastabend@gmail.com>
    Cc: Jamal Hadi Salim <jhs@mojatatu.com>
    Cc:	Cong Wang <xiyou.wangcong@gmail.com>
    Cc:	Jiri Pirko <jiri@resnulli.us>
    Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    cce6294c
sch_generic.c 31.8 KB