syzbot


KASAN: slab-use-after-free Write in hash_ipport4_gc

Status: moderation: reported on 2024/02/06 01:52
Subsystems: kernel
[Documentation on labels]
Reported-by: syzbot+72e72fabc7bc24d0d357@syzkaller.appspotmail.com
First crash: 85d, last: 85d

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
BUG: KASAN: slab-use-after-free in atomic_inc include/linux/atomic/atomic-instrumented.h:435 [inline]
BUG: KASAN: slab-use-after-free in hash_ipport4_gc+0xce/0x460 net/netfilter/ipset/ip_set_hash_gen.h:572
Write of size 4 at addr ffff88801e258004 by task kworker/1:4/5126

CPU: 1 PID: 5126 Comm: kworker/1:4 Not tainted 6.8.0-rc2-syzkaller-00199-g021533194476 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Workqueue: events_power_efficient hash_ipport4_gc
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc4/0x620 mm/kasan/report.c:488
 kasan_report+0xda/0x110 mm/kasan/report.c:601
 check_region_inline mm/kasan/generic.c:183 [inline]
 kasan_check_range+0xef/0x1a0 mm/kasan/generic.c:189
 instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
 atomic_inc include/linux/atomic/atomic-instrumented.h:435 [inline]
 hash_ipport4_gc+0xce/0x460 net/netfilter/ipset/ip_set_hash_gen.h:572
 process_one_work+0x889/0x15e0 kernel/workqueue.c:2633
 process_scheduled_works kernel/workqueue.c:2706 [inline]
 worker_thread+0x8b9/0x12a0 kernel/workqueue.c:2787
 kthread+0x2c6/0x3b0 kernel/kthread.c:388
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:242
 </TASK>

Allocated by task 7869:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:314 [inline]
 __kasan_slab_alloc+0x89/0x90 mm/kasan/common.c:340
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3813 [inline]
 slab_alloc_node mm/slub.c:3860 [inline]
 kmem_cache_alloc_node+0x177/0x350 mm/slub.c:3903
 kmalloc_reserve+0x16a/0x260 net/core/skbuff.c:560
 __alloc_skb+0x12b/0x330 net/core/skbuff.c:651
 __netdev_alloc_skb+0x72/0x3f0 net/core/skbuff.c:715
 netdev_alloc_skb include/linux/skbuff.h:3235 [inline]
 dev_alloc_skb include/linux/skbuff.h:3248 [inline]
 __ieee80211_beacon_get+0xc33/0x16e0 net/mac80211/tx.c:5442
 ieee80211_beacon_get_tim+0xa7/0x280 net/mac80211/tx.c:5564
 ieee80211_beacon_get include/net/mac80211.h:5452 [inline]
 mac80211_hwsim_beacon_tx+0x3f6/0x740 drivers/net/wireless/virtual/mac80211_hwsim.c:2275
 __iterate_interfaces+0x2d2/0x580 net/mac80211/util.c:767
 ieee80211_iterate_active_interfaces_atomic+0x71/0x1b0 net/mac80211/util.c:803
 mac80211_hwsim_beacon+0x105/0x200 drivers/net/wireless/virtual/mac80211_hwsim.c:2305
 __run_hrtimer kernel/time/hrtimer.c:1688 [inline]
 __hrtimer_run_queues+0x203/0xc30 kernel/time/hrtimer.c:1752
 hrtimer_run_softirq+0x17d/0x350 kernel/time/hrtimer.c:1769
 __do_softirq+0x21c/0x8e7 kernel/softirq.c:553

Freed by task 7869:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3f/0x60 mm/kasan/generic.c:640
 poison_slab_object mm/kasan/common.c:241 [inline]
 __kasan_slab_free+0x121/0x1c0 mm/kasan/common.c:257
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2121 [inline]
 slab_free mm/slub.c:4299 [inline]
 kmem_cache_free+0x129/0x360 mm/slub.c:4363
 skb_kfree_head net/core/skbuff.c:984 [inline]
 skb_kfree_head net/core/skbuff.c:981 [inline]
 skb_free_head+0x17f/0x1b0 net/core/skbuff.c:998
 skb_release_data+0x5c0/0x880 net/core/skbuff.c:1028
 skb_release_all net/core/skbuff.c:1094 [inline]
 __kfree_skb net/core/skbuff.c:1108 [inline]
 consume_skb net/core/skbuff.c:1324 [inline]
 consume_skb+0xd2/0x170 net/core/skbuff.c:1318
 mac80211_hwsim_tx_frame+0x1f3/0x2a0 drivers/net/wireless/virtual/mac80211_hwsim.c:2187
 mac80211_hwsim_beacon_tx+0x41b/0x740 drivers/net/wireless/virtual/mac80211_hwsim.c:2279
 __iterate_interfaces+0x2d2/0x580 net/mac80211/util.c:767
 ieee80211_iterate_active_interfaces_atomic+0x71/0x1b0 net/mac80211/util.c:803
 mac80211_hwsim_beacon+0x105/0x200 drivers/net/wireless/virtual/mac80211_hwsim.c:2305
 __run_hrtimer kernel/time/hrtimer.c:1688 [inline]
 __hrtimer_run_queues+0x203/0xc30 kernel/time/hrtimer.c:1752
 hrtimer_run_softirq+0x17d/0x350 kernel/time/hrtimer.c:1769
 __do_softirq+0x21c/0x8e7 kernel/softirq.c:553

