syzbot


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

Status: fixed on 2021/03/10 01:48
Subsystems: net s390
[Documentation on labels]
Reported-by: syzbot+14101f19c94fba071512@syzkaller.appspotmail.com
Fix commit: 995433b795ce net/smc: fix access to parent of an ib device
First crash: 1188d, last: 1188d

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in smc_set_pci_values net/smc/smc_core.h:396 [inline]
BUG: KASAN: slab-out-of-bounds in smc_nl_handle_smcr_dev.isra.0+0x111b/0x11b0 net/smc/smc_ib.c:422
Read of size 2 at addr ffff888026985f84 by task syz-executor.5/11535

CPU: 0 PID: 11535 Comm: syz-executor.5 Not tainted 5.10.0-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x107/0x163 lib/dump_stack.c:120
 print_address_description.constprop.0.cold+0xae/0x4c8 mm/kasan/report.c:385
 __kasan_report mm/kasan/report.c:545 [inline]
 kasan_report.cold+0x1f/0x37 mm/kasan/report.c:562
 smc_set_pci_values net/smc/smc_core.h:396 [inline]
 smc_nl_handle_smcr_dev.isra.0+0x111b/0x11b0 net/smc/smc_ib.c:422
 smc_nl_prep_smcr_dev net/smc/smc_ib.c:469 [inline]
 smcr_nl_get_device+0xdf/0x1f0 net/smc/smc_ib.c:481
 genl_lock_dumpit+0x60/0x90 net/netlink/genetlink.c:623
 netlink_dump+0x4b9/0xb70 net/netlink/af_netlink.c:2268
 __netlink_dump_start+0x642/0x900 net/netlink/af_netlink.c:2373
 genl_family_rcv_msg_dumpit+0x2af/0x310 net/netlink/genetlink.c:686
 genl_family_rcv_msg net/netlink/genetlink.c:780 [inline]
 genl_rcv_msg+0x434/0x580 net/netlink/genetlink.c:800
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:811
 netlink_unicast_kernel net/netlink/af_netlink.c:1304 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1330
 netlink_sendmsg+0x856/0xd90 net/netlink/af_netlink.c:1919
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2336
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2390
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2423
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45e149
Code: 0d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 db b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fc607914c68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045e149
RDX: 00000000000008c0 RSI: 0000000020000080 RDI: 0000000000000003
RBP: 000000000119bfc0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000119bf8c
R13: 00007ffe15f2b6ef R14: 00007fc6079159c0 R15: 000000000119bf8c

Allocated by task 8489:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track mm/kasan/common.c:56 [inline]
 __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:461
 kmalloc_node include/linux/slab.h:575 [inline]
 kvmalloc_node+0x61/0xf0 mm/util.c:575
 kvmalloc include/linux/mm.h:773 [inline]
 kvmalloc_array include/linux/mm.h:791 [inline]
 alloc_fdtable+0xcd/0x280 fs/file.c:119
 dup_fd+0x726/0xc90 fs/file.c:324
 copy_files kernel/fork.c:1467 [inline]
 copy_process+0x1ed7/0x6fc0 kernel/fork.c:2087
 kernel_clone+0xe7/0xab0 kernel/fork.c:2464
 __do_sys_clone+0xc8/0x110 kernel/fork.c:2581
 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 11522:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_set_track+0x1c/0x30 mm/kasan/common.c:56
 kasan_set_free_info+0x1b/0x30 mm/kasan/generic.c:352
 __kasan_slab_free+0x102/0x140 mm/kasan/common.c:422
 slab_free_hook mm/slub.c:1544 [inline]
 slab_free_freelist_hook+0x5d/0x150 mm/slub.c:1577
 slab_free mm/slub.c:3140 [inline]
 kfree+0xdb/0x360 mm/slub.c:4122
 kvfree+0x42/0x50 mm/util.c:604
 __free_fdtable fs/file.c:35 [inline]
 put_files_struct fs/file.c:434 [inline]
 put_files_struct+0x267/0x350 fs/file.c:427
 exit_files+0x12a/0x170 fs/file.c:460
 do_exit+0xb4f/0x29e0 kernel/exit.c:818
 do_group_exit+0x125/0x310 kernel/exit.c:920
 get_signal+0x42a/0x1fb0 kernel/signal.c:2792
 arch_do_signal_or_restart+0x2a8/0x1eb0 arch/x86/kernel/signal.c:811
 handle_signal_work kernel/entry/common.c:147 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
 exit_to_user_mode_prepare+0x124/0x200 kernel/entry/common.c:201
 __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
 syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:302
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Last potentially related work creation:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_record_aux_stack+0xc0/0xf0 mm/kasan/generic.c:343
 __call_rcu kernel/rcu/tree.c:2965 [inline]
 call_rcu+0xbb/0x700 kernel/rcu/tree.c:3038
 netlink_release+0xd43/0x1cf0 net/netlink/af_netlink.c:802
 __sock_release+0xcd/0x280 net/socket.c:597
 sock_close+0x18/0x20 net/socket.c:1256
 __fput+0x285/0x920 fs/file_table.c:281
 task_work_run+0xdd/0x190 kernel/task_work.c:168
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:174 [inline]
 exit_to_user_mode_prepare+0x1f0/0x200 kernel/entry/common.c:201
 __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
 syscall_exit_to_user_mode+0x19/0x50 kernel/entry/common.c:302
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Second to last potentially related work creation:
 kasan_save_stack+0x1b/0x40 mm/kasan/common.c:48
 kasan_record_aux_stack+0xc0/0xf0 mm/kasan/generic.c:343
 insert_work+0x48/0x370 kernel/workqueue.c:1331
 __queue_work+0x5c1/0xf00 kernel/workqueue.c:1497
 queue_work_on+0xc7/0xd0 kernel/workqueue.c:1524
 queue_work include/linux/workqueue.h:507 [inline]
 schedule_work include/linux/workqueue.h:568 [inline]
 deferred_put_nlk_sk net/netlink/af_netlink.c:726 [inline]
 deferred_put_nlk_sk+0x251/0x2e0 net/netlink/af_netlink.c:713
 rcu_do_batch kernel/rcu/tree.c:2489 [inline]
 rcu_core+0x5eb/0xf00 kernel/rcu/tree.c:2723
 __do_softirq+0x2a0/0x9f6 kernel/softirq.c:298

The buggy address belongs to the object at ffff888026985000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1924 bytes to the right of
 2048-byte region [ffff888026985000, ffff888026985800)
The buggy address belongs to the page:
page:00000000db6aa34f refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x26980
head:00000000db6aa34f order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head)
raw: 00fff00000010200 ffffea0001854a00 0000000300000003 ffff888010042000
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888026985e80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888026985f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888026985f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
                   ^
 ffff888026986000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff888026986080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/12/17 08:12 net-next-old 3db1a3fa9880 04201c06 .config console log report info ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.