syzbot


KASAN: slab-out-of-bounds Read in bitmap_ip_add

Status: upstream: reported on 2024/12/02 14:17
Reported-by: syzbot+b8b46d888f567563c7fd@syzkaller.appspotmail.com
First crash: 19d, last: 19d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-out-of-bounds Read in bitmap_ip_add netfilter syz done done 7 1787d 1798d 15/28 fixed on 2020/03/25 19:36
upstream KASAN: slab-out-of-bounds Read in bitmap_ip_add (2) netfilter C 3 43d 39d 28/28 fixed on 2024/12/16 09:50

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in instrument_atomic_read include/linux/instrumented.h:72 [inline]
BUG: KASAN: slab-out-of-bounds in _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [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+0xdb/0x8c0 net/netfilter/ipset/ip_set_bitmap_gen.h:134
Read of size 8 at addr ffff888060612fd0 by task syz.2.2732/13663

CPU: 0 PID: 13663 Comm: syz.2.2732 Not tainted 6.1.119-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 kasan_check_range+0x27f/0x290 mm/kasan/generic.c:189
 instrument_atomic_read include/linux/instrumented.h:72 [inline]
 _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline]
 bitmap_ip_do_add net/netfilter/ipset/ip_set_bitmap_ip.c:83 [inline]
 bitmap_ip_add+0xdb/0x8c0 net/netfilter/ipset/ip_set_bitmap_gen.h:134
 bitmap_ip_uadt+0x761/0xb80 net/netfilter/ipset/ip_set_bitmap_ip.c:186
 call_ad+0x271/0xa60 net/netfilter/ipset/ip_set_core.c:1748
 ip_set_ad+0x7cf/0x980 net/netfilter/ipset/ip_set_core.c:1838
 nfnetlink_rcv_msg+0xbce/0x1160 net/netfilter/nfnetlink.c:302
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2493
 nfnetlink_rcv+0x28d/0x2600 net/netfilter/nfnetlink.c:659
 netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline]
 netlink_unicast+0x7d8/0x970 net/netlink/af_netlink.c:1337
 netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1859
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 ____sys_sendmsg+0x5a5/0x8f0 net/socket.c:2519
 ___sys_sendmsg net/socket.c:2573 [inline]
 __sys_sendmsg+0x2a9/0x390 net/socket.c:2602
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f075f97ff19
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f0760808058 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f075fb45fa0 RCX: 00007f075f97ff19
RDX: 0000000004000084 RSI: 0000000020000000 RDI: 0000000000000004
RBP: 00007f075f9f3986 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f075fb45fa0 R15: 00007ffd7e1230c8
 </TASK>

Allocated by task 7216:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:936 [inline]
 __kmalloc+0xb2/0x230 mm/slab_common.c:949
 init_map_ip net/netfilter/ipset/ip_set_bitmap_ip.c:223 [inline]
 bitmap_ip_create+0x55d/0xbf0 net/netfilter/ipset/ip_set_bitmap_ip.c:327
 ip_set_create+0xa51/0x18d0 net/netfilter/ipset/ip_set_core.c:1106
 nfnetlink_rcv_msg+0xbce/0x1160 net/netfilter/nfnetlink.c:302
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2493
 nfnetlink_rcv+0x28d/0x2600 net/netfilter/nfnetlink.c:659
 netlink_unicast_kernel net/netlink/af_netlink.c:1311 [inline]
 netlink_unicast+0x7d8/0x970 net/netlink/af_netlink.c:1337
 netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1859
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 ____sys_sendmsg+0x5a5/0x8f0 net/socket.c:2519
 ___sys_sendmsg net/socket.c:2573 [inline]
 __sys_sendmsg+0x2a9/0x390 net/socket.c:2602
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff888060612fc8
 which belongs to the cache kmalloc-8 of size 8
The buggy address is located 0 bytes to the right of
 8-byte region [ffff888060612fc8, ffff888060612fd0)

The buggy address belongs to the physical page:
page:ffffea0001818480 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x60612
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000001 ffff888017c41280
raw: 0000000000000000 0000000000660066 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 0x112c00(GFP_NOIO|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 4252, tgid 4252 (kworker/0:3), ts 194632769843, free_ts 194571289413
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4313
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5590
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:557 [inline]
 usb_control_msg+0xb7/0x4c0 drivers/usb/core/message.c:143
 get_capabilities drivers/usb/class/usbtmc.c:1821 [inline]
 usbtmc_probe+0x7bf/0x18d0 drivers/usb/class/usbtmc.c:2424
 usb_probe_interface+0x5c0/0xaf0 drivers/usb/core/driver.c:396
 really_probe+0x2ab/0xcb0 drivers/base/dd.c:639
 __driver_probe_device+0x1a2/0x3d0 drivers/base/dd.c:785
 driver_probe_device+0x50/0x420 drivers/base/dd.c:815
 __device_attach_driver+0x2cf/0x510 drivers/base/dd.c:943
 bus_for_each_drv+0x183/0x200 drivers/base/bus.c:429
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1444 [inline]
 free_pcp_prepare mm/page_alloc.c:1494 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3369
 free_unref_page_list+0x663/0x900 mm/page_alloc.c:3510
 release_pages+0x2836/0x2b40 mm/swap.c:1055
 tlb_batch_pages_flush mm/mmu_gather.c:59 [inline]
 tlb_flush_mmu_free mm/mmu_gather.c:254 [inline]
 tlb_flush_mmu+0xfc/0x210 mm/mmu_gather.c:261
 tlb_finish_mmu+0xce/0x1f0 mm/mmu_gather.c:361
 exit_mmap+0x3b3/0x980 mm/mmap.c:3246
 __mmput+0x115/0x3c0 kernel/fork.c:1200
 exit_mm+0x226/0x300 kernel/exit.c:565
 do_exit+0x9f6/0x26a0 kernel/exit.c:858
 do_group_exit+0x202/0x2b0 kernel/exit.c:1021
 __do_sys_exit_group kernel/exit.c:1032 [inline]
 __se_sys_exit_group kernel/exit.c:1030 [inline]
 __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1030
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Memory state around the buggy address:
 ffff888060612e80: fc 07 fc fc fc fc 05 fc fc fc fc 00 fc fc fc fc
 ffff888060612f00: 05 fc fc fc fc 00 fc fc fc fc 00 fc fc fc fc 00
>ffff888060612f80: fc fc fc fc 00 fc fc fc fc 00 fc fc fc fc fc fc
                                                 ^
 ffff888060613000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888060613080: fb fb fb fb fb fc fc fc fc fc fc fc fc fa fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/02 14:16 linux-6.1.y e4d90d63d385 b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: slab-out-of-bounds Read in bitmap_ip_add
* Struck through repros no longer work on HEAD.