syzbot


KASAN: slab-out-of-bounds Read in skb_gso_transport_seglen

Status: fixed on 2020/07/17 17:58
Subsystems: net
[Documentation on labels]
Fix commit: 9274124f023b net: stricter validation of untrusted gso packets
First crash: 1439d, last: 1420d
Cause bisection: introduced by (bisect log) :
commit 9d2f67e43b73e8af7438be219b66a5de0cfa8bd9
Author: Jianfeng Tan <jianfeng.tan@linux.alibaba.com>
Date: Sat Sep 29 15:41:27 2018 +0000

  net/packet: fix packet drop as of virtio gso

Crash: KASAN: slab-out-of-bounds Read in skb_gso_transport_seglen (log)
Repro: C syz .config
  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: slab-out-of-bounds Read in skb_gso_transport_seglen 1 1421d 1421d 0/1 auto-closed as invalid on 2020/09/04 10:34

Sample crash report:
netlink: 1996 bytes leftover after parsing attributes in process `syz-executor373'.
sch_tbf: burst 549 is lower than device lo mtu (65550) !
==================================================================
BUG: KASAN: slab-out-of-bounds in __tcp_hdrlen include/linux/tcp.h:31 [inline]
BUG: KASAN: slab-out-of-bounds in tcp_hdrlen include/linux/tcp.h:36 [inline]
BUG: KASAN: slab-out-of-bounds in skb_gso_transport_seglen+0x344/0x360 net/core/skbuff.c:5266
Read of size 2 at addr ffff8880a84ec25c by task syz-executor373/7031

CPU: 0 PID: 7031 Comm: syz-executor373 Not tainted 5.7.0-rc1-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x315 mm/kasan/report.c:382
 __kasan_report.cold+0x35/0x4d mm/kasan/report.c:511
 kasan_report+0x33/0x50 mm/kasan/common.c:625
 __tcp_hdrlen include/linux/tcp.h:31 [inline]
 tcp_hdrlen include/linux/tcp.h:36 [inline]
 skb_gso_transport_seglen+0x344/0x360 net/core/skbuff.c:5266
 skb_gso_mac_seglen net/core/skbuff.c:5310 [inline]
 skb_gso_validate_mac_len+0x85/0x290 net/core/skbuff.c:5381
 tbf_enqueue+0x1f2/0x990 net/sched/sch_tbf.c:233
 __dev_xmit_skb net/core/dev.c:3710 [inline]
 __dev_queue_xmit+0x154a/0x30a0 net/core/dev.c:4021
 packet_snd net/packet/af_packet.c:2979 [inline]
 packet_sendmsg+0x23cc/0x5ce0 net/packet/af_packet.c:3004
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 __sys_sendto+0x220/0x330 net/socket.c:2000
 __do_sys_sendto net/socket.c:2012 [inline]
 __se_sys_sendto net/socket.c:2008 [inline]
 __x64_sys_sendto+0xdd/0x1b0 net/socket.c:2008
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x440419
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffdc977f428 EFLAGS: 00000246 ORIG_RAX: 000000000000002c
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440419
RDX: 0000000000004e60 RSI: 0000000020000180 RDI: 0000000000000005
RBP: 00000000006cb018 R08: 0000000000000000 R09: fffffffffffffe5d
R10: 0000000000000810 R11: 0000000000000246 R12: 0000000000401ca0
R13: 0000000000401d30 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7031:
 save_stack+0x1b/0x40 mm/kasan/common.c:49
 set_track mm/kasan/common.c:57 [inline]
 __kasan_kmalloc mm/kasan/common.c:495 [inline]
 __kasan_kmalloc.constprop.0+0xbf/0xd0 mm/kasan/common.c:468
 __kmalloc_reserve.isra.0+0x39/0xe0 net/core/skbuff.c:142
 __alloc_skb+0xef/0x5a0 net/core/skbuff.c:210
 alloc_skb include/linux/skbuff.h:1083 [inline]
 alloc_skb_with_frags+0x92/0x560 net/core/skbuff.c:5772
 sock_alloc_send_pskb+0x734/0x890 net/core/sock.c:2265
 packet_alloc_skb net/packet/af_packet.c:2827 [inline]
 packet_snd net/packet/af_packet.c:2922 [inline]
 packet_sendmsg+0x1947/0x5ce0 net/packet/af_packet.c:3004
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 __sys_sendto+0x220/0x330 net/socket.c:2000
 __do_sys_sendto net/socket.c:2012 [inline]
 __se_sys_sendto net/socket.c:2008 [inline]
 __x64_sys_sendto+0xdd/0x1b0 net/socket.c:2008
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3

Freed by task 17:
 save_stack+0x1b/0x40 mm/kasan/common.c:49
 set_track mm/kasan/common.c:57 [inline]
 kasan_set_free_info mm/kasan/common.c:317 [inline]
 __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:456
 __cache_free mm/slab.c:3426 [inline]
 kmem_cache_free_bulk+0x7d/0x280 mm/slab.c:3721
 kfree_bulk include/linux/slab.h:412 [inline]
 kfree_rcu_work+0x1a1/0x480 kernel/rcu/tree.c:2859
 process_one_work+0x965/0x16a0 kernel/workqueue.c:2268
 worker_thread+0x96/0xe20 kernel/workqueue.c:2414
 kthread+0x388/0x470 kernel/kthread.c:268
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352

The buggy address belongs to the object at ffff8880a84ec000
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 92 bytes to the right of
 512-byte region [ffff8880a84ec000, ffff8880a84ec200)
The buggy address belongs to the page:
page:ffffea0002a13b00 refcount:1 mapcount:0 mapping:00000000d23c3060 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea00027c4588 ffffea00029c0688 ffff8880aa000a80
raw: 0000000000000000 ffff8880a84ec000 0000000100000004 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a84ec100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff8880a84ec180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880a84ec200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                                                    ^
 ffff8880a84ec280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880a84ec300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/04/19 15:40 upstream 50cc09c18985 6dfd45e1 .config console log report syz C ci-upstream-kasan-gce
2020/04/21 03:26 upstream ae83d0b416db 98a9f9e6 .config console log report syz C ci-upstream-kasan-gce-386
2020/04/19 10:45 net-old 441870ee4240 365fba24 .config console log report syz C ci-upstream-net-this-kasan-gce
2020/05/08 17:25 linux-next ac935d227366 2b98fdbc .config console log report syz C ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.