bisecting cause commit starting from 5a9ef19454cd5daec8041bc7c3c11deb7456d9a0 building syzkaller on 3de7aabbb79a6c2267f5d7ee8a8aaa83f63305b7 testing commit 5a9ef19454cd5daec8041bc7c3c11deb7456d9a0 with gcc (GCC) 8.1.0 kernel signature: ebf6cd67d6ad015cfcb57b3d7d3e6d99343d34b1 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_port_add testing release v5.4 testing commit 219d54332a09e8d8741c1e1982f5eae56099de85 with gcc (GCC) 8.1.0 kernel signature: 4aad8fc5504d02b81d2ca20c799de46d9e5c6bb8 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_port_add testing release v5.3 testing commit 4d856f72c10ecb060868ed10ff1b1453943fc6c8 with gcc (GCC) 8.1.0 kernel signature: 9a857e3b158eb65339158eae58c6c59cc8efda4d all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_port_add testing release v5.2 testing commit 0ecfebd2b52404ae0c54a878c872bb93363ada36 with gcc (GCC) 8.1.0 kernel signature: 7d6eb649bab12af41ee3b8ceaf5e18d3f9fb2ce3 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: ca627fd5951a387021302081a2ff7d4b25928961 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_port_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: 8c2dfd1163fed53b81dcf8cd7a3e27cda44e2cf2 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: d61366ed471b17a81303da40d6b4dbd544e6ff0d 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: 76e0fdb26990309108f5bb06583a185be3bb7528 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: ce01cffc5fa7e43e1f82ea32a4d9c214a18c4db5 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_port_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: 5e798af1284cd0d2c588bee56eaddee5343efe5d 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: 34f0d3bca07fd2ae4b4952e78c53e8cf8d63dcf1 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_port_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: d8c7a2d33bd53ae36a43fc1bc255fc39e2bc8ebb all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_port_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: 9435c3b2caa9964b9b048d9ce6ff80f1314f14f4 all runs: crashed: KASAN: slab-out-of-bounds Read in bitmap_port_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: c4cb01ccbebb649ebe5b6a231e5f8539e21b9d38 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: 364c6808b1838753b50226bc403e598b6cd4f9f7 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: 2c98ea27a4e61d696d6dfb9602e9a6c63f037574 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: ec2d00ee5bc9cf9f51b7328510349229390bce76 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: b97472bd9e10d3a8491b5a933e06bf154a296b33 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: 9435c3b2caa9964b9b048d9ce6ff80f1314f14f4 parent signature: b97472bd9e10d3a8491b5a933e06bf154a296b33 revisions tested: 18, total time: 4h3m26.053083623s (build: 1h54m13.602496953s, test: 2h7m28.478515949s) 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_port_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_port_do_add net/netfilter/ipset/ip_set_bitmap_port.c:74 [inline] BUG: KASAN: slab-out-of-bounds in bitmap_port_add+0xea/0x10a0 net/netfilter/ipset/ip_set_bitmap_gen.h:136 Read of size 8 at addr ffff88809c364940 by task syz-executor.3/7419 CPU: 1 PID: 7419 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_port_do_add net/netfilter/ipset/ip_set_bitmap_port.c:74 [inline] bitmap_port_add+0xea/0x10a0 net/netfilter/ipset/ip_set_bitmap_gen.h:136 bitmap_port_uadt+0x551/0x890 net/netfilter/ipset/ip_set_bitmap_port.c:172 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:0x45aff9 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:00007f4f195b9c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f4f195ba6d4 RCX: 000000000045aff9 RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000003 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 00000000000008c8 R14: 00000000004c9dfc R15: 000000000075bf2c Allocated by task 7416: 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_port net/netfilter/ipset/ip_set_bitmap_port.c:207 [inline] bitmap_port_create+0x32e/0x740 net/netfilter/ipset/ip_set_bitmap_port.c:249 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 7229: 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 tomoyo_path_perm+0x218/0x380 security/tomoyo/file.c:842 tomoyo_inode_getattr+0x13/0x20 security/tomoyo/tomoyo.c:129 security_inode_getattr+0xb0/0x100 security/security.c:1182 vfs_getattr+0x1c/0x40 fs/stat.c:115 vfs_statx+0xd8/0x150 fs/stat.c:191 vfs_stat include/linux/fs.h:3203 [inline] __do_sys_newstat+0x85/0xe0 fs/stat.c:341 __se_sys_newstat fs/stat.c:337 [inline] __x64_sys_newstat+0x4f/0x70 fs/stat.c:337 do_syscall_64+0xd0/0x540 arch/x86/entry/common.c:296 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff88809c364940 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 0 bytes inside of 32-byte region [ffff88809c364940, ffff88809c364960) The buggy address belongs to the page: page:ffffea000270d900 refcount:1 mapcount:0 mapping:ffff8880aa4001c0 index:0xffff88809c364fc1 flags: 0xfffe0000000200(slab) raw: 00fffe0000000200 ffffea00027a9808 ffffea0002a3e388 ffff8880aa4001c0 raw: ffff88809c364fc1 ffff88809c364000 000000010000003c 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809c364800: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff88809c364880: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc >ffff88809c364900: fb fb fb fb fc fc fc fc 04 fc fc fc fc fc fc fc ^ ffff88809c364980: fb fb fb fb fc fc fc fc fb fb fb fb fc fc fc fc ffff88809c364a00: 00 fc fc fc fc fc fc fc fb fb fb fb fc fc fc fc ==================================================================