The buggy address belongs to the object at ffff88801e258000
 which belongs to the cache skbuff_small_head of size 640
The buggy address is located 4 bytes inside of
 freed 640-byte region [ffff88801e258000, ffff88801e258280)

The buggy address belongs to the physical page:
page:ffffea0000789600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1e258
head:ffffea0000789600 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff8880192e68c0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000150015 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x1f2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_MEMALLOC|__GFP_HARDWALL), pid 7869, tgid 7863 (syz-executor.3), ts 444116522636, free_ts 442727496352
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x2d4/0x350 mm/page_alloc.c:1533
 prep_new_page mm/page_alloc.c:1540 [inline]
 get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3311
 __alloc_pages+0x22f/0x2440 mm/page_alloc.c:4567
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page mm/slub.c:2190 [inline]
 allocate_slab mm/slub.c:2354 [inline]
 new_slab+0xcc/0x3a0 mm/slub.c:2407
 ___slab_alloc+0x4af/0x19a0 mm/slub.c:3540
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3625
 __slab_alloc_node mm/slub.c:3678 [inline]
 slab_alloc_node mm/slub.c:3850 [inline]
 kmem_cache_alloc_node+0x10a/0x350 mm/slub.c:3903
 kmalloc_reserve+0x16a/0x260 net/core/skbuff.c:560
 __alloc_skb+0x12b/0x330 net/core/skbuff.c:651
 __netdev_alloc_skb+0x72/0x3f0 net/core/skbuff.c:715
 netdev_alloc_skb include/linux/skbuff.h:3235 [inline]
 dev_alloc_skb include/linux/skbuff.h:3248 [inline]
 __ieee80211_beacon_get+0xc33/0x16e0 net/mac80211/tx.c:5442
 ieee80211_beacon_get_tim+0xa7/0x280 net/mac80211/tx.c:5564
 ieee80211_beacon_get include/net/mac80211.h:5452 [inline]
 mac80211_hwsim_beacon_tx+0x3f6/0x740 drivers/net/wireless/virtual/mac80211_hwsim.c:2275
 __iterate_interfaces+0x2d2/0x580 net/mac80211/util.c:767
 ieee80211_iterate_active_interfaces_atomic+0x71/0x1b0 net/mac80211/util.c:803
 mac80211_hwsim_beacon+0x105/0x200 drivers/net/wireless/virtual/mac80211_hwsim.c:2305
page last free pid 7865 tgid 7864 stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1140 [inline]
 free_unref_page_prepare+0x527/0xb10 mm/page_alloc.c:2346
 free_unref_page+0x33/0x3c0 mm/page_alloc.c:2486
 __folio_put+0xeb/0x110 mm/swap.c:127
 kvfree+0x47/0x50 mm/util.c:663
 hash_ipport4_destroy+0xae/0x3a0 net/netfilter/ipset/ip_set_hash_gen.h:455
 ip_set_create+0xd9f/0x1360 net/netfilter/ipset/ip_set_core.c:1157
 nfnetlink_rcv_msg+0x9c3/0x11e0 net/netfilter/nfnetlink.c:302
 netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2543
 nfnetlink_rcv+0x1b4/0x430 net/netfilter/nfnetlink.c:659
 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
 netlink_unicast+0x542/0x820 net/netlink/af_netlink.c:1367
 netlink_sendmsg+0x8bb/0xd70 net/netlink/af_netlink.c:1908
 sock_sendmsg_nosec net/socket.c:730 [inline]
 __sock_sendmsg net/socket.c:745 [inline]
 ____sys_sendmsg+0xab5/0xc90 net/socket.c:2584
 ___sys_sendmsg+0x135/0x1e0 net/socket.c:2638
 __sys_sendmsg+0x117/0x1f0 net/socket.c:2667
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x6f/0x77

Memory state around the buggy address:
 ffff88801e257f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88801e257f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88801e258000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88801e258080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801e258100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/02/02 01:50 upstream 021533194476 81024119 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Write in hash_ipport4_gc
* Struck through repros no longer work on HEAD.