syzbot


KASAN: use-after-free Read in kill_fasync

Status: upstream: reported C repro on 2022/07/11 06:41
Reported-by: syzbot+382c8824777dca2812fe@syzkaller.appspotmail.com
First crash: 143d, last: 97d

Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: KASAN: use-after-free Read in kill_fasync (log)
Repro: C syz .config

Fix bisection: failed (bisect log)
Patch testing requests:
Created Duration User Patch Repo Result
2022/07/12 10:52 18m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git cb71b93c2dc3 OK log
2022/07/11 11:11 10m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git cb71b93c2dc3 report log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in kill_fasync+0x45e/0x470 fs/fcntl.c:1014
Read of size 8 at addr ffff88807abbe968 by task syz-executor339/3606

CPU: 1 PID: 3606 Comm: syz-executor339 Not tainted 5.19.0-rc6-syzkaller-00418-g972a278fe60c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313
 print_report mm/kasan/report.c:429 [inline]
 kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491
 kill_fasync+0x45e/0x470 fs/fcntl.c:1014
 post_one_notification.isra.0+0x6e4/0x990 kernel/watch_queue.c:128
 __post_watch_notification kernel/watch_queue.c:206 [inline]
 __post_watch_notification+0x561/0x840 kernel/watch_queue.c:176
 post_watch_notification include/linux/watch_queue.h:109 [inline]
 notify_key security/keys/internal.h:199 [inline]
 __key_update security/keys/key.c:775 [inline]
 key_create_or_update+0xdbf/0xde0 security/keys/key.c:979
 __do_sys_add_key+0x215/0x430 security/keys/keyctl.c:134
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fb1a43aaf49
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 b1 14 00 00 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 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffc4dcbdb48 EFLAGS: 00000246 ORIG_RAX: 00000000000000f8
RAX: ffffffffffffffda RBX: 00000000000f4240 RCX: 00007fb1a43aaf49
RDX: 0000000020000280 RSI: 0000000020000100 RDI: 00000000200000c0
RBP: 0000000000000000 R08: 00000000fffffffc R09: 0000000000000001
R10: 0000000000000048 R11: 0000000000000246 R12: 00007fb1a436e720
R13: 0000000000000000 R14: 00007ffc4dcbdb70 R15: 00007ffc4dcbdb60
 </TASK>

Allocated by task 3600:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:436 [inline]
 ____kasan_kmalloc mm/kasan/common.c:515 [inline]
 ____kasan_kmalloc mm/kasan/common.c:474 [inline]
 __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524
 kmalloc include/linux/slab.h:600 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 alloc_pipe_info+0x105/0x590 fs/pipe.c:790
 get_pipe_inode fs/pipe.c:881 [inline]
 create_pipe_files+0x8d/0x880 fs/pipe.c:913
 __do_pipe_flags fs/pipe.c:962 [inline]
 do_pipe2+0x96/0x1b0 fs/pipe.c:1010
 __do_sys_pipe2 fs/pipe.c:1028 [inline]
 __se_sys_pipe2 fs/pipe.c:1026 [inline]
 __x64_sys_pipe2+0x50/0x70 fs/pipe.c:1026
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 3600:
 kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38
 kasan_set_track+0x21/0x30 mm/kasan/common.c:45
 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370
 ____kasan_slab_free mm/kasan/common.c:366 [inline]
 ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328
 kasan_slab_free include/linux/kasan.h:200 [inline]
 slab_free_hook mm/slub.c:1754 [inline]
 slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1780
 slab_free mm/slub.c:3536 [inline]
 kfree+0xd6/0x4d0 mm/slub.c:4584
 put_pipe_info fs/pipe.c:711 [inline]
 pipe_release+0x2b6/0x310 fs/pipe.c:734
 __fput+0x277/0x9d0 fs/file_table.c:317
 task_work_run+0xdd/0x1a0 kernel/task_work.c:177
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0xade/0x29d0 kernel/exit.c:795
 do_group_exit+0xd2/0x2f0 kernel/exit.c:925
 __do_sys_exit_group kernel/exit.c:936 [inline]
 __se_sys_exit_group kernel/exit.c:934 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:934
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88807abbe800
 which belongs to the cache kmalloc-cg-512 of size 512
The buggy address is located 360 bytes inside of
 512-byte region [ffff88807abbe800, ffff88807abbea00)

