syzbot


KASAN: slab-use-after-free Read in ptp_read

Status: auto-obsoleted due to no activity on 2024/01/19 06:50
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+9704e6f099d952508943@syzkaller.appspotmail.com
First crash: 468d, last: 445d
Cause bisection: introduced by (bisect log) :
commit 8f5de6fb245326704f37d91780b9a10253a8a100
Author: Xabier Marquiegui <reibax@gmail.com>
Date: Wed Oct 11 22:39:55 2023 +0000

  ptp: support multiple timestamp event readers

Crash: KASAN: slab-use-after-free Read in ptp_read (log)
Repro: C syz .config
  
Fix bisection: fixed by (bisect log) :
commit b714ca2ccf6a90733f6ceb14abb6ce914f8832c3
Author: Edward Adam Davis <eadavis@qq.com>
Date: Tue Nov 7 08:00:40 2023 +0000

  ptp: ptp_read should not release queue

  
Discussions (2)
Title Replies (including bot) Last reply
[syzbot] [net?] KASAN: slab-use-after-free Read in ptp_read 0 (2) 2023/12/10 21:38
[PATCH] ptp: ptp_read should not release queue 7 (7) 2023/10/24 01:49
Last patch testing requests (8)
Created Duration User Patch Repo Result
2023/11/24 12:49 20m retest repro upstream OK log
2023/11/24 11:00 20m retest repro linux-next OK log
2023/11/24 07:30 35m retest repro upstream OK log
2023/11/24 07:30 30m retest repro upstream OK log
2023/11/24 06:56 16m retest repro upstream OK log
2023/11/24 06:56 16m retest repro upstream OK log
2023/11/24 06:56 17m retest repro upstream OK log
2023/10/23 01:19 26m eadavis@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 2dac75696c6d OK log

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in queue_cnt drivers/ptp/ptp_private.h:89 [inline]
BUG: KASAN: slab-use-after-free in ptp_read+0x5e4/0x820 drivers/ptp/ptp_chardev.c:547
Read of size 4 at addr ffff88805e735004 by task syz-executor136/5058

CPU: 1 PID: 5058 Comm: syz-executor136 Not tainted 6.6.0-syzkaller-15601-g4bbdb725a36b #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/09/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e7/0x2d0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:364 [inline]
 print_report+0x163/0x540 mm/kasan/report.c:475
 kasan_report+0x142/0x170 mm/kasan/report.c:588
 queue_cnt drivers/ptp/ptp_private.h:89 [inline]
 ptp_read+0x5e4/0x820 drivers/ptp/ptp_chardev.c:547
 posix_clock_read+0x12f/0x190 kernel/time/posix-clock.c:51
 vfs_read+0x289/0xb00 fs/read_write.c:468
 ksys_read+0x1a0/0x2c0 fs/read_write.c:613
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82
 entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7fc9c4770c39
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fc9c4733238 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007fc9c47fa308 RCX: 00007fc9c4770c39
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007fc9c47fa300 R08: 00007fc9c47336c0 R09: 00007fc9c47336c0
R10: 00007fc9c47336c0 R11: 0000000000000246 R12: 7074702f7665642f
R13: 0000000000000000 R14: 00007ffc9e9b9ff0 R15: 00007ffc9e9ba0d8
 </TASK>

