syzbot


KASAN: use-after-free Read in hugetlb_fault

Status: fixed on 2023/02/24 13:50
Subsystems: mm
[Documentation on labels]
Reported-by: syzbot+1b27d7a2722eabc2c5d5@syzkaller.appspotmail.com
Fix commit: 04ada095dcfc hugetlb: don't delete vma_lock in hugetlb MADV_DONTNEED processing
First crash: 584d, last: 484d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] KASAN: use-after-free Read in hugetlb_fault 3 (5) 2022/10/24 20:34
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in hugetlb_fault mm C done 6 14d 37d 0/26 upstream: reported C repro on 2024/04/17 22:30

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:72 [inline]
BUG: KASAN: use-after-free in atomic_long_read include/linux/atomic/atomic-instrumented.h:1265 [inline]
BUG: KASAN: use-after-free in is_rwsem_reader_owned kernel/locking/rwsem.c:193 [inline]
BUG: KASAN: use-after-free in __down_read_common+0xa2/0x2a0 kernel/locking/rwsem.c:1262
Read of size 8 at addr ffff88801803e908 by task syz-executor407/3986

CPU: 0 PID: 3986 Comm: syz-executor407 Not tainted 6.1.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x74/0x340 mm/kasan/report.c:284
 print_report+0x107/0x220 mm/kasan/report.c:395
 kasan_report+0x139/0x170 mm/kasan/report.c:495
 kasan_check_range+0x2a7/0x2e0 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:72 [inline]
 atomic_long_read include/linux/atomic/atomic-instrumented.h:1265 [inline]
 is_rwsem_reader_owned kernel/locking/rwsem.c:193 [inline]
 __down_read_common+0xa2/0x2a0 kernel/locking/rwsem.c:1262
 hugetlb_vma_lock_read mm/hugetlb.c:6822 [inline]
 hugetlb_fault+0x62b/0x1a20 mm/hugetlb.c:5861
 handle_mm_fault+0x2478/0x3660 mm/memory.c:5216
 do_user_addr_fault+0x69b/0xcb0 arch/x86/mm/fault.c:1428
 handle_page_fault arch/x86/mm/fault.c:1519 [inline]
 exc_page_fault+0x7a/0x120 arch/x86/mm/fault.c:1575
 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:570
RIP: 0033:0x7f9e51e605bf
Code: 31 c0 49 b8 31 c8 05 00 00 00 02 00 e8 fa 32 04 00 59 5e e9 63 ff ff ff 0f 1f 00 ba 75 00 00 00 45 31 c0 31 c9 bf 01 01 00 00 <4c> 89 24 25 00 00 00 20 48 c7 c6 9c ff ff ff 31 c0 66 89 14 25 08
RSP: 002b:00007f9e51e55320 EFLAGS: 00010246
RAX: 0000000000000002 RBX: 00007f9e51f2b3e8 RCX: 0000000000000000
RDX: 0000000000000075 RSI: 0000000000000081 RDI: 0000000000000101
RBP: 00007f9e51f2b3e0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 7363762f7665642f
R13: 00007ffcd43d78cf R14: 00007f9e51e55400 R15: 0000000000022000
 </TASK>

Allocated by task 3986:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:371 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:380
 kmalloc include/linux/slab.h:553 [inline]
 hugetlb_vma_lock_alloc mm/hugetlb.c:6932 [inline]
 hugetlb_reserve_pages+0x271/0x13e0 mm/hugetlb.c:6557
 hugetlbfs_file_mmap+0x43d/0x5c0 fs/hugetlbfs/inode.c:167
 call_mmap include/linux/fs.h:2204 [inline]
 mmap_region+0x1022/0x1e60 mm/mmap.c:2625
 do_mmap+0x8d9/0xf30 mm/mmap.c:1412
 vm_mmap_pgoff+0x1e5/0x2f0 mm/util.c:520
 ksys_mmap_pgoff+0x512/0x6d0 mm/mmap.c:1458
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Freed by task 3987:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:511
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook+0x12e/0x1a0 mm/slub.c:1750
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x71/0x110 mm/slub.c:3674
 hugetlb_vma_lock_release mm/hugetlb.c:6877 [inline]
 kref_put include/linux/kref.h:65 [inline]
 __hugetlb_vma_unlock_write_put mm/hugetlb.c:6892 [inline]
 __hugetlb_vma_unlock_write_free mm/hugetlb.c:6900 [inline]
 __unmap_hugepage_range_final+0x284/0x330 mm/hugetlb.c:5217
 zap_page_range+0x585/0x720 mm/memory.c:1762
 madvise_dontneed_single_vma mm/madvise.c:793 [inline]
 madvise_dontneed_free+0x4bc/0x1020 mm/madvise.c:886
 madvise_vma_behavior mm/madvise.c:1025 [inline]
 madvise_walk_vmas mm/madvise.c:1250 [inline]
 do_madvise+0x7d3/0x2000 mm/madvise.c:1429
 __do_sys_madvise mm/madvise.c:1442 [inline]
 __se_sys_madvise mm/madvise.c:1440 [inline]
 __x64_sys_madvise+0xa2/0xb0 mm/madvise.c:1440
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