The buggy address belongs to the physical page:
page:ffffea0001eaef00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7abbc
head:ffffea0001eaef00 order:2 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888011842dc0
raw: 0000000000000000 0000000080100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3185, tgid 3185 (dhcpcd), ts 21830558237, free_ts 18232364269
 prep_new_page mm/page_alloc.c:2456 [inline]
 get_page_from_freelist+0x1290/0x3b70 mm/page_alloc.c:4198
 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5426
 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272
 alloc_slab_page mm/slub.c:1824 [inline]
 allocate_slab+0x26c/0x3c0 mm/slub.c:1969
 new_slab mm/slub.c:2029 [inline]
 ___slab_alloc+0x9c4/0xe20 mm/slub.c:3031
 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3118
 slab_alloc_node mm/slub.c:3209 [inline]
 __kmalloc_node_track_caller+0x2cb/0x360 mm/slub.c:4979
 kmalloc_reserve net/core/skbuff.c:354 [inline]
 __alloc_skb+0xde/0x340 net/core/skbuff.c:426
 alloc_skb include/linux/skbuff.h:1426 [inline]
 alloc_skb_with_frags+0x93/0x730 net/core/skbuff.c:5992
 sock_alloc_send_pskb+0x793/0x920 net/core/sock.c:2662
 unix_dgram_sendmsg+0x425/0x1ad0 net/unix/af_unix.c:1895
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:734
 sock_write_iter+0x284/0x3c0 net/socket.c:1108
 call_write_iter include/linux/fs.h:2058 [inline]
 do_iter_readv_writev+0x3d1/0x640 fs/read_write.c:742
 do_iter_write+0x182/0x700 fs/read_write.c:868
 vfs_writev+0x1aa/0x630 fs/read_write.c:941
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1371 [inline]
 free_pcp_prepare+0x549/0xd20 mm/page_alloc.c:1421
 free_unref_page_prepare mm/page_alloc.c:3343 [inline]
 free_unref_page+0x19/0x6a0 mm/page_alloc.c:3438
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:446
 kasan_slab_alloc include/linux/kasan.h:224 [inline]
 slab_post_alloc_hook mm/slab.h:750 [inline]
 slab_alloc_node mm/slub.c:3243 [inline]
 slab_alloc mm/slub.c:3251 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3258 [inline]
 kmem_cache_alloc+0x204/0x3b0 mm/slub.c:3268
 getname_flags.part.0+0x50/0x4f0 fs/namei.c:139
 getname_flags+0x9a/0xe0 include/linux/audit.h:323
 vfs_fstatat+0x73/0xb0 fs/stat.c:254
 __do_sys_newfstatat+0x91/0x110 fs/stat.c:425
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
 ffff88807abbe800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807abbe880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807abbe900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                          ^
 ffff88807abbe980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807abbea00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (40):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-root 2022/07/17 15:27 upstream 972a278fe60c 95cb00d1 .config log report syz C KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce 2022/07/08 07:21 upstream e8a4e1c1bb69 bff65f44 .config log report syz C KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-smack-root 2022/07/08 06:53 upstream e8a4e1c1bb69 bff65f44 .config log report syz C KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce 2022/07/08 06:51 upstream e8a4e1c1bb69 bff65f44 .config log report syz C KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce 2022/07/08 06:29 upstream e8a4e1c1bb69 bff65f44 .config log report syz C KASAN: use-after-free Read in kill_fasync
ci-upstream-linux-next-kasan-gce-root 2022/07/08 06:08 linux-next cb71b93c2dc3 bff65f44 .config log report syz C KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/20 00:39 upstream ca85855bdcae 775344bc .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/19 17:22 upstream ca85855bdcae 72a3cc0c .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/19 05:46 upstream ca85855bdcae ff988920 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/18 17:43 upstream ff6992735ade ff988920 .config log report info KASAN: use-after-free Read in kill_fasync
ci-qemu-upstream 2022/07/18 13:56 upstream 4a57a8400075 ff988920 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-root 2022/07/17 10:37 upstream 972a278fe60c 95cb00d1 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/16 23:14 upstream c658cabbfd32 95cb00d1 .config log report info KASAN: use-after-free Read in kill_fasync
ci-qemu-upstream 2022/07/15 21:03 upstream 4a57a8400075 95cb00d1 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/15 13:06 upstream e5d523f1ae8f 5d921b08 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce 2022/07/14 00:29 upstream 4a57a8400075 5d921b08 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/13 21:55 upstream 4a57a8400075 5d921b08 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce 2022/07/13 20:55 upstream 4a57a8400075 5d921b08 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/13 10:19 upstream b047602d579b 5d921b08 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-root 2022/07/13 10:11 upstream b047602d579b 5d921b08 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-smack-root 2022/07/13 09:46 upstream b047602d579b 5d921b08 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-root 2022/07/12 19:13 upstream 72a8e05d4f66 d91dd8ea .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce 2022/07/12 17:53 upstream 72a8e05d4f66 d91dd8ea .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/12 16:58 upstream 72a8e05d4f66 d91dd8ea .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-root 2022/07/12 14:43 upstream 5a29232d870d d91dd8ea .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce 2022/07/12 03:19 upstream 5a29232d870d da3d6955 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-smack-root 2022/07/11 14:03 upstream 32346491ddf2 da3d6955 .config log report info KASAN: use-after-free Read in kill_fasync
ci-qemu-upstream 2022/07/11 12:34 upstream 32346491ddf2 f3f217ff .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/11 12:15 upstream 32346491ddf2 da3d6955 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-smack-root 2022/07/11 10:52 upstream 32346491ddf2 da3d6955 .config log report info KASAN: use-after-free Read in kill_fasync
ci-qemu-upstream 2022/07/11 09:25 upstream 32346491ddf2 b5765a15 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/10 23:21 upstream d9919d43cbf6 b5765a15 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-selinux-root 2022/07/10 03:13 upstream b1c428b6c368 b5765a15 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-smack-root 2022/07/10 03:10 upstream b1c428b6c368 b5765a15 .config log report info KASAN: use-after-free Read in kill_fasync
ci-qemu-upstream 2022/07/10 02:39 upstream b1c428b6c368 b5765a15 .config log report info KASAN: use-after-free Read in kill_fasync
ci-qemu-upstream 2022/07/09 09:58 upstream e5524c2a1fc4 b5765a15 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-root 2022/07/09 08:34 upstream e5524c2a1fc4 b5765a15 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce 2022/07/08 06:02 upstream e8a4e1c1bb69 bff65f44 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-kasan-gce-smack-root 2022/07/08 05:45 upstream e8a4e1c1bb69 bff65f44 .config log report info KASAN: use-after-free Read in kill_fasync
ci-upstream-linux-next-kasan-gce-root 2022/07/08 05:49 linux-next cb71b93c2dc3 bff65f44 .config log report info KASAN: use-after-free Read in kill_fasync
* Struck through repros no longer work on HEAD.