Allocated by task 5058:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4f/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:600 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 ptp_open+0xd9/0x430 drivers/ptp/ptp_chardev.c:112
 posix_clock_open+0x155/0x1f0 kernel/time/posix-clock.c:134
 chrdev_open+0x5ab/0x630 fs/char_dev.c:414
 do_dentry_open+0x8fd/0x1590 fs/open.c:948
 do_open fs/namei.c:3622 [inline]
 path_openat+0x2845/0x3280 fs/namei.c:3779
 do_filp_open+0x234/0x490 fs/namei.c:3809
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1440
 do_sys_open fs/open.c:1455 [inline]
 __do_sys_openat fs/open.c:1471 [inline]
 __se_sys_openat fs/open.c:1466 [inline]
 __x64_sys_openat+0x247/0x290 fs/open.c:1466
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Freed by task 5059:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4f/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x28/0x40 mm/kasan/generic.c:522
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:164 [inline]
 slab_free_hook mm/slub.c:1800 [inline]
 slab_free_freelist_hook mm/slub.c:1826 [inline]
 slab_free mm/slub.c:3809 [inline]
 __kmem_cache_free+0x263/0x3a0 mm/slub.c:3822
 ptp_release+0x1ce/0x1e0 drivers/ptp/ptp_chardev.c:150
 ptp_read+0x17f/0x820 drivers/ptp/ptp_chardev.c:589
 posix_clock_read+0x12f/0x190 kernel/time/posix-clock.c:51
 vfs_read+0x289/0xb00 fs/read_write.c:468
 ksys_read+0x1a0/0x2c0 fs/read_write.c:613
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

The buggy address belongs to the object at ffff88805e734000
 which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 4100 bytes inside of
 freed 8192-byte region [ffff88805e734000, ffff88805e736000)

The buggy address belongs to the physical page:
page:ffffea000179cc00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5e730
head:ffffea000179cc00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
anon flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888012c42280 0000000000000000 dead000000000001
raw: 0000000000000000 0000000080020002 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4707, tgid 4707 (S30dbus), ts 30110856861, free_ts 30085131088
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1537
 prep_new_page mm/page_alloc.c:1544 [inline]
 get_page_from_freelist+0x339a/0x3530 mm/page_alloc.c:3312
 __alloc_pages+0x255/0x670 mm/page_alloc.c:4568
 alloc_pages_mpol+0x3de/0x640 mm/mempolicy.c:2133
 alloc_slab_page+0x6a/0x160 mm/slub.c:1870
 allocate_slab mm/slub.c:2017 [inline]
 new_slab+0x84/0x2f0 mm/slub.c:2070
 ___slab_alloc+0xc85/0x1310 mm/slub.c:3223
 __slab_alloc mm/slub.c:3322 [inline]
 __slab_alloc_node mm/slub.c:3375 [inline]
 slab_alloc_node mm/slub.c:3468 [inline]
 __kmem_cache_alloc_node+0x21d/0x300 mm/slub.c:3517
 kmalloc_trace+0x2a/0xe0 mm/slab_common.c:1098
 kmalloc include/linux/slab.h:600 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 tomoyo_print_bprm security/tomoyo/audit.c:26 [inline]
 tomoyo_init_log+0x11cd/0x2040 security/tomoyo/audit.c:264
 tomoyo_supervisor+0x386/0x11f0 security/tomoyo/common.c:2089
 tomoyo_audit_env_log security/tomoyo/environ.c:36 [inline]
 tomoyo_env_perm+0x178/0x210 security/tomoyo/environ.c:63
 tomoyo_environ security/tomoyo/domain.c:672 [inline]
 tomoyo_find_next_domain+0x1383/0x1cf0 security/tomoyo/domain.c:878
 tomoyo_bprm_check_security+0x114/0x170 security/tomoyo/tomoyo.c:101
 security_bprm_check+0x63/0xa0 security/security.c:1103
 search_binary_handler fs/exec.c:1725 [inline]
 exec_binprm fs/exec.c:1779 [inline]
 bprm_execve+0x95f/0x18a0 fs/exec.c:1854
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1137 [inline]
 free_unref_page_prepare+0x92a/0xa50 mm/page_alloc.c:2347
 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2487
 discard_slab mm/slub.c:2116 [inline]
 __unfreeze_partials+0x1dc/0x220 mm/slub.c:2655
 put_cpu_partial+0x17b/0x250 mm/slub.c:2731
 __slab_free+0x2b6/0x390 mm/slub.c:3679
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x75/0xe0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x14b/0x160 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x23/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:188 [inline]
 slab_post_alloc_hook+0x6c/0x3c0 mm/slab.h:763
 slab_alloc_node mm/slub.c:3478 [inline]
 slab_alloc mm/slub.c:3486 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3493 [inline]
 kmem_cache_alloc+0x1be/0x350 mm/slub.c:3502
 getname_flags+0xbc/0x4f0 fs/namei.c:140
 vfs_fstatat+0x11c/0x190 fs/stat.c:294
 __do_sys_newfstatat fs/stat.c:459 [inline]
 __se_sys_newfstatat fs/stat.c:453 [inline]
 __x64_sys_newfstatat+0x117/0x190 fs/stat.c:453
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x44/0x110 arch/x86/entry/common.c:82
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Memory state around the buggy address:
 ffff88805e734f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805e734f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805e735000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88805e735080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805e735100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (50):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/11/10 06:00 upstream 4bbdb725a36b 56230772 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/07 17:01 upstream be3ca57cfb77 83211397 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/06 17:36 upstream d2f51b3516da 78fae24e .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in ptp_read
