bisecting cause commit starting from 25e9471b6a279ee28eb17a1baeceb575543002f7 building syzkaller on 8bd6bd63656d411729c450d452e1355b42adf900 testing commit 25e9471b6a279ee28eb17a1baeceb575543002f7 with gcc (GCC) 8.1.0 run #0: crashed: general protection fault in delayed_uprobe_remove run #1: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #2: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #3: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #4: crashed: general protection fault in delayed_uprobe_remove run #5: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #6: OK run #7: OK run #8: OK run #9: OK testing release v4.19 testing commit 84df9525b0c27f3ebc2ebb1864fa62a97fdedb7d with gcc (GCC) 8.1.0 all runs: OK # git bisect start 25e9471b6a279ee28eb17a1baeceb575543002f7 v4.19 Bisecting: 6875 revisions left to test after this (roughly 13 steps) [26873acacbdbb4e4b444f5dd28dcc4853f0e8ba2] Merge tag 'driver-core-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core testing commit 26873acacbdbb4e4b444f5dd28dcc4853f0e8ba2 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 26873acacbdbb4e4b444f5dd28dcc4853f0e8ba2 Bisecting: 3325 revisions left to test after this (roughly 12 steps) [738b04fba18d35cd352b7b15afefb8a7b798648e] Merge tag 'staging-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging testing commit 738b04fba18d35cd352b7b15afefb8a7b798648e with gcc (GCC) 8.1.0 all runs: OK # git bisect good 738b04fba18d35cd352b7b15afefb8a7b798648e Bisecting: 1662 revisions left to test after this (roughly 11 steps) [8df1d0e4a265f25dc1e7e7624ccdbcb4a6630c89] mm/memory_hotplug: make add_memory() take the device_hotplug_lock testing commit 8df1d0e4a265f25dc1e7e7624ccdbcb4a6630c89 with gcc (GCC) 8.1.0 run #0: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #1: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #2: crashed: general protection fault in delayed_uprobe_remove run #3: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #4: crashed: general protection fault in delayed_uprobe_remove run #5: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad 8df1d0e4a265f25dc1e7e7624ccdbcb4a6630c89 Bisecting: 879 revisions left to test after this (roughly 10 steps) [be59a3282cf8e0c9c82e8835ffca98dfd2cd98e1] Merge tag 'socfpga_updates_for_v4.20_part3' of git://git.kernel.org/pub/scm/linux/kernel/git/dinguyen/linux into next/dt testing commit be59a3282cf8e0c9c82e8835ffca98dfd2cd98e1 with gcc (GCC) 8.1.0 all runs: OK # git bisect good be59a3282cf8e0c9c82e8835ffca98dfd2cd98e1 Bisecting: 420 revisions left to test after this (roughly 9 steps) [53b7a3b7ec00f207c18e71f58ef2bca48635c622] Merge tag 'armsoc-defconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc testing commit 53b7a3b7ec00f207c18e71f58ef2bca48635c622 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 53b7a3b7ec00f207c18e71f58ef2bca48635c622 Bisecting: 197 revisions left to test after this (roughly 8 steps) [4b42745211af552f170f38a1b97f4a112b5da6b2] Merge tag 'armsoc-soc' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc testing commit 4b42745211af552f170f38a1b97f4a112b5da6b2 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 4b42745211af552f170f38a1b97f4a112b5da6b2 Bisecting: 87 revisions left to test after this (roughly 7 steps) [343a9f35409b68b6de66ecd0db90a277aee90ec2] Merge tag 'trace-v4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace testing commit 343a9f35409b68b6de66ecd0db90a277aee90ec2 with gcc (GCC) 8.1.0 run #0: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #1: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #2: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #3: crashed: general protection fault in delayed_uprobe_remove run #4: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #5: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad 343a9f35409b68b6de66ecd0db90a277aee90ec2 Bisecting: 51 revisions left to test after this (roughly 6 steps) [85b5d4bcab8b46664f8e1993bd5919cb0f24a3ca] Merge tag 'for-4.20-part2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux testing commit 85b5d4bcab8b46664f8e1993bd5919cb0f24a3ca with gcc (GCC) 8.1.0 all runs: OK # git bisect good 85b5d4bcab8b46664f8e1993bd5919cb0f24a3ca Bisecting: 24 revisions left to test after this (roughly 5 steps) [f4267b3604a84ff72c013a0e3e467289908603a6] Merge tag 'trace-v4.19-rc8-3' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace testing commit f4267b3604a84ff72c013a0e3e467289908603a6 with gcc (GCC) 8.1.0 all runs: OK # git bisect good f4267b3604a84ff72c013a0e3e467289908603a6 Bisecting: 12 revisions left to test after this (roughly 4 steps) [9178412ddf5a98feba0ad3986111c5ad10eb9e59] tracing: probeevent: Return consumed bytes of dynamic area testing commit 9178412ddf5a98feba0ad3986111c5ad10eb9e59 with gcc (GCC) 8.1.0 run #0: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #1: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #2: crashed: general protection fault in delayed_uprobe_remove run #3: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #4: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #5: crashed: general protection fault in delayed_uprobe_remove run #6: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #7: OK run #8: OK run #9: OK # git bisect bad 9178412ddf5a98feba0ad3986111c5ad10eb9e59 Bisecting: 5 revisions left to test after this (roughly 3 steps) [a6ca88b241d5e929e6e60b12ad8cd288f0ffa256] trace_uprobe: support reference counter in fd-based uprobe testing commit a6ca88b241d5e929e6e60b12ad8cd288f0ffa256 with gcc (GCC) 8.1.0 run #0: crashed: BUG: corrupted list in delayed_uprobe_delete run #1: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #2: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #3: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #4: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #5: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #6: crashed: general protection fault in delayed_uprobe_remove run #7: crashed: KASAN: use-after-free Read in delayed_uprobe_remove run #8: OK run #9: OK # git bisect bad a6ca88b241d5e929e6e60b12ad8cd288f0ffa256 Bisecting: 2 revisions left to test after this (roughly 2 steps) [22bad38286d9a652d7061a02f9743bb2ebb84e59] uprobes/sdt: Prevent multiple reference counter for same uprobe testing commit 22bad38286d9a652d7061a02f9743bb2ebb84e59 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 22bad38286d9a652d7061a02f9743bb2ebb84e59 Bisecting: 0 revisions left to test after this (roughly 1 step) [5a5e3d3ceae2121590d67258a4e658d938b4a46d] perf probe: Support SDT markers having reference counter (semaphore) testing commit 5a5e3d3ceae2121590d67258a4e658d938b4a46d with gcc (GCC) 8.1.0 all runs: OK # git bisect good 5a5e3d3ceae2121590d67258a4e658d938b4a46d a6ca88b241d5e929e6e60b12ad8cd288f0ffa256 is the first bad commit commit a6ca88b241d5e929e6e60b12ad8cd288f0ffa256 Author: Song Liu Date: Mon Oct 1 22:36:36 2018 -0700 trace_uprobe: support reference counter in fd-based uprobe This patch enables uprobes with reference counter in fd-based uprobe. Highest 32 bits of perf_event_attr.config is used to stored offset of the reference count (semaphore). Format information in /sys/bus/event_source/devices/uprobe/format/ is updated to reflect this new feature. Link: http://lkml.kernel.org/r/20181002053636.1896903-1-songliubraving@fb.com Cc: Oleg Nesterov Acked-by: Peter Zijlstra (Intel) Reviewed-and-tested-by: Ravi Bangoria Signed-off-by: Song Liu Signed-off-by: Steven Rostedt (VMware) :040000 040000 b446c3d6eac34a0d1a8ffcd908316b24faaa2369 f66eeb68be0e10cf2e14dea4e1a5463ea453d9f9 M include :040000 040000 aeb23f2502565e9991cc09794b274723d04e514b c9ca32f10032ea54394cbf689e05fe21708554e6 M kernel revisions tested: 15, total time: 4h32m56.875539413s (build: 1h29m14.819808547s, test: 2h58m28.025644966s) first bad commit: a6ca88b241d5e929e6e60b12ad8cd288f0ffa256 trace_uprobe: support reference counter in fd-based uprobe cc: ["acme@kernel.org" "alexander.shishkin@linux.intel.com" "jolsa@redhat.com" "linux-kernel@vger.kernel.org" "mingo@redhat.com" "namhyung@kernel.org" "oleg@redhat.com" "peterz@infradead.org" "ravi.bangoria@linux.ibm.com" "rostedt@goodmis.org" "songliubraving@fb.com"] crash: KASAN: use-after-free Read in delayed_uprobe_remove ================================================================== BUG: KASAN: use-after-free in delayed_uprobe_remove.part.21+0xc5/0xf0 kernel/events/uprobes.c:339 Read of size 8 at addr ffff8801b9d34c80 by task syz-executor0/24839 CPU: 1 PID: 24839 Comm: syz-executor0 Not tainted 4.19.0-rc5+ #1 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x16e/0x22a lib/dump_stack.c:113 print_address_description.cold.8+0x9/0x1ff mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report.cold.9+0x242/0x309 mm/kasan/report.c:412 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433 delayed_uprobe_remove.part.21+0xc5/0xf0 kernel/events/uprobes.c:339 delayed_uprobe_remove kernel/events/uprobes.c:336 [inline] put_uprobe+0x2b/0x40 kernel/events/uprobes.c:575 uprobe_unregister+0x40/0x50 kernel/events/uprobes.c:1088 probe_event_disable.part.14+0x149/0x290 kernel/trace/trace_uprobe.c:1017 probe_event_disable kernel/trace/trace_uprobe.c:1262 [inline] trace_uprobe_register+0x467/0xe50 kernel/trace/trace_uprobe.c:1261 perf_trace_event_unreg.isra.3+0xa4/0x1e0 kernel/trace/trace_event_perf.c:157 perf_uprobe_destroy+0xbe/0x130 kernel/trace/trace_event_perf.c:342 _free_event+0x3ac/0x1370 kernel/events/core.c:4440 put_event+0x2b/0x30 kernel/events/core.c:4526 perf_event_release_kernel+0x797/0x1010 kernel/events/core.c:4632 perf_release+0x32/0x50 kernel/events/core.c:4642 __fput+0x303/0xab0 fs/file_table.c:278 ____fput+0x9/0x10 fs/file_table.c:309 task_work_run+0x19f/0x240 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:193 [inline] exit_to_usermode_loop+0x26e/0x300 arch/x86/entry/common.c:166 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline] syscall_return_slowpath arch/x86/entry/common.c:268 [inline] do_syscall_64+0x587/0x700 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x4576b9 Code: fd b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 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 0f 83 cb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007ff8793fec78 EFLAGS: 00000246 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000001 RCX: 00000000004576b9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006 RBP: 000000000072bf00 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007ff8793ff6d4 R13: 00000000004efed2 R14: 00000000004cc780 R15: 00000000ffffffff Allocated by task 24836: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553 kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620 kmalloc include/linux/slab.h:513 [inline] kzalloc include/linux/slab.h:707 [inline] delayed_uprobe_add kernel/events/uprobes.c:313 [inline] update_ref_ctr+0x2e9/0x4f0 kernel/events/uprobes.c:447 uprobe_write_opcode+0x79b/0xa60 kernel/events/uprobes.c:496 set_swbp+0xe/0x10 install_breakpoint.isra.25+0x131/0x700 kernel/events/uprobes.c:883 uprobe_mmap+0x5d1/0xff0 kernel/events/uprobes.c:1353 mmap_region+0x4aa/0x1b30 mm/mmap.c:1808 do_mmap+0x86e/0x1360 mm/mmap.c:1535 do_mmap_pgoff include/linux/mm.h:2298 [inline] vm_mmap_pgoff+0x1d7/0x2c0 mm/util.c:357 ksys_mmap_pgoff+0x40d/0x6b0 mm/mmap.c:1585 __do_sys_mmap arch/x86/kernel/sys_x86_64.c:100 [inline] __se_sys_mmap arch/x86/kernel/sys_x86_64.c:91 [inline] __x64_sys_mmap+0xe9/0x1b0 arch/x86/kernel/sys_x86_64.c:91 do_syscall_64+0x183/0x700 arch/x86/entry/common.c:290 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 24841: save_stack+0x43/0xd0 mm/kasan/kasan.c:448 set_track mm/kasan/kasan.c:460 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528 __cache_free mm/slab.c:3498 [inline] kfree+0xcf/0x230 mm/slab.c:3813 delayed_uprobe_delete+0x182/0x250 kernel/events/uprobes.c:328 delayed_uprobe_remove.part.21+0xb0/0xf0 kernel/events/uprobes.c:347 delayed_uprobe_remove kernel/events/uprobes.c:336 [inline] uprobe_clear_state+0xbc/0x310 kernel/events/uprobes.c:1510 __mmput kernel/fork.c:997 [inline] mmput+0x18e/0x560 kernel/fork.c:1022 exit_mm kernel/exit.c:545 [inline] do_exit+0xd52/0x2320 kernel/exit.c:854 do_group_exit+0x13d/0x3c0 kernel/exit.c:970 get_signal+0x686/0x1420 kernel/signal.c:2513 do_signal+0x9c/0x21e0 arch/x86/kernel/signal.c:816 exit_to_usermode_loop+0x1ce/0x300 arch/x86/entry/common.c:162 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline] syscall_return_slowpath arch/x86/entry/common.c:268 [inline] do_syscall_64+0x587/0x700 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8801b9d34c80 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff8801b9d34c80, ffff8801b9d34ca0) The buggy address belongs to the page: page:ffffea0006e74d00 count:1 mapcount:0 mapping:ffff8801da8001c0 index:0xffff8801b9d34fc1 flags: 0x2fffc0000000100(slab) raw: 02fffc0000000100 ffffea0006e99b48 ffffea00075edfc8 ffff8801da8001c0 raw: ffff8801b9d34fc1 ffff8801b9d34000 000000010000003e 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8801b9d34b80: fb fb fb fb fc fc fc fc 00 00 01 fc fc fc fc fc ffff8801b9d34c00: fb fb fb fb fc fc fc fc 00 00 00 05 fc fc fc fc >ffff8801b9d34c80: fb fb fb fb fc fc fc fc 00 00 00 00 fc fc fc fc ^ ffff8801b9d34d00: fb fb fb fb fc fc fc fc 00 00 00 fc fc fc fc fc ffff8801b9d34d80: fb fb fb fb fc fc fc fc 00 00 07 fc fc fc fc fc ==================================================================