bisecting cause commit starting from cb71b93c2dc36d18a8b05245973328d018272cdf building syzkaller on b5765a153856746a5e7b74ea11751342337b0370 testing commit cb71b93c2dc36d18a8b05245973328d018272cdf compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 831af8c9d62b72a30137fe7e4b04ef9fb57056490c8210708ad207ee3d1e2843 all runs: crashed: KASAN: use-after-free Read in mprotect_fixup testing release v5.18 testing commit 4b0986a3613c92f4ec1bdc7f60ec66fea135991f compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 299eff2ecefd76c5968b8222a0eeeb63cb64d967fa12f5575aa5a0034b95721f all runs: OK # git bisect start cb71b93c2dc36d18a8b05245973328d018272cdf 4b0986a3613c92f4ec1bdc7f60ec66fea135991f Bisecting: 10621 revisions left to test after this (roughly 13 steps) [9d004b2f4fea97cde123e7f1939b80e77bf2e695] Merge tag 'cxl-for-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl testing commit 9d004b2f4fea97cde123e7f1939b80e77bf2e695 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 29a334d9d6331a408077609af7600a9810bcf96c5b15f51e6483b32113e170fa all runs: OK # git bisect good 9d004b2f4fea97cde123e7f1939b80e77bf2e695 Bisecting: 5301 revisions left to test after this (roughly 12 steps) [b4c48ce837dc0122ed62b423c334b620cf8ff81b] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git testing commit b4c48ce837dc0122ed62b423c334b620cf8ff81b compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 94a54038dac98bfe075cd88a01ff548605425e2be462e5739d3c347b48d71bab all runs: OK # git bisect good b4c48ce837dc0122ed62b423c334b620cf8ff81b Bisecting: 2582 revisions left to test after this (roughly 11 steps) [c2e609e496f8195af2b789511f24a00546bb976e] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git testing commit c2e609e496f8195af2b789511f24a00546bb976e compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 584e16085d970facd57b5ecca832a8b131c55aa7c991c70a0ea2f4f6b187b8eb all runs: OK # git bisect good c2e609e496f8195af2b789511f24a00546bb976e Bisecting: 1245 revisions left to test after this (roughly 10 steps) [f38c55f14bf7f4b2abc621e53d4f2ec05693b8d9] Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git testing commit f38c55f14bf7f4b2abc621e53d4f2ec05693b8d9 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: dc1dc037d7a87326472752e18770b343f213282180f98b2c82c4c5a4a286d73e all runs: OK # git bisect good f38c55f14bf7f4b2abc621e53d4f2ec05693b8d9 Bisecting: 621 revisions left to test after this (roughly 9 steps) [f0b534a439397a673ea84327da9a89b557417d20] Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git testing commit f0b534a439397a673ea84327da9a89b557417d20 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: c4e0b3d825ccda4b81cbc30dbce0f595770dd405a3f80012d28a3a2eec39fb0a all runs: OK # git bisect good f0b534a439397a673ea84327da9a89b557417d20 Bisecting: 307 revisions left to test after this (roughly 8 steps) [ee8804b7b3e6c5f45ddeafa3273f673bd4524110] Merge branch 'mm-stable' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm testing commit ee8804b7b3e6c5f45ddeafa3273f673bd4524110 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 2b813bdb985004c94c7f3046344bd8ab38632f69ee9ca2ff556d54e4133e88aa all runs: OK # git bisect good ee8804b7b3e6c5f45ddeafa3273f673bd4524110 Bisecting: 153 revisions left to test after this (roughly 7 steps) [e6369794355535a6ede873c3633dfc91bf1932b9] mm/damon/schemes: add 'LRU_PRIO' DAMOS action testing commit e6369794355535a6ede873c3633dfc91bf1932b9 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 15e0becf00f89dd4af08aae4ef59a1480eaca2ac50113748b8b4d7e32d96d00b all runs: crashed: KASAN: use-after-free Read in mprotect_fixup # git bisect bad e6369794355535a6ede873c3633dfc91bf1932b9 Bisecting: 76 revisions left to test after this (roughly 6 steps) [e23cb70bcbef5c189790042d1d6d89e33308c386] mm: remove the vma linked list testing commit e23cb70bcbef5c189790042d1d6d89e33308c386 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 2e09afb7c4146d7998b56b104ea51dc43d46c0738125fbfc052065ad8d6df396 all runs: crashed: KASAN: use-after-free Read in mprotect_fixup # git bisect bad e23cb70bcbef5c189790042d1d6d89e33308c386 Bisecting: 38 revisions left to test after this (roughly 5 steps) [392e35bc64f10697f255c7ed6548cd5a480f37d0] mm/mmap: reorganize munmap to use maple states testing commit 392e35bc64f10697f255c7ed6548cd5a480f37d0 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 1d62487ee61775b0d2e0bb1585c19bf9d32443d8bddb32c1d27599179af6d273 all runs: crashed: KASAN: use-after-free Read in mprotect_fixup # git bisect bad 392e35bc64f10697f255c7ed6548cd5a480f37d0 Bisecting: 18 revisions left to test after this (roughly 4 steps) [985ab5390e3d29c368e9f2401219f530b1965aa8] mm: add VMA iterator testing commit 985ab5390e3d29c368e9f2401219f530b1965aa8 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: ec124717c633ee8ce15d38d996c06fc18c75911cc1566bde4a623a2670ca0ef6 all runs: crashed: KASAN: use-after-free Read in mprotect_fixup # git bisect bad 985ab5390e3d29c368e9f2401219f530b1965aa8 Bisecting: 9 revisions left to test after this (roughly 3 steps) [df33742a4ad9a39e02608aca11c6eb1ddf3afbe0] Maple Tree: add new data structure testing commit df33742a4ad9a39e02608aca11c6eb1ddf3afbe0 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: a085883f3f7b8afffb18658fc35061d1f3f882a0f257f5f1e84c6ed20e9d35aa all runs: OK # git bisect good df33742a4ad9a39e02608aca11c6eb1ddf3afbe0 Bisecting: 4 revisions left to test after this (roughly 2 steps) [11945bc29b2590896b1cab890d9dcc443c3b0bbc] radix tree test suite: add support for slab bulk APIs testing commit 11945bc29b2590896b1cab890d9dcc443c3b0bbc compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 75b4ef76036abe6123e5b7783c56a140c06ae5744c3388c04a85b49206fc3cf8 all runs: OK # git bisect good 11945bc29b2590896b1cab890d9dcc443c3b0bbc Bisecting: 2 revisions left to test after this (roughly 1 step) [209e6c246b0ab3fa8df81299104284bcc27bc1b6] lib/test_maple_tree: add testing for maple tree testing commit 209e6c246b0ab3fa8df81299104284bcc27bc1b6 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 58b754ec539a3385e8b54f3cd7514222951cad543386a9c20eacb20c6b4df36c all runs: OK # git bisect good 209e6c246b0ab3fa8df81299104284bcc27bc1b6 Bisecting: 0 revisions left to test after this (roughly 1 step) [2ee236fe53a8e2ab54679c74e8a1fb77e55b29bb] mm: start tracking VMAs with maple tree testing commit 2ee236fe53a8e2ab54679c74e8a1fb77e55b29bb compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: fcd612b2d09426481760489b0f3e3e5f760fd77cc55cb01307bb0925fdb9baef all runs: crashed: KASAN: use-after-free Read in mprotect_fixup # git bisect bad 2ee236fe53a8e2ab54679c74e8a1fb77e55b29bb Bisecting: 0 revisions left to test after this (roughly 0 steps) [9400b59d2e5546fc603bf7047336fe76e1065c52] test_maple_tree: add test for spanning store of entire range testing commit 9400b59d2e5546fc603bf7047336fe76e1065c52 compiler: gcc (GCC) 10.2.1 20210217, GNU ld (GNU Binutils for Debian) 2.35.2 kernel signature: 9f1ed820c9419ac01010c36f40aee2d5aabf0ffbbb2ceaca0caddf60b85f38a4 all runs: OK # git bisect good 9400b59d2e5546fc603bf7047336fe76e1065c52 2ee236fe53a8e2ab54679c74e8a1fb77e55b29bb is the first bad commit commit 2ee236fe53a8e2ab54679c74e8a1fb77e55b29bb Author: Liam R. Howlett Date: Tue Jun 21 20:46:53 2022 +0000 mm: start tracking VMAs with maple tree Start tracking the VMAs with the new maple tree structure in parallel with the rb_tree. Add debug and trace events for maple tree operations and duplicate the rb_tree that is created on forks into the maple tree. The maple tree is added to the mm_struct including the mm_init struct, added support in required mm/mmap functions, added tracking in kernel/fork for process forking, and used to find the unmapped_area and checked against what the rbtree finds. This also moves the mmap_lock() in exit_mmap() since the oom reaper call does walk the VMAs. Otherwise lockdep will be unhappy if oom happens. Link: https://lkml.kernel.org/r/20220504010716.661115-10-Liam.Howlett@oracle.com Link: https://lkml.kernel.org/r/20220621204632.3370049-9-Liam.Howlett@oracle.com Signed-off-by: Liam R. Howlett Signed-off-by: Matthew Wilcox (Oracle) Cc: Catalin Marinas Cc: David Howells Cc: SeongJae Park Cc: Vlastimil Babka Cc: Will Deacon Cc: Davidlohr Bueso Signed-off-by: Andrew Morton arch/x86/kernel/tboot.c | 1 + drivers/firmware/efi/efi.c | 1 + include/linux/mm.h | 5 + include/linux/mm_types.h | 3 + include/trace/events/mmap.h | 73 ++++++++++ kernel/fork.c | 20 ++- mm/init-mm.c | 2 + mm/mmap.c | 320 ++++++++++++++++++++++++++++++++++++++++---- mm/nommu.c | 13 ++ 9 files changed, 412 insertions(+), 26 deletions(-) culprit signature: fcd612b2d09426481760489b0f3e3e5f760fd77cc55cb01307bb0925fdb9baef parent signature: 9f1ed820c9419ac01010c36f40aee2d5aabf0ffbbb2ceaca0caddf60b85f38a4 revisions tested: 17, total time: 4h1m27.950928595s (build: 2h4m59.337814881s, test: 1h54m30.854396207s) first bad commit: 2ee236fe53a8e2ab54679c74e8a1fb77e55b29bb mm: start tracking VMAs with maple tree recipients (to): ["akpm@linux-foundation.org" "liam.howlett@oracle.com" "willy@infradead.org"] recipients (cc): [] crash: KASAN: use-after-free Read in mprotect_fixup ================================================================== BUG: KASAN: use-after-free in mprotect_fixup+0x711/0x780 mm/mprotect.c:568 Read of size 8 at addr ffff88802499a630 by task syz-executor.0/4083 CPU: 1 PID: 4083 Comm: syz-executor.0 Not tainted 5.19.0-rc4-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/29/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x57/0x7d 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 mprotect_fixup+0x711/0x780 mm/mprotect.c:568 do_mprotect_pkey+0x406/0x7e0 mm/mprotect.c:733 __do_sys_pkey_mprotect mm/mprotect.c:768 [inline] __se_sys_pkey_mprotect mm/mprotect.c:765 [inline] __x64_sys_pkey_mprotect+0x8e/0xf0 mm/mprotect.c:765 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+0x46/0xb0 RIP: 0033:0x7fa344089109 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 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fa3451b7168 EFLAGS: 00000246 ORIG_RAX: 0000000000000149 RAX: ffffffffffffffda RBX: 00007fa34419bf60 RCX: 00007fa344089109 RDX: 0000000000000000 RSI: 0000000000003000 RDI: 0000000020ffd000 RBP: 00007fa3451b71d0 R08: 0000000000000000 R09: 0000000000000000 R10: ffffffffffffffff R11: 0000000000000246 R12: 0000000000000001 R13: 00007ffc1794e7df R14: 00007fa3451b7300 R15: 0000000000022000 Allocated by task 4083: 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_slab_alloc+0x90/0xc0 mm/kasan/common.c:469 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 vm_area_dup+0x83/0x380 kernel/fork.c:467 __split_vma+0x88/0x480 mm/mmap.c:2960 mprotect_fixup+0x54b/0x780 mm/mprotect.c:569 do_mprotect_pkey+0x406/0x7e0 mm/mprotect.c:733 __do_sys_pkey_mprotect mm/mprotect.c:768 [inline] __se_sys_pkey_mprotect mm/mprotect.c:765 [inline] __x64_sys_pkey_mprotect+0x8e/0xf0 mm/mprotect.c:765 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+0x46/0xb0 Freed by task 4083: 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] kmem_cache_free+0xdd/0x5a0 mm/slub.c:3553 __vma_adjust+0x845/0x2630 mm/mmap.c:1113 vma_merge+0xa8d/0x12f0 mm/mmap.c:1366 mprotect_fixup+0x2cc/0x780 mm/mprotect.c:557 do_mprotect_pkey+0x406/0x7e0 mm/mprotect.c:733 __do_sys_pkey_mprotect mm/mprotect.c:768 [inline] __se_sys_pkey_mprotect mm/mprotect.c:765 [inline] __x64_sys_pkey_mprotect+0x8e/0xf0 mm/mprotect.c:765 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+0x46/0xb0 The buggy address belongs to the object at ffff88802499a630 which belongs to the cache vm_area_struct of size 200 The buggy address is located 0 bytes inside of 200-byte region [ffff88802499a630, ffff88802499a6f8) The buggy address belongs to the physical page: page:ffffea0000926680 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2499a memcg:ffff8880206be301 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffffea0000968e80 dead000000000005 ffff888140006b40 raw: 0000000000000000 00000000800f000f 00000001ffffffff ffff8880206be301 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 3814, tgid 3814 (dhcpcd-run-hook), ts 55127326908, free_ts 55115182052 prep_new_page mm/page_alloc.c:2456 [inline] get_page_from_freelist+0x19d2/0x3b30 mm/page_alloc.c:4198 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5415 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+0x9bc/0xe10 mm/slub.c:3031 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3118 slab_alloc_node mm/slub.c:3209 [inline] slab_alloc mm/slub.c:3251 [inline] __kmem_cache_alloc_lru mm/slub.c:3258 [inline] kmem_cache_alloc+0x360/0x3b0 mm/slub.c:3268 vm_area_dup+0x83/0x380 kernel/fork.c:467 dup_mmap kernel/fork.c:646 [inline] dup_mm+0x56a/0x11d0 kernel/fork.c:1538 copy_mm kernel/fork.c:1590 [inline] copy_process+0x349a/0x6690 kernel/fork.c:2254 kernel_clone+0xb8/0x7f0 kernel/fork.c:2669 __do_sys_clone+0xa1/0xe0 kernel/fork.c:2803 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+0x46/0xb0 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 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2548 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+0x4a/0x440 fs/namei.c:139 do_sys_openat2+0xd2/0x3f0 fs/open.c:1272 do_sys_open fs/open.c:1294 [inline] __do_sys_openat fs/open.c:1310 [inline] __se_sys_openat fs/open.c:1305 [inline] __x64_sys_openat+0x11b/0x1d0 fs/open.c:1305 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+0x46/0xb0 Memory state around the buggy address: ffff88802499a500: fc fc fc fc fc fb fb fb fb fb fb fb fb fb fb fb ffff88802499a580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc >ffff88802499a600: fc fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb ^ ffff88802499a680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc ffff88802499a700: fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00 00 ==================================================================