syzbot


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

Status: fixed on 2020/02/27 08:36
Reported-by: syzbot+05a54ad651bb814ba6af@syzkaller.appspotmail.com
Fix commit: c5fd8a37e971 net-sysfs: Fix reference count leak
First crash: 1759d, last: 1759d
Fix bisection: fixed by (bisect log) :
commit c5fd8a37e97100254a2178e470e9641c51e91dbb
Author: Jouni Hogander <jouni.hogander@unikie.com>
Date: Mon Jan 20 07:51:03 2020 +0000

  net-sysfs: Fix reference count leak

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: slab-out-of-bounds Read in __nla_put_nohdr C done 1 1758d 1758d 1/1 fixed on 2020/02/28 16:14
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(1580164526.071:36): avc:  denied  { map } for  pid=7355 comm="syz-executor935" path="/root/syz-executor935341964" 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:347 [inline]
BUG: KASAN: slab-out-of-bounds in __nla_put_nohdr+0x46/0x50 lib/nlattr.c:585
Read of size 8 at addr ffff88809fb72f80 by task syz-executor935/7356

CPU: 0 PID: 7356 Comm: syz-executor935 Not tainted 4.14.168-syzkaller #0
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+0x142/0x197 lib/dump_stack.c:58
 print_address_description.cold+0x7c/0x1dc mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report mm/kasan/report.c:409 [inline]
 kasan_report.cold+0xa9/0x2af mm/kasan/report.c:393
 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:347 [inline]
 __nla_put_nohdr+0x46/0x50 lib/nlattr.c:585
 nla_put_nohdr+0xe8/0x120 lib/nlattr.c:651
 tcf_em_tree_dump+0x5d1/0x890 net/sched/ematch.c:474
 basic_dump net/sched/cls_basic.c:290 [inline]
 basic_dump+0x1bd/0x410 net/sched/cls_basic.c:270
 tcf_fill_node+0x536/0x860 net/sched/cls_api.c:453
 tfilter_notify+0x11d/0x240 net/sched/cls_api.c:476
 tc_ctl_tfilter+0x1048/0x1aba net/sched/cls_api.c:743
 rtnetlink_rcv_msg+0x3da/0xb70 net/core/rtnetlink.c:4306
 netlink_rcv_skb+0x14f/0x3c0 net/netlink/af_netlink.c:2432
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:4318
 netlink_unicast_kernel net/netlink/af_netlink.c:1286 [inline]
 netlink_unicast+0x44d/0x650 net/netlink/af_netlink.c:1312
 netlink_sendmsg+0x7c4/0xc60 net/netlink/af_netlink.c:1877
 sock_sendmsg_nosec net/socket.c:646 [inline]
 sock_sendmsg+0xce/0x110 net/socket.c:656
 ___sys_sendmsg+0x70a/0x840 net/socket.c:2062
 __sys_sendmsg+0xb9/0x140 net/socket.c:2096
 SYSC_sendmsg net/socket.c:2107 [inline]
 SyS_sendmsg+0x2d/0x50 net/socket.c:2103
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x4410b9
RSP: 002b:00007ffff343aaf8 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 7356:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
 __do_kmalloc mm/slab.c:3720 [inline]
 __kmalloc_track_caller+0x159/0x790 mm/slab.c:3735
 kmemdup+0x27/0x60 mm/util.c:118
 kmemdup include/linux/string.h:420 [inline]
 em_nbyte_change+0xb9/0x130 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+0x922/0xe7e net/sched/ematch.c:304
 basic_set_parms net/sched/cls_basic.c:158 [inline]
 basic_change+0x451/0xfb0 net/sched/cls_basic.c:222
 tc_ctl_tfilter+0xff1/0x1aba net/sched/cls_api.c:738
 rtnetlink_rcv_msg+0x3da/0xb70 net/core/rtnetlink.c:4306
 netlink_rcv_skb+0x14f/0x3c0 net/netlink/af_netlink.c:2432
 rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:4318
 netlink_unicast_kernel net/netlink/af_netlink.c:1286 [inline]
 netlink_unicast+0x44d/0x650 net/netlink/af_netlink.c:1312
 netlink_sendmsg+0x7c4/0xc60 net/netlink/af_netlink.c:1877
 sock_sendmsg_nosec net/socket.c:646 [inline]
 sock_sendmsg+0xce/0x110 net/socket.c:656
 ___sys_sendmsg+0x70a/0x840 net/socket.c:2062
 __sys_sendmsg+0xb9/0x140 net/socket.c:2096
 SYSC_sendmsg net/socket.c:2107 [inline]
 SyS_sendmsg+0x2d/0x50 net/socket.c:2103
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 5619:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xcc/0x270 mm/slab.c:3815
 xattr_getsecurity+0x104/0x110 fs/xattr.c:253
 vfs_getxattr+0xc6/0x110 fs/xattr.c:333
 getxattr+0xef/0x2a0 fs/xattr.c:540
 path_getxattr+0xa3/0x100 fs/xattr.c:568
 SYSC_lgetxattr fs/xattr.c:586 [inline]
 SyS_lgetxattr+0x31/0x40 fs/xattr.c:583
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff88809fb72f80
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 0 bytes inside of
 32-byte region [ffff88809fb72f80, ffff88809fb72fa0)
The buggy address belongs to the page:
page:ffffea00027edc80 count:1 mapcount:0 mapping:ffff88809fb72000 index:0xffff88809fb72fc1
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff88809fb72000 ffff88809fb72fc1 000000010000003b
raw: ffffea00027e1aa0 ffffea00027d7120 ffff8880aa8001c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809fb72e80: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc
 ffff88809fb72f00: 06 fc fc fc fc fc fc fc fb fb fb fb fc fc fc fc
>ffff88809fb72f80: 04 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffff88809fb73000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809fb73080: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/01/27 22:38 linux-4.14.y 9a95f25269bd 56cd6c9b .config console log report syz C ci2-linux-4-14
2020/01/27 22:04 linux-4.14.y 9a95f25269bd 56cd6c9b .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.