bisecting cause commit starting from 244dc2689085d7ff478f7b61841e62e59bea4557 building syzkaller on bc8bc756c272115ed92fad4f716b77f6fb995203 testing commit 244dc2689085d7ff478f7b61841e62e59bea4557 with gcc (GCC) 8.1.0 kernel signature: c9e2bc815f87b155f9bedb0ef5efc09a80299b2eceb24dd2daa6cc4a79bd2dc8 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_ip_add testing release v5.4 testing commit 219d54332a09e8d8741c1e1982f5eae56099de85 with gcc (GCC) 8.1.0 kernel signature: cf83c3bb28646ae9c39d2bb50c55c2e9009e8d6ae0d7a01df0fe30cca146c8fc all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_ip_add testing release v5.3 testing commit 4d856f72c10ecb060868ed10ff1b1453943fc6c8 with gcc (GCC) 8.1.0 kernel signature: 24102bc05f6ee3b4a615dd7e4b6fda82fdddf8458ebbe758fe96b330085c5bc0 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_ip_add testing release v5.2 testing commit 0ecfebd2b52404ae0c54a878c872bb93363ada36 with gcc (GCC) 8.1.0 kernel signature: 52cbb839e2a6616247ab35eefea142051e6c48b59852d9e86491b9f6b6339f50 all runs: OK # git bisect start 4d856f72c10ecb060868ed10ff1b1453943fc6c8 0ecfebd2b52404ae0c54a878c872bb93363ada36 Bisecting: 7848 revisions left to test after this (roughly 13 steps) [43c95d3694cc448fdf50bd53b7ff3a5bb4655883] Merge tag 'pinctrl-v5.3-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl testing commit 43c95d3694cc448fdf50bd53b7ff3a5bb4655883 with gcc (GCC) 8.1.0 kernel signature: 75ea994010e91a99faf7b49cebb9961c3da4c9f81bc581a621a4aa11880fb1b0 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_ip_add # git bisect bad 43c95d3694cc448fdf50bd53b7ff3a5bb4655883 Bisecting: 4619 revisions left to test after this (roughly 12 steps) [8f6ccf6159aed1f04c6d179f61f6fb2691261e84] Merge tag 'clone3-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux testing commit 8f6ccf6159aed1f04c6d179f61f6fb2691261e84 with gcc (GCC) 8.1.0 kernel signature: 4d394430864622cf0d9f84bad1e541de92ac2c0646751aa245eaac05220d19a8 all runs: OK # git bisect good 8f6ccf6159aed1f04c6d179f61f6fb2691261e84 Bisecting: 2306 revisions left to test after this (roughly 11 steps) [753c8d9b7d81206bb5d011b28abe829d364b028e] Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip testing commit 753c8d9b7d81206bb5d011b28abe829d364b028e with gcc (GCC) 8.1.0 kernel signature: 4a6edcafc25f6d2c90129a79ffbc8a5e263e97d5e829a513fae628fdf4284361 all runs: OK # git bisect good 753c8d9b7d81206bb5d011b28abe829d364b028e Bisecting: 1152 revisions left to test after this (roughly 10 steps) [d72619706abc4aa7e540ea882dae883cee7cc3b3] Merge tag 'tty-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty testing commit d72619706abc4aa7e540ea882dae883cee7cc3b3 with gcc (GCC) 8.1.0 kernel signature: 6509f7637cb8f0c85b0c558d2a2ee89b51dca8b4ffa4728f118ac3e02408b699 all runs: OK # git bisect good d72619706abc4aa7e540ea882dae883cee7cc3b3 Bisecting: 574 revisions left to test after this (roughly 9 steps) [f632a8170a6b667ee4e3f552087588f0fe13c4bb] Merge tag 'driver-core-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core testing commit f632a8170a6b667ee4e3f552087588f0fe13c4bb with gcc (GCC) 8.1.0 kernel signature: b1b2344c89c1fe1b1f57a046aeed5b049eec2626f6711a0b7320d103009e684d all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_ip_add # git bisect bad f632a8170a6b667ee4e3f552087588f0fe13c4bb Bisecting: 307 revisions left to test after this (roughly 8 steps) [d06e4156430e7c5eb4f04dabcaa0d9e2fba335e3] Merge tag 'devicetree-for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux testing commit d06e4156430e7c5eb4f04dabcaa0d9e2fba335e3 with gcc (GCC) 8.1.0 kernel signature: 9ba35befa5148ec87d662c73ab549fc63457b3a79b8cf3ebcc0c7a578b8e26af all runs: OK # git bisect good d06e4156430e7c5eb4f04dabcaa0d9e2fba335e3 Bisecting: 160 revisions left to test after this (roughly 7 steps) [2c207985f354dfb549e5a543102a3e084eea81f6] mm/oom_kill.c: remove redundant OOM score normalization in select_bad_process() testing commit 2c207985f354dfb549e5a543102a3e084eea81f6 with gcc (GCC) 8.1.0 kernel signature: cc398208f9bb162678c28e4ec28f872e78e0693a971a37517f7f6501748d1ea0 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_ip_add # git bisect bad 2c207985f354dfb549e5a543102a3e084eea81f6 Bisecting: 73 revisions left to test after this (roughly 6 steps) [0b14e8aa68223c2c124d408aa4b110b364d13c53] mm: memcg/slab: rename slab delayed deactivation functions and fields testing commit 0b14e8aa68223c2c124d408aa4b110b364d13c53 with gcc (GCC) 8.1.0 kernel signature: 8f54a2ce6a3cc795fbfa612d579265eb27d3dd1ba347070f816e07870cb55f31 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_ip_add # git bisect bad 0b14e8aa68223c2c124d408aa4b110b364d13c53 Bisecting: 36 revisions left to test after this (roughly 5 steps) [751ad98d5f881df91ba47e013b82422912381e8e] asm-generic, x86: add bitops instrumentation for KASAN testing commit 751ad98d5f881df91ba47e013b82422912381e8e with gcc (GCC) 8.1.0 kernel signature: 881de59c0d4f27a9cd6565aa220ad003f92a70d2ba79723e9be2941924cc1add all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_ip_add # git bisect bad 751ad98d5f881df91ba47e013b82422912381e8e Bisecting: 17 revisions left to test after this (roughly 4 steps) [0e71666b8b9e21e4cb5d805219eb5ed7c5617ca3] ocfs2/dlm: use struct_size() helper testing commit 0e71666b8b9e21e4cb5d805219eb5ed7c5617ca3 with gcc (GCC) 8.1.0 kernel signature: 8fe49034c66a8a8a73511ca554410aed4bec1607f71e231696ec936fcfc1d536 all runs: OK # git bisect good 0e71666b8b9e21e4cb5d805219eb5ed7c5617ca3 Bisecting: 8 revisions left to test after this (roughly 3 steps) [966fede8e4be15bcc08e3c390080d3f9072a5367] lkdtm/heap: add tests for freelist hardening testing commit 966fede8e4be15bcc08e3c390080d3f9072a5367 with gcc (GCC) 8.1.0 kernel signature: 21ce2508d2f5e5ab12cda13b2f5154db29d66a39ea15cfb7c52f3942b8da7b9e all runs: OK # git bisect good 966fede8e4be15bcc08e3c390080d3f9072a5367 Bisecting: 4 revisions left to test after this (roughly 2 steps) [4e4dfce2278929de4379cdcfa2335dad7a6c4aa0] mm/kmemleak.c: change error at _write when kmemleak is disabled testing commit 4e4dfce2278929de4379cdcfa2335dad7a6c4aa0 with gcc (GCC) 8.1.0 kernel signature: bf29cfb5aca9f2ffba31d2d48afab188e0672c262f3b23b1b8147eeecd661343 all runs: OK # git bisect good 4e4dfce2278929de4379cdcfa2335dad7a6c4aa0 Bisecting: 2 revisions left to test after this (roughly 1 step) [e89692190065c12386bd37272ae8b7d142dd079f] mm/kasan: print frame description for stack bugs testing commit e89692190065c12386bd37272ae8b7d142dd079f with gcc (GCC) 8.1.0 kernel signature: edd648e41afb73612faac740088d6fc5bd78305e5f6585d6964a81b327c1ed20 all runs: OK # git bisect good e89692190065c12386bd37272ae8b7d142dd079f Bisecting: 0 revisions left to test after this (roughly 1 step) [ff66135015726696568e998720d9b6afe2d04642] x86: use static_cpu_has in uaccess region to avoid instrumentation testing commit ff66135015726696568e998720d9b6afe2d04642 with gcc (GCC) 8.1.0 kernel signature: 2350c6edb318eb931616078f9f848baa4f68d7dfa9dc8978ff4087b8531ed1c9 all runs: OK # git bisect good ff66135015726696568e998720d9b6afe2d04642 751ad98d5f881df91ba47e013b82422912381e8e is the first bad commit commit 751ad98d5f881df91ba47e013b82422912381e8e Author: Marco Elver Date: Thu Jul 11 20:54:00 2019 -0700 asm-generic, x86: add bitops instrumentation for KASAN This adds a new header to asm-generic to allow optionally instrumenting architecture-specific asm implementations of bitops. This change includes the required change for x86 as reference and changes the kernel API doc to point to bitops-instrumented.h instead. Rationale: the functions in x86's bitops.h are no longer the kernel API functions, but instead the arch_ prefixed functions, which are then instrumented via bitops-instrumented.h. Other architectures can similarly add support for asm implementations of bitops. The documentation text was derived from x86 and existing bitops asm-generic versions: 1) references to x86 have been removed; 2) as a result, some of the text had to be reworded for clarity and consistency. Tested using lib/test_kasan with bitops tests (pre-requisite patch). Bugzilla ref: https://bugzilla.kernel.org/show_bug.cgi?id=198439 Link: http://lkml.kernel.org/r/20190613125950.197667-4-elver@google.com Signed-off-by: Marco Elver Acked-by: Mark Rutland Reviewed-by: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Arnd Bergmann Cc: Borislav Petkov Cc: Dmitry Vyukov Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Jonathan Corbet Cc: Josh Poimboeuf Cc: Peter Zijlstra (Intel) Cc: Thomas Gleixner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Documentation/core-api/kernel-api.rst | 2 +- arch/x86/include/asm/bitops.h | 189 +++++---------------- include/asm-generic/bitops-instrumented.h | 263 ++++++++++++++++++++++++++++++ 3 files changed, 302 insertions(+), 152 deletions(-) create mode 100644 include/asm-generic/bitops-instrumented.h culprit signature: 881de59c0d4f27a9cd6565aa220ad003f92a70d2ba79723e9be2941924cc1add parent signature: 2350c6edb318eb931616078f9f848baa4f68d7dfa9dc8978ff4087b8531ed1c9 revisions tested: 18, total time: 4h10m20.860018871s (build: 1h53m18.523635502s, test: 2h15m23.073530769s) first bad commit: 751ad98d5f881df91ba47e013b82422912381e8e asm-generic, x86: add bitops instrumentation for KASAN cc: ["akpm@linux-foundation.org" "aryabinin@virtuozzo.com" "elver@google.com" "mark.rutland@arm.com" "torvalds@linux-foundation.org"] crash: KASAN: slab-out-of-bounds Read in bitmap_ip_add ================================================================== BUG: KASAN: slab-out-of-bounds in test_bit include/asm-generic/bitops-instrumented.h:237 [inline] BUG: KASAN: slab-out-of-bounds in bitmap_ip_do_add net/netfilter/ipset/ip_set_bitmap_ip.c:83 [inline] BUG: KASAN: slab-out-of-bounds in bitmap_ip_add+0xea/0x10a0 net/netfilter/ipset/ip_set_bitmap_gen.h:136 Read of size 8 at addr ffff8880a5fbe880 by task syz-executor.3/7340 CPU: 1 PID: 7340 Comm: syz-executor.3 Not tainted 5.2.0-syzkaller #0 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+0x113/0x167 lib/dump_stack.c:113 print_address_description.cold.8+0x9/0x318 mm/kasan/report.c:351 __kasan_report.cold.9+0x1b/0x3f mm/kasan/report.c:482 kasan_report+0x12/0x20 mm/kasan/common.c:614 check_memory_region_inline mm/kasan/generic.c:185 [inline] check_memory_region+0x13e/0x1b0 mm/kasan/generic.c:191 kasan_check_read+0x11/0x20 mm/kasan/common.c:94 test_bit include/asm-generic/bitops-instrumented.h:237 [inline] bitmap_ip_do_add net/netfilter/ipset/ip_set_bitmap_ip.c:83 [inline] bitmap_ip_add+0xea/0x10a0 net/netfilter/ipset/ip_set_bitmap_gen.h:136 bitmap_ip_uadt+0x611/0x940 net/netfilter/ipset/ip_set_bitmap_ip.c:186 call_ad+0x178/0x560 net/netfilter/ipset/ip_set_core.c:1515 ip_set_ad.isra.27+0x411/0xb30 net/netfilter/ipset/ip_set_core.c:1601 ip_set_uadd+0x11/0x20 net/netfilter/ipset/ip_set_core.c:1625 nfnetlink_rcv_msg+0x946/0xc10 net/netfilter/nfnetlink.c:229 netlink_rcv_skb+0x13c/0x380 net/netlink/af_netlink.c:2477 nfnetlink_rcv+0x15d/0x3b0 net/netfilter/nfnetlink.c:563 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline] netlink_unicast+0x43b/0x640 net/netlink/af_netlink.c:1328 netlink_sendmsg+0x765/0xc50 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:633 [inline] sock_sendmsg+0xb5/0xf0 net/socket.c:653 ___sys_sendmsg+0x647/0x950 net/socket.c:2306 __sys_sendmsg+0xd9/0x180 net/socket.c:2344 __do_sys_sendmsg net/socket.c:2353 [inline] __se_sys_sendmsg net/socket.c:2351 [inline] __x64_sys_sendmsg+0x73/0xb0 net/socket.c:2351 do_syscall_64+0xd0/0x540 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x45b159 Code: ad b6 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 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f289cad0c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f289cad16d4 RCX: 000000000045b159 RDX: 0000000000000000 RSI: 0000000020000300 RDI: 0000000000000003 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 00000000000008dc R14: 00000000004ca08f R15: 000000000075bf2c Allocated by task 7340: save_stack+0x21/0x90 mm/kasan/common.c:71 set_track mm/kasan/common.c:79 [inline] __kasan_kmalloc.constprop.12+0xc7/0xd0 mm/kasan/common.c:489 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503 __do_kmalloc mm/slab.c:3654 [inline] __kmalloc+0x15d/0x760 mm/slab.c:3663 kmalloc include/linux/slab.h:552 [inline] kzalloc include/linux/slab.h:742 [inline] ip_set_alloc+0x1b/0x30 net/netfilter/ipset/ip_set_core.c:255 init_map_ip net/netfilter/ipset/ip_set_bitmap_ip.c:223 [inline] bitmap_ip_create+0x540/0xd00 net/netfilter/ipset/ip_set_bitmap_ip.c:315 ip_set_create+0x5aa/0x1150 net/netfilter/ipset/ip_set_core.c:942 nfnetlink_rcv_msg+0x946/0xc10 net/netfilter/nfnetlink.c:229 netlink_rcv_skb+0x13c/0x380 net/netlink/af_netlink.c:2477 nfnetlink_rcv+0x15d/0x3b0 net/netfilter/nfnetlink.c:563 netlink_unicast_kernel net/netlink/af_netlink.c:1302 [inline] netlink_unicast+0x43b/0x640 net/netlink/af_netlink.c:1328 netlink_sendmsg+0x765/0xc50 net/netlink/af_netlink.c:1917 sock_sendmsg_nosec net/socket.c:633 [inline] sock_sendmsg+0xb5/0xf0 net/socket.c:653 ___sys_sendmsg+0x647/0x950 net/socket.c:2306 __sys_sendmsg+0xd9/0x180 net/socket.c:2344 __do_sys_sendmsg net/socket.c:2353 [inline] __se_sys_sendmsg net/socket.c:2351 [inline] __x64_sys_sendmsg+0x73/0xb0 net/socket.c:2351 do_syscall_64+0xd0/0x540 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe Freed by task 7182: save_stack+0x21/0x90 mm/kasan/common.c:71 set_track mm/kasan/common.c:79 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/common.c:451 kasan_slab_free+0xe/0x10 mm/kasan/common.c:459 __cache_free mm/slab.c:3426 [inline] kfree+0x108/0x2c0 mm/slab.c:3755 single_release+0x8b/0xc0 fs/seq_file.c:609 __fput+0x25a/0x770 fs/file_table.c:280 ____fput+0x9/0x10 fs/file_table.c:313 task_work_run+0x108/0x180 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop+0x24e/0x2e0 arch/x86/entry/common.c:163 prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline] syscall_return_slowpath arch/x86/entry/common.c:274 [inline] do_syscall_64+0x462/0x540 arch/x86/entry/common.c:299 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff8880a5fbe880 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff8880a5fbe880, ffff8880a5fbe8a0) The buggy address belongs to the page: page:ffffea000297ef80 refcount:1 mapcount:0 mapping:ffff8880aa4001c0 index:0xffff8880a5fbefc1 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea000297c888 ffffea000293ff88 ffff8880aa4001c0 raw: ffff8880a5fbefc1 ffff8880a5fbe000 0000000100000039 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880a5fbe780: 00 00 fc fc fc fc fc fc fb fb fb fb fc fc fc fc ffff8880a5fbe800: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc >ffff8880a5fbe880: 04 fc fc fc fc fc fc fc 00 05 fc fc fc fc fc fc ^ ffff8880a5fbe900: 00 00 fc fc fc fc fc fc 00 fc fc fc fc fc fc fc ffff8880a5fbe980: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ==================================================================