syzbot


KASAN: stack-out-of-bounds Read in fanotify_read

Status: moderation: reported on 2025/03/15 04:08
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+fde15d7f37da7ab330e2@syzkaller.appspotmail.com
First crash: 4d07h, last: 4d07h

Sample crash report:
==================================================================
BUG: KASAN: stack-out-of-bounds in copy_range_info_to_user fs/notify/fanotify/fanotify_user.c:564 [inline]
BUG: KASAN: stack-out-of-bounds in copy_info_records_to_user fs/notify/fanotify/fanotify_user.c:695 [inline]
BUG: KASAN: stack-out-of-bounds in copy_event_to_user fs/notify/fanotify/fanotify_user.c:817 [inline]
BUG: KASAN: stack-out-of-bounds in fanotify_read+0x1ff0/0x2e90 fs/notify/fanotify/fanotify_user.c:905
Read of size 8 at addr ffffc9000d3b7b28 by task syz.0.0/5334

CPU: 0 UID: 0 PID: 5334 Comm: syz.0.0 Not tainted 6.14.0-rc6-syzkaller-00003-g4d872d51bc9d #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:408 [inline]
 print_report+0x16e/0x5b0 mm/kasan/report.c:521
 kasan_report+0x143/0x180 mm/kasan/report.c:634
 copy_range_info_to_user fs/notify/fanotify/fanotify_user.c:564 [inline]
 copy_info_records_to_user fs/notify/fanotify/fanotify_user.c:695 [inline]
 copy_event_to_user fs/notify/fanotify/fanotify_user.c:817 [inline]
 fanotify_read+0x1ff0/0x2e90 fs/notify/fanotify/fanotify_user.c:905
 do_loop_readv_writev fs/read_write.c:840 [inline]
 vfs_readv+0x6bc/0xa80 fs/read_write.c:1013
 do_readv+0x1b6/0x360 fs/read_write.c:1073
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fc578d8d169
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fc579bd0038 EFLAGS: 00000246 ORIG_RAX: 0000000000000013
RAX: ffffffffffffffda RBX: 00007fc578fa6160 RCX: 00007fc578d8d169
RDX: 0000000000000001 RSI: 0000400000000700 RDI: 000000000000000b
RBP: 00007fc578e0e2a0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000001 R14: 00007fc578fa6160 R15: 00007fffb7eff728
 </TASK>

The buggy address belongs to the virtual mapping at
 [ffffc9000d3b0000, ffffc9000d3b9000) created by:
 copy_process+0x5d1/0x3cf0 kernel/fork.c:2233

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880409b7c00 pfn:0x409b6
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
raw: 04fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: ffff8880409b7c00 0000000000000000 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x2dc2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_NOWARN|__GFP_ZERO), pid 5323, tgid 5323 (syz.0.0), ts 66694185572, free_ts 66569402610
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f4/0x240 mm/page_alloc.c:1551
 prep_new_page mm/page_alloc.c:1559 [inline]
 get_page_from_freelist+0x365c/0x37a0 mm/page_alloc.c:3477
 __alloc_frozen_pages_noprof+0x292/0x710 mm/page_alloc.c:4740
 alloc_pages_mpol+0x311/0x660 mm/mempolicy.c:2270
 alloc_frozen_pages_noprof mm/mempolicy.c:2341 [inline]
 alloc_pages_noprof+0x121/0x190 mm/mempolicy.c:2361
 vm_area_alloc_pages mm/vmalloc.c:3591 [inline]
 __vmalloc_area_node mm/vmalloc.c:3669 [inline]
 __vmalloc_node_range_noprof+0x9c6/0x1380 mm/vmalloc.c:3846
 alloc_thread_stack_node kernel/fork.c:314 [inline]
 dup_task_struct+0x444/0x8c0 kernel/fork.c:1127
 copy_process+0x5d1/0x3cf0 kernel/fork.c:2233
 kernel_clone+0x226/0x8e0 kernel/fork.c:2815
 __do_sys_clone3 kernel/fork.c:3119 [inline]
 __se_sys_clone3+0x2ee/0x380 kernel/fork.c:3098
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
page last free pid 5307 tgid 5307 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_frozen_pages+0xe0d/0x10e0 mm/page_alloc.c:2660
 discard_slab mm/slub.c:2684 [inline]
 __put_partials+0x160/0x1c0 mm/slub.c:3153
 put_cpu_partial+0x17c/0x250 mm/slub.c:3228
 __slab_free+0x290/0x380 mm/slub.c:4479
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329
 kasan_slab_alloc include/linux/kasan.h:250 [inline]
 slab_post_alloc_hook mm/slub.c:4115 [inline]
 slab_alloc_node mm/slub.c:4164 [inline]
 kmem_cache_alloc_node_noprof+0x1d9/0x380 mm/slub.c:4216
 __alloc_skb+0x1c3/0x440 net/core/skbuff.c:596
 alloc_skb include/linux/skbuff.h:1331 [inline]
 nlmsg_new include/net/netlink.h:1018 [inline]
 netlink_ack+0x145/0xa60 net/netlink/af_netlink.c:2470
 netlink_rcv_skb+0x294/0x480 net/netlink/af_netlink.c:2539
 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219
 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline]
 netlink_unicast+0x7f6/0x990 net/netlink/af_netlink.c:1338
 netlink_sendmsg+0x8de/0xcb0 net/netlink/af_netlink.c:1882
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg+0x221/0x270 net/socket.c:733
 __sys_sendto+0x363/0x4c0 net/socket.c:2187

Memory state around the buggy address:
 ffffc9000d3b7a00: f3 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
 ffffc9000d3b7a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffc9000d3b7b00: 00 00 00 00 f1 f1 f1 f1 00 00 f2 f2 00 00 f2 f2
                                  ^
 ffffc9000d3b7b80: 00 f3 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
 ffffc9000d3b7c00: 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
2025/03/11 03:57 upstream 4d872d51bc9d 16256247 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: stack-out-of-bounds Read in fanotify_read
* Struck through repros no longer work on HEAD.