2023/11/05 11:49 upstream aea6bf908d73 500bfdc4 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in ptp_read
2023/11/02 01:41 upstream 8bc9e6515183 69904c9f .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in ptp_read
2023/11/01 09:09 upstream 89ed67ef126c 69904c9f .config strace log report syz C [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/10/18 18:26 linux-next 2dac75696c6d 342b9c55 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/11/10 03:54 upstream 4bbdb725a36b 56230772 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/11/09 12:33 upstream 6bc986ab839c 4862372a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/09 10:51 upstream 6bc986ab839c 4862372a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/09 08:18 upstream 6bc986ab839c 4862372a .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/08 21:32 upstream 305230142ae0 df3908d6 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/11/08 14:38 upstream 305230142ae0 83211397 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/11/07 22:18 upstream 13d88ac54ddd 83211397 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/07 17:47 upstream be3ca57cfb77 83211397 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/07 16:36 upstream be3ca57cfb77 83211397 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/07 14:43 upstream be3ca57cfb77 83211397 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/07 08:02 upstream be3ca57cfb77 83211397 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/07 00:39 upstream d2f51b3516da 78fae24e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/11/06 19:51 upstream d2f51b3516da 78fae24e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/06 18:39 upstream d2f51b3516da 78fae24e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/06 15:48 upstream d2f51b3516da 78fae24e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/06 14:56 upstream d2f51b3516da 78fae24e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/06 09:53 upstream 77fa2fbe87fc 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in ptp_read
2023/11/06 01:50 upstream 1c41041124bd 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/05 22:42 upstream 1c41041124bd 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/05 18:39 upstream 1c41041124bd 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/05 06:41 upstream aea6bf908d73 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/11/04 22:05 upstream 90b0c2b2edd1 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in ptp_read
2023/11/04 21:05 upstream 90b0c2b2edd1 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/04 20:14 upstream 90b0c2b2edd1 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/04 06:56 upstream 6bdfe2d88b9f 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/03 17:07 upstream 8f6f76a6a29f c4ac074c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/03 12:47 upstream 8f6f76a6a29f c4ac074c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/03 07:13 upstream 4652b8e4f3ff c4ac074c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/03 02:06 upstream 4652b8e4f3ff c4ac074c .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/02 03:32 upstream 8bc9e6515183 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/02 01:58 upstream 8bc9e6515183 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in ptp_read
2023/11/02 01:18 upstream 8bc9e6515183 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in ptp_read
2023/11/02 01:04 upstream 8bc9e6515183 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/11/01 12:15 upstream 89ed67ef126c 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/01 11:38 upstream 89ed67ef126c 69904c9f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce KASAN: slab-use-after-free Read in ptp_read
2023/11/01 02:49 upstream 89ed67ef126c 58499c95 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in ptp_read
2023/11/09 05:46 upstream 34f763262743 4862372a .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in ptp_read
2023/11/06 20:53 upstream d2f51b3516da 78fae24e .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-use-after-free Read in ptp_read
2023/11/05 18:26 linux-next e27090b1413f 500bfdc4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/11/03 17:53 linux-next e27090b1413f c4ac074c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
2023/10/23 02:18 linux-next 2030579113a1 361b23dc .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in ptp_read
* Struck through repros no longer work on HEAD.