syzbot


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

Status: fixed on 2020/02/28 16:14
Reported-by: syzbot+c47bbdd0fc4eea31a787@syzkaller.appspotmail.com
Fix commit: 66ac8ee96faa net_sched: fix datalen for ematch
First crash: 1758d, last: 1758d
Fix bisection: fixed by (bisect log) :
commit 66ac8ee96faa582a252ae19510f35529c9143670
Author: Cong Wang <xiyou.wangcong@gmail.com>
Date: Wed Jan 22 23:42:02 2020 +0000

  net_sched: fix datalen for ematch

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: slab-out-of-bounds Read in __nla_put_nohdr C done 2 1759d 1759d 1/1 fixed on 2020/02/27 08:36
upstream KASAN: slab-out-of-bounds Read in __nla_put_nohdr net C done 4 1765d 1765d 15/28 fixed on 2020/02/18 14:31

Sample crash report:
audit: type=1400 audit(1580255901.197:36): avc:  denied  { map } for  pid=8161 comm="syz-executor916" path="/root/syz-executor916294225" dev="sda1" ino=16483 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
IPVS: ftp: loaded support on port[0] = 21
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:348 [inline]
BUG: KASAN: slab-out-of-bounds in __nla_put_nohdr+0x46/0x50 lib/nlattr.c:608
Read of size 8 at addr ffff88809664f480 by task syz-executor916/8162

CPU: 0 PID: 8162 Comm: syz-executor916 Not tainted 4.19.99-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+0x197/0x210 lib/dump_stack.c:118
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x123/0x190 mm/kasan/kasan.c:267
 memcpy+0x24/0x50 mm/kasan/kasan.c:302
 memcpy include/linux/string.h:348 [inline]
 __nla_put_nohdr+0x46/0x50 lib/nlattr.c:608
 nla_put_nohdr+0xff/0x140 lib/nlattr.c:674
 tcf_em_tree_dump+0x67e/0x960 net/sched/ematch.c:474
 basic_dump net/sched/cls_basic.c:285 [inline]
 basic_dump+0x21e/0x4c0 net/sched/cls_basic.c:265
 tcf_fill_node+0x574/0x950 net/sched/cls_api.c:1101
 tfilter_notify+0x129/0x270 net/sched/cls_api.c:1125
 tc_new_tfilter+0xcc8/0x1790 net/sched/cls_api.c:1326
 rtnetlink_rcv_msg+0x463/0xb00 net/core/rtnetlink.c:4768
 netlink_rcv_skb+0x17d/0x460 net/netlink/af_netlink.c:2454
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:4786
 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
 netlink_unicast+0x53a/0x730 net/netlink/af_netlink.c:1343
 netlink_sendmsg+0x8ae/0xd70 net/netlink/af_netlink.c:1908
 sock_sendmsg_nosec net/socket.c:622 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:632
 ___sys_sendmsg+0x803/0x920 net/socket.c:2115
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2153
 __do_sys_sendmsg net/socket.c:2162 [inline]
 __se_sys_sendmsg net/socket.c:2160 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2160
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4410b9
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 7b 10 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffd1d397b08 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000004a28b0 RCX: 00000000004410b9
RDX: 0000000000000000 RSI: 00000000200001c0 RDI: 0000000000000003
RBP: 00000000006cc018 R08: 0000000120080522 R09: 0000000120080522
R10: 0000000120080522 R11: 0000000000000246 R12: 00000000004025c0
R13: 0000000000402650 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 8162:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 __do_kmalloc mm/slab.c:3727 [inline]
 __kmalloc_track_caller+0x159/0x750 mm/slab.c:3742
 kmemdup+0x27/0x60 mm/util.c:118
 kmemdup include/linux/string.h:421 [inline]
 em_nbyte_change+0xd6/0x150 net/sched/em_nbyte.c:36
 tcf_em_validate net/sched/ematch.c:245 [inline]
 tcf_em_tree_validate net/sched/ematch.c:362 [inline]
 tcf_em_tree_validate+0x9a9/0xf30 net/sched/ematch.c:304
 basic_set_parms net/sched/cls_basic.c:155 [inline]
 basic_change+0x126e/0x1370 net/sched/cls_basic.c:212
 tc_new_tfilter+0xc54/0x1790 net/sched/cls_api.c:1320
 rtnetlink_rcv_msg+0x463/0xb00 net/core/rtnetlink.c:4768
 netlink_rcv_skb+0x17d/0x460 net/netlink/af_netlink.c:2454
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:4786
 netlink_unicast_kernel net/netlink/af_netlink.c:1317 [inline]
 netlink_unicast+0x53a/0x730 net/netlink/af_netlink.c:1343
 netlink_sendmsg+0x8ae/0xd70 net/netlink/af_netlink.c:1908
 sock_sendmsg_nosec net/socket.c:622 [inline]
 sock_sendmsg+0xd7/0x130 net/socket.c:632
 ___sys_sendmsg+0x803/0x920 net/socket.c:2115
 __sys_sendmsg+0x105/0x1d0 net/socket.c:2153
 __do_sys_sendmsg net/socket.c:2162 [inline]
 __se_sys_sendmsg net/socket.c:2160 [inline]
 __x64_sys_sendmsg+0x78/0xb0 net/socket.c:2160
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 5714:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcf/0x220 mm/slab.c:3822
 xattr_getsecurity fs/xattr.c:252 [inline]
 vfs_getxattr+0x1fa/0x2a0 fs/xattr.c:331
 getxattr+0x110/0x2d0 fs/xattr.c:537
 path_getxattr+0xd1/0x170 fs/xattr.c:565
 __do_sys_lgetxattr fs/xattr.c:583 [inline]
 __se_sys_lgetxattr fs/xattr.c:580 [inline]
 __x64_sys_lgetxattr+0x9a/0xf0 fs/xattr.c:580
 do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809664f480
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
 32-byte region [ffff88809664f480, ffff88809664f4a0)
The buggy address belongs to the page:
page:ffffea00025993c0 count:1 mapcount:0 mapping:ffff88812c31c1c0 index:0xffff88809664ffc1
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea00029852c8 ffff88812c314248 ffff88812c31c1c0
raw: ffff88809664ffc1 ffff88809664f000 000000010000003f 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809664f380: 00 00 01 fc fc fc fc fc fb fb fb fb fc fc fc fc
 ffff88809664f400: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
>ffff88809664f480: 04 fc fc fc fc fc fc fc fb fb fb fb fc fc fc fc
                   ^
 ffff88809664f500: 00 00 00 00 fc fc fc fc fb fb fb fb fc fc fc fc
 ffff88809664f580: 00 00 01 fc fc fc fc fc fb fb fb fb fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/01/29 00:01 linux-4.19.y 88d6de67e390 c8e81ce4 .config console log report syz C ci2-linux-4-19
* Struck through repros no longer work on HEAD.