The buggy address belongs to the object at ffff88801803e900
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 8 bytes inside of
 192-byte region [ffff88801803e900, ffff88801803e9c0)

The buggy address belongs to the physical page:
page:ffffea0000600f80 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1803e
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0000600a00 dead000000000002 ffff888012841a00
raw: 0000000000000000 0000000080100010 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 1, tgid 1 (swapper/0), ts 2295518295, free_ts 0
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x72b/0x7a0 mm/page_alloc.c:4291
 __alloc_pages+0x259/0x560 mm/page_alloc.c:5558
 alloc_page_interleave+0x22/0x1c0 mm/mempolicy.c:2118
 alloc_slab_page+0x70/0xf0 mm/slub.c:1794
 allocate_slab+0x5e/0x4b0 mm/slub.c:1939
 new_slab mm/slub.c:1992 [inline]
 ___slab_alloc+0x7f4/0xeb0 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x252/0x310 mm/slub.c:3437
 kmalloc_trace+0x26/0x60 mm/slab_common.c:1045
 kmalloc include/linux/slab.h:553 [inline]
 kzalloc include/linux/slab.h:689 [inline]
 call_usermodehelper_setup+0x8a/0x260 kernel/umh.c:366
 kobject_uevent_env+0x7c1/0x8e0 lib/kobject_uevent.c:614
 kernel_add_sysfs_param+0x106/0x126 kernel/params.c:816
 param_sysfs_builtin+0x16a/0x1e2 kernel/params.c:851
 param_sysfs_init+0x68/0x6c kernel/params.c:970
 do_one_initcall+0xbd/0x2b0 init/main.c:1303
 do_initcall_level+0x168/0x218 init/main.c:1376
 do_initcalls+0x4b/0x8c init/main.c:1392
page_owner free stack trace missing

Memory state around the buggy address:
 ffff88801803e800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88801803e880: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
>ffff88801803e900: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff88801803e980: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88801803ea00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (383):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/11/28 22:46 upstream b7b275e60bcd 247de55b .config strace log report syz C ci-upstream-kasan-gce-smack-root KASAN: use-after-free Read in hugetlb_fault
2022/11/16 08:41 upstream 81e7cfa3a9eb 3a127a31 .config console log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Read in hugetlb_fault
2022/11/02 00:53 upstream b229b6ca5abb edac4fd1 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Read in hugetlb_fault
2022/11/02 00:36 upstream b229b6ca5abb edac4fd1 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: use-after-free Read in hugetlb_fault
2022/10/24 01:15 upstream a70385240892 23bf86af .config strace log report syz C ci-upstream-kasan-gce KASAN: use-after-free Read in hugetlb_fault
2022/10/23 22:21 upstream a70385240892 23bf86af .config strace log report syz C ci-upstream-kasan-gce KASAN: use-after-free Read in hugetlb_fault
2022/10/23 22:03 linux-next 4d48f589d294 23bf86af .config strace log report syz C [disk image] [vmlinux] ci-upstream-linux-next-kasan-gce-root KASAN: use-after-free Read in hugetlb_fault
2022/11/12 13:10 upstream f5020a08b2b3 3ead01ad .config console log report syz C ci-upstream-kasan-gce KASAN: use-after-free Write in hugetlb_fault
2023/01/25 06:31 linux-next 691781f561e9 9dfcf09c .config console log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/21 01:51 linux-next d514392f17fd 559a440a .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/20 14:30 linux-next d514392f17fd 559a440a .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/20 14:06 linux-next d514392f17fd 559a440a .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2022/11/28 23:03 upstream b7b275e60bcd 247de55b .config console log report syz ci-upstream-kasan-gce-root KASAN: use-after-free Read in hugetlb_fault
2022/11/16 13:43 upstream 81e7cfa3a9eb 3a127a31 .config console log report syz ci-upstream-kasan-gce KASAN: use-after-free Read in hugetlb_fault
2022/10/18 17:56 upstream bb1a1146467a b31320fc .config console log report info ci-qemu-upstream KASAN: use-after-free Read in hugetlb_fault
2022/10/31 16:07 upstream b229b6ca5abb 2a71366b .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-386 KASAN: use-after-free Read in hugetlb_fault
2022/11/25 08:31 upstream 08ad43d554ba 74a66371 .config console log report info ci-upstream-kasan-gce-selinux-root KASAN: use-after-free Write in hugetlb_fault
2023/01/27 02:09 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/27 01:24 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 23:37 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 19:41 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 17:15 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 16:10 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 15:56 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 13:00 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 11:59 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 09:55 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 09:28 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 08:18 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 05:31 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 03:30 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 01:40 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/26 00:21 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 22:32 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 19:19 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 16:54 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 11:05 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 09:52 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 07:37 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 06:10 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 05:11 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/25 04:10 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 19:47 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 18:17 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 16:48 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 15:41 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 14:32 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 13:29 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 12:43 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 11:41 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 10:24 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 05:46 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 02:47 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/24 00:14 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/23 22:19 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/23 21:37 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/23 20:07 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/23 18:52 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
2023/01/23 17:43 linux-next 691781f561e9 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: null-ptr-deref Read in hugetlb_fault
* Struck through repros no longer work on HEAD.