[v5.15] KASAN: use-after-free Read in devlink_notify

0 views
Skip to first unread message

syzbot

unread,
Feb 3, 2024, 9:17:36 PMFeb 3
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6139f2a02fe0 Linux 5.15.148
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1340668fe80000
kernel config: https://syzkaller.appspot.com/x/.config?x=c170eb20d8be8542
dashboard link: https://syzkaller.appspot.com/bug?extid=39a0f9ccae0719b58cb1
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/528e8fe56997/disk-6139f2a0.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/18abf1e442f9/vmlinux-6139f2a0.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0538a5d3b1f3/bzImage-6139f2a0.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+39a0f9...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in genlmsg_multicast_netns include/net/genetlink.h:314 [inline]
BUG: KASAN: use-after-free in devlink_notify+0xeb/0x150 net/core/devlink.c:756
Read of size 8 at addr ffff888079399c18 by task syz-executor.3/5031

CPU: 0 PID: 5031 Comm: syz-executor.3 Not tainted 5.15.148-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description+0x63/0x3b0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
genlmsg_multicast_netns include/net/genetlink.h:314 [inline]
devlink_notify+0xeb/0x150 net/core/devlink.c:756
devlink_unregister+0x13e/0x1d0 net/core/devlink.c:8987
nsim_dev_remove+0xdf/0x100 drivers/net/netdevsim/dev.c:1583
__device_release_driver drivers/base/dd.c:1227 [inline]
device_release_driver_internal+0x4cb/0x7f0 drivers/base/dd.c:1262
bus_remove_device+0x2e5/0x400 drivers/base/bus.c:529
device_del+0x6e2/0xbd0 drivers/base/core.c:3582
device_unregister+0x1c/0xc0 drivers/base/core.c:3615
nsim_bus_dev_del drivers/net/netdevsim/bus.c:454 [inline]
del_device_store+0x321/0x470 drivers/net/netdevsim/bus.c:354
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
call_write_iter include/linux/fs.h:2146 [inline]
new_sync_write fs/read_write.c:507 [inline]
vfs_write+0xacf/0xe50 fs/read_write.c:594
ksys_write+0x1a2/0x2c0 fs/read_write.c:647
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f8024a56aef
Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 b9 80 02 00 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 0c 81 02 00 48
RSP: 002b:00007ffc8c1f5ce0 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007f8024a56aef
RDX: 0000000000000001 RSI: 00007ffc8c1f5d30 RDI: 0000000000000005
RBP: 00007f8024aa4021 R08: 0000000000000000 R09: 00007ffc8c1f5b37
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000001
R13: 00007ffc8c1f5d30 R14: 00007f80256ae620 R15: 0000000000000003
</TASK>

Allocated by task 3525:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track mm/kasan/common.c:46 [inline]
set_alloc_info mm/kasan/common.c:434 [inline]
__kasan_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
net_alloc net/core/net_namespace.c:405 [inline]
copy_net_ns+0x143/0x5d0 net/core/net_namespace.c:460
create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
ksys_unshare+0x580/0xb20 kernel/fork.c:3101
__do_sys_unshare kernel/fork.c:3175 [inline]
__se_sys_unshare kernel/fork.c:3173 [inline]
__x64_sys_unshare+0x34/0x40 kernel/fork.c:3173
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 4295:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
net_free net/core/net_namespace.c:434 [inline]
cleanup_net+0xab5/0xb60 net/core/net_namespace.c:617
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff888079399a40
which belongs to the cache net_namespace of size 6464
The buggy address is located 472 bytes inside of
6464-byte region [ffff888079399a40, ffff88807939b380)
The buggy address belongs to the page:
page:ffffea0001e4e600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x79398
head:ffffea0001e4e600 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff888073864741
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888011de33c0
raw: 0000000000000000 0000000000040004 00000001ffffffff ffff888073864741
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3518, ts 63063217612, free_ts 63031653266
prep_new_page mm/page_alloc.c:2426 [inline]
get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
__alloc_pages+0x272/0x700 mm/page_alloc.c:5421
alloc_slab_page mm/slub.c:1775 [inline]
allocate_slab mm/slub.c:1912 [inline]
new_slab+0xbb/0x4b0 mm/slub.c:1975
___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
__slab_alloc mm/slub.c:3095 [inline]
slab_alloc_node mm/slub.c:3186 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc+0x18e/0x280 mm/slub.c:3233
kmem_cache_zalloc include/linux/slab.h:711 [inline]
net_alloc net/core/net_namespace.c:405 [inline]
copy_net_ns+0x143/0x5d0 net/core/net_namespace.c:460
create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
ksys_unshare+0x580/0xb20 kernel/fork.c:3101
__do_sys_unshare kernel/fork.c:3175 [inline]
__se_sys_unshare kernel/fork.c:3173 [inline]
__x64_sys_unshare+0x34/0x40 kernel/fork.c:3173
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1340 [inline]
free_pcp_prepare mm/page_alloc.c:1391 [inline]
free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
free_slab mm/slub.c:2015 [inline]
discard_slab mm/slub.c:2021 [inline]
__unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
do_slab_free mm/slub.c:3487 [inline]
___cache_free+0xe3/0x100 mm/slub.c:3506
qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
__kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
kasan_slab_alloc include/linux/kasan.h:254 [inline]
slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
slab_alloc_node mm/slub.c:3220 [inline]
slab_alloc mm/slub.c:3228 [inline]
kmem_cache_alloc_trace+0xfb/0x290 mm/slub.c:3245
kmalloc include/linux/slab.h:591 [inline]
tomoyo_print_header security/tomoyo/audit.c:156 [inline]
tomoyo_init_log+0x1bf/0x1fe0 security/tomoyo/audit.c:255
tomoyo_supervisor+0x3b8/0x12c0 security/tomoyo/common.c:2097
tomoyo_audit_path_log security/tomoyo/file.c:168 [inline]
tomoyo_path_permission+0x243/0x360 security/tomoyo/file.c:587
tomoyo_check_open_permission+0x350/0x490 security/tomoyo/file.c:780
security_file_open+0x5f/0xa0 security/security.c:1650
do_dentry_open+0x315/0xfb0 fs/open.c:813

Memory state around the buggy address:
ffff888079399b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888079399b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888079399c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888079399c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888079399d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages