[syzbot] [net?] [bpf?] KASAN: slab-use-after-free Read in __sk_msg_recvmsg

2 views
Skip to first unread message

syzbot

unread,
Apr 1, 2026, 8:49:24 PMĀ (7 hours ago)Ā Apr 1
to and...@kernel.org, a...@kernel.org, b...@vger.kernel.org, dan...@iogearbox.net, da...@davemloft.net, edum...@google.com, ho...@kernel.org, ja...@cloudflare.com, john.fa...@gmail.com, ku...@kernel.org, linux-...@vger.kernel.org, net...@vger.kernel.org, pab...@redhat.com, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 93d04e76bcf1 Merge branch 'r8152-add-helper-functions-for-..
git tree: net-next
console output: https://syzkaller.appspot.com/x/log.txt?x=14fde46a580000
kernel config: https://syzkaller.appspot.com/x/.config?x=71d49d824b43a0d9
dashboard link: https://syzkaller.appspot.com/bug?extid=431f9a9e3f5227fbb904
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11b9baba580000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=152c5e26580000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/953c48b40f73/disk-93d04e76.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/edb39d99bd41/vmlinux-93d04e76.xz
kernel image: https://storage.googleapis.com/syzbot-assets/656d4ad35e4a/bzImage-93d04e76.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+431f9a...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: slab-use-after-free in __sk_msg_recvmsg+0x19b/0xe70 net/core/skmsg.c:431
Read of size 8 at addr ffff88807eeac2b0 by task syz.0.31/6071

CPU: 0 UID: 0 PID: 6071 Comm: syz.0.31 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
Call Trace:
<TASK>
dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:378 [inline]
print_report+0xba/0x230 mm/kasan/report.c:482
kasan_report+0x117/0x150 mm/kasan/report.c:595
__sk_msg_recvmsg+0x19b/0xe70 net/core/skmsg.c:431
udp_bpf_recvmsg+0x196/0xac0 net/ipv4/udp_bpf.c:83
sock_recvmsg_nosec net/socket.c:1071 [inline]
sock_recvmsg+0x155/0x1b0 net/socket.c:1093
____sys_recvmsg+0x1e6/0x4a0 net/socket.c:2805
___sys_recvmsg+0x215/0x590 net/socket.c:2847
do_recvmmsg+0x334/0x800 net/socket.c:2942
__sys_recvmmsg net/socket.c:3016 [inline]
__do_sys_recvmmsg net/socket.c:3039 [inline]
__se_sys_recvmmsg net/socket.c:3032 [inline]
__x64_sys_recvmmsg+0x198/0x250 net/socket.c:3032
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4a3579c819
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f4a365f2028 EFLAGS: 00000246 ORIG_RAX: 000000000000012b
RAX: ffffffffffffffda RBX: 00007f4a35a16180 RCX: 00007f4a3579c819
RDX: 0000000000000012 RSI: 0000200000000400 RDI: 0000000000000003
RBP: 00007f4a35832c91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000040000021 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f4a35a16218 R14: 00007f4a35a16180 R15: 00007ffda3b0e6c8
</TASK>

Allocated by task 6069:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
__kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
kasan_kmalloc include/linux/kasan.h:263 [inline]
__kmalloc_cache_noprof+0x31c/0x660 mm/slub.c:5380
kmalloc_noprof include/linux/slab.h:950 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
alloc_sk_msg net/core/skmsg.c:525 [inline]
sk_psock_skb_ingress_self+0x5e/0x370 net/core/skmsg.c:627
sk_psock_verdict_apply net/core/skmsg.c:1062 [inline]
sk_psock_verdict_recv+0x7d9/0x8d0 net/core/skmsg.c:1260
udp_read_skb+0x5d9/0x6b0 net/ipv4/udp.c:2014
sk_psock_verdict_data_ready+0x12d/0x590 net/core/skmsg.c:1281
__udp_enqueue_schedule_skb+0xc4b/0x12e0 net/ipv4/udp.c:1745
__udp_queue_rcv_skb net/ipv4/udp.c:2311 [inline]
udp_queue_rcv_one_skb+0x831/0x1230 net/ipv4/udp.c:2401
__udp4_lib_mcast_deliver+0xad7/0xb70 net/ipv4/udp.c:2513
udp_rcv+0xcc2/0x24c0 net/ipv4/udp.c:2638
ip_protocol_deliver_rcu+0x282/0x440 net/ipv4/ip_input.c:207
ip_local_deliver_finish+0x3bb/0x6f0 net/ipv4/ip_input.c:241
NF_HOOK+0x336/0x3c0 include/linux/netfilter.h:318
dst_input include/net/dst.h:480 [inline]
ip_sublist_rcv_finish+0x1f0/0x240 net/ipv4/ip_input.c:623
ip_list_rcv_finish net/ipv4/ip_input.c:667 [inline]
ip_sublist_rcv+0x5c6/0xa70 net/ipv4/ip_input.c:683
ip_list_rcv+0x3f1/0x450 net/ipv4/ip_input.c:717
__netif_receive_skb_list_ptype net/core/dev.c:6233 [inline]
__netif_receive_skb_list_core+0x7e5/0x810 net/core/dev.c:6280
__netif_receive_skb_list net/core/dev.c:6332 [inline]
netif_receive_skb_list_internal+0x995/0xcf0 net/core/dev.c:6423
netif_receive_skb_list+0x55/0x4b0 net/core/dev.c:6475
xdp_recv_frames net/bpf/test_run.c:269 [inline]
xdp_test_run_batch net/bpf/test_run.c:350 [inline]
bpf_test_run_xdp_live+0x1946/0x1cf0 net/bpf/test_run.c:379
bpf_prog_test_run_xdp+0x81c/0x1160 net/bpf/test_run.c:1397
bpf_prog_test_run+0x2c7/0x340 kernel/bpf/syscall.c:4722
__sys_bpf+0x643/0x950 kernel/bpf/syscall.c:6246
__do_sys_bpf kernel/bpf/syscall.c:6341 [inline]
__se_sys_bpf kernel/bpf/syscall.c:6339 [inline]
__x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:6339
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 6070:
kasan_save_stack mm/kasan/common.c:57 [inline]
kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
poison_slab_object mm/kasan/common.c:253 [inline]
__kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
kasan_slab_free include/linux/kasan.h:235 [inline]
slab_free_hook mm/slub.c:2685 [inline]
slab_free mm/slub.c:6165 [inline]
kfree+0x1c1/0x630 mm/slub.c:6483
kfree_sk_msg include/linux/skmsg.h:418 [inline]
__sk_msg_recvmsg+0xc7e/0xe70 net/core/skmsg.c:491
udp_bpf_recvmsg+0x196/0xac0 net/ipv4/udp_bpf.c:83
sock_recvmsg_nosec net/socket.c:1071 [inline]
sock_recvmsg+0x155/0x1b0 net/socket.c:1093
____sys_recvmsg+0x1e6/0x4a0 net/socket.c:2805
___sys_recvmsg+0x215/0x590 net/socket.c:2847
do_recvmmsg+0x334/0x800 net/socket.c:2942
__sys_recvmmsg net/socket.c:3016 [inline]
__do_sys_recvmmsg net/socket.c:3039 [inline]
__se_sys_recvmmsg net/socket.c:3032 [inline]
__x64_sys_recvmmsg+0x198/0x250 net/socket.c:3032
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88807eeac000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 688 bytes inside of
freed 1024-byte region [ffff88807eeac000, ffff88807eeac400)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7eea8
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88813fea6dc0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000040 ffff88813fea6dc0 dead000000000100 dead000000000122
head: 0000000000000000 0000000800100010 00000000f5000000 0000000000000000
head: 00fff00000000003 ffffea0001fbaa01 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 176, tgid 176 (kworker/u8:7), ts 108779589894, free_ts 108254079914
set_page_owner include/linux/page_owner.h:32 [inline]
post_alloc_hook+0x231/0x280 mm/page_alloc.c:1889
prep_new_page mm/page_alloc.c:1897 [inline]
get_page_from_freelist+0x24dc/0x2580 mm/page_alloc.c:3962
__alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5250
alloc_slab_page mm/slub.c:3292 [inline]
allocate_slab+0x77/0x660 mm/slub.c:3481
new_slab mm/slub.c:3539 [inline]
refill_objects+0x331/0x3c0 mm/slub.c:7175
refill_sheaf mm/slub.c:2812 [inline]
__pcs_replace_empty_main+0x2e6/0x730 mm/slub.c:4615
alloc_from_pcs mm/slub.c:4717 [inline]
slab_alloc_node mm/slub.c:4851 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kmalloc_noprof+0x474/0x760 mm/slub.c:5272
kmalloc_noprof include/linux/slab.h:954 [inline]
kzalloc_noprof include/linux/slab.h:1188 [inline]
ieee802_11_parse_elems_full+0x159/0x2ab0 net/mac80211/parse.c:1051
ieee802_11_parse_elems net/mac80211/ieee80211_i.h:2496 [inline]
ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1565 [inline]
ieee80211_ibss_rx_queued_mgmt+0x4ca/0x2ce0 net/mac80211/ibss.c:1596
ieee80211_iface_process_skb net/mac80211/iface.c:1757 [inline]
ieee80211_iface_work+0x845/0x1380 net/mac80211/iface.c:1811
cfg80211_wiphy_work+0x2ab/0x4a0 net/wireless/core.c:513
process_one_work kernel/workqueue.c:3276 [inline]
process_scheduled_works+0xb6e/0x18c0 kernel/workqueue.c:3359
worker_thread+0xa53/0xfc0 kernel/workqueue.c:3440
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
page last free pid 6064 tgid 6061 stack trace:
reset_page_owner include/linux/page_owner.h:25 [inline]
__free_pages_prepare mm/page_alloc.c:1433 [inline]
__free_frozen_pages+0xc2b/0xdb0 mm/page_alloc.c:2978
__slab_free+0x263/0x2b0 mm/slub.c:5573
qlink_free mm/kasan/quarantine.c:163 [inline]
qlist_free_all+0x97/0x100 mm/kasan/quarantine.c:179
kasan_quarantine_reduce+0x148/0x160 mm/kasan/quarantine.c:286
__kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:350
kasan_slab_alloc include/linux/kasan.h:253 [inline]
slab_post_alloc_hook mm/slub.c:4538 [inline]
slab_alloc_node mm/slub.c:4866 [inline]
__do_kmalloc_node mm/slub.c:5259 [inline]
__kmalloc_noprof+0x316/0x760 mm/slub.c:5272
kmalloc_noprof include/linux/slab.h:954 [inline]
iovec_from_user+0x87/0x250 lib/iov_iter.c:1321
__import_iovec+0x163/0x7e0 lib/iov_iter.c:1375
import_iovec+0x73/0xa0 lib/iov_iter.c:1440
copy_msghdr_from_user net/socket.c:2522 [inline]
recvmsg_copy_msghdr net/socket.c:2771 [inline]
___sys_recvmsg+0x4bd/0x590 net/socket.c:2843
do_recvmmsg+0x334/0x800 net/socket.c:2942
__sys_recvmmsg net/socket.c:3016 [inline]
__do_sys_recvmmsg net/socket.c:3039 [inline]
__se_sys_recvmmsg net/socket.c:3032 [inline]
__x64_sys_recvmmsg+0x198/0x250 net/socket.c:3032
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x14d/0xf80 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
ffff88807eeac180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807eeac200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807eeac280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807eeac300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807eeac380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Apr 1, 2026, 10:16:53 PMĀ (5 hours ago)Ā Apr 1
to linux-...@vger.kernel.org, syzkall...@googlegroups.com
For archival purposes, forwarding an incoming command email to
linux-...@vger.kernel.org, syzkall...@googlegroups.com.

***

Subject: [PATCH] udp_bpf: fix use-after-free in udp_bpf_recvmsg()
Author: karti...@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main


udp_bpf_recvmsg() calls sk_msg_recvmsg() without holding lock_sock(),
unlike tcp_bpf_recvmsg() which properly acquires lock_sock() before
calling __sk_msg_recvmsg(). This allows concurrent tasks to race inside
sk_msg_recvmsg() on the same psock ingress queue, where one task can
free msg_rx via kfree_sk_msg() while another task is still reading it
via sk_msg_elem(), causing a slab-use-after-free.

Fix this by adding lock_sock()/release_sock() pairs around the recvmsg
path. Since udp_msg_wait_data() does not release lock_sock() internally
before sleeping (unlike tcp_msg_wait_data()), we must release the socket
lock manually before calling udp_msg_wait_data() and reacquire it after
to avoid a deadlock with the ingress path delivering new data.

Reported-by: syzbot+431f9a...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=431f9a9e3f5227fbb904
Fixes: 1f5be6b3b063 ("udp: Implement udp_bpf_recvmsg() for sockmap")
Signed-off-by: Deepanshu Kartikey <karti...@gmail.com>
---
net/ipv4/udp_bpf.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/net/ipv4/udp_bpf.c b/net/ipv4/udp_bpf.c
index 9f33b07b1481..5e6d82816103 100644
--- a/net/ipv4/udp_bpf.c
+++ b/net/ipv4/udp_bpf.c
@@ -74,7 +74,9 @@ static int udp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
if (unlikely(!psock))
return sk_udp_recvmsg(sk, msg, len, flags);

+ lock_sock(sk);
if (!psock_has_data(psock)) {
+ release_sock(sk);
ret = sk_udp_recvmsg(sk, msg, len, flags);
goto out;
}
@@ -86,16 +88,20 @@ static int udp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
int data;

timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
+ release_sock(sk);
data = udp_msg_wait_data(sk, psock, timeo);
+ lock_sock(sk);
if (data) {
if (psock_has_data(psock))
goto msg_bytes_ready;
+ release_sock(sk);
ret = sk_udp_recvmsg(sk, msg, len, flags);
goto out;
}
copied = -EAGAIN;
}
ret = copied;
+ release_sock(sk);
out:
sk_psock_put(sk, psock);
return ret;
--
2.43.0

syzbot

unread,
Apr 1, 2026, 11:39:04 PMĀ (4 hours ago)Ā Apr 1
to karti...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in inet_sock_destruct

------------[ cut here ]------------
sk->sk_forward_alloc
WARNING: net/ipv4/af_inet.c:162 at inet_sock_destruct+0x62d/0x740 net/ipv4/af_inet.c:162, CPU#1: ksoftirqd/1/23
Modules linked in:
CPU: 1 UID: 0 PID: 23 Comm: ksoftirqd/1 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
RIP: 0010:inet_sock_destruct+0x62d/0x740 net/ipv4/af_inet.c:162
Code: 0f 0b 90 e9 58 fe ff ff e8 50 dd 9e f7 90 0f 0b 90 e9 8b fe ff ff e8 42 dd 9e f7 90 0f 0b 90 e9 b1 fe ff ff e8 34 dd 9e f7 90 <0f> 0b 90 e9 d7 fe ff ff 89 f9 80 e1 07 80 c1 03 38 c1 0f 8c 95 fc
RSP: 0018:ffffc900001d7ae8 EFLAGS: 00010246
RAX: ffffffff8a26d13c RBX: dffffc0000000000 RCX: ffff88801daf8000
RDX: 0000000000000100 RSI: 0000000000000090 RDI: 0000000000000000
RBP: 0000000000000090 R08: ffff88801bffcf27 R09: 1ffff110037ff9e4
R10: dffffc0000000000 R11: ffffed10037ff9e5 R12: ffff88801bffcc80
R13: dffffc0000000000 R14: ffff88801bffcf0c R15: ffffffff8fca6c00
FS: 0000000000000000(0000) GS:ffff888125557000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fdb873e9f00 CR3: 000000000e54c000 CR4: 00000000003526f0
Call Trace:
<TASK>
__sk_destruct+0x85/0x880 net/core/sock.c:2350
rcu_do_batch kernel/rcu/tree.c:2617 [inline]
rcu_core+0x7cd/0x1070 kernel/rcu/tree.c:2869
handle_softirqs+0x22a/0x870 kernel/softirq.c:622
run_ksoftirqd+0x36/0x60 kernel/softirq.c:1063
smpboot_thread_fn+0x541/0xa50 kernel/smpboot.c:160
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x51e/0xb90 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>


Tested on:

commit: a77fb1ac Octeontx2-af: add WQ_PERCPU to alloc_workqueu..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main
console output: https://syzkaller.appspot.com/x/log.txt?x=137ed5da580000
kernel config: https://syzkaller.appspot.com/x/.config?x=71d49d824b43a0d9
dashboard link: https://syzkaller.appspot.com/bug?extid=431f9a9e3f5227fbb904
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=143bf0f2580000

syzbot

unread,
12:28 AMĀ (3 hours ago)Ā 12:28 AM
to linux-...@vger.kernel.org, syzkall...@googlegroups.com
For archival purposes, forwarding an incoming command email to
linux-...@vger.kernel.org, syzkall...@googlegroups.com.

***

Subject: [PATCH] udp_bpf: fix use-after-free in udp_bpf_recvmsg()
Author: karti...@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git main

udp_bpf_recvmsg() calls sk_msg_recvmsg() without holding lock_sock(),
unlike tcp_bpf_recvmsg() which properly acquires lock_sock() before
calling __sk_msg_recvmsg(). This allows concurrent tasks to race inside
sk_msg_recvmsg() on the same psock ingress queue, where one task can
free msg_rx via kfree_sk_msg() while another task is still reading it
via sk_msg_elem(), causing a slab-use-after-free.

Fix this by adding lock_sock()/release_sock() around the sk_msg_recvmsg()
path in udp_bpf_recvmsg(), consistent with tcp_bpf_recvmsg(). Also make
udp_msg_wait_data() release lock_sock() before sleeping and reacquire it
after waking, so it can be called with the socket lock held, consistent
with how tcp_msg_wait_data() uses sk_wait_event() which does the same
internally.

Reported-by: syzbot+431f9a...@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=431f9a9e3f5227fbb904
Fixes: 1f5be6b3b063 ("udp: Implement udp_bpf_recvmsg() for sockmap")
Signed-off-by: Deepanshu Kartikey <karti...@gmail.com>
---
net/ipv4/udp_bpf.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/net/ipv4/udp_bpf.c b/net/ipv4/udp_bpf.c
index 9f33b07b1481..f924b255cee6 100644
--- a/net/ipv4/udp_bpf.c
+++ b/net/ipv4/udp_bpf.c
@@ -50,7 +50,9 @@ static int udp_msg_wait_data(struct sock *sk, struct sk_psock *psock,
sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
ret = udp_msg_has_data(sk, psock);
if (!ret) {
+ release_sock(sk);
wait_woken(&wait, TASK_INTERRUPTIBLE, timeo);
+ lock_sock(sk);
ret = udp_msg_has_data(sk, psock);
}
sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
@@ -79,6 +81,7 @@ static int udp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
goto out;
}

+ lock_sock(sk);
msg_bytes_ready:
copied = sk_msg_recvmsg(sk, psock, msg, len, flags);
if (!copied) {
@@ -90,12 +93,14 @@ static int udp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,

syzbot

unread,
1:01 AMĀ (2 hours ago)Ā 1:01 AM
to karti...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in inet_sock_destruct

------------[ cut here ]------------
sk->sk_forward_alloc
WARNING: net/ipv4/af_inet.c:162 at inet_sock_destruct+0x62d/0x740 net/ipv4/af_inet.c:162, CPU#0: swapper/0/0
Modules linked in:
CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/18/2026
RIP: 0010:inet_sock_destruct+0x62d/0x740 net/ipv4/af_inet.c:162
Code: 0f 0b 90 e9 58 fe ff ff e8 50 dd 9e f7 90 0f 0b 90 e9 8b fe ff ff e8 42 dd 9e f7 90 0f 0b 90 e9 b1 fe ff ff e8 34 dd 9e f7 90 <0f> 0b 90 e9 d7 fe ff ff 89 f9 80 e1 07 80 c1 03 38 c1 0f 8c 95 fc
RSP: 0018:ffffc90000007d48 EFLAGS: 00010246
RAX: ffffffff8a26d13c RBX: dffffc0000000000 RCX: ffffffff8e494ec0
RDX: 0000000000000100 RSI: 0000000000000090 RDI: 0000000000000000
RBP: 0000000000000090 R08: ffff88801d7bf9a7 R09: 1ffff11003af7f34
R10: dffffc0000000000 R11: ffffed1003af7f35 R12: ffff88801d7bf700
R13: dffffc0000000000 R14: ffff88801d7bf98c R15: ffffffff8fca6c00
FS: 0000000000000000(0000) GS:ffff888125457000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000000e54c000 CR4: 00000000003526f0
Call Trace:
<IRQ>
__sk_destruct+0x85/0x880 net/core/sock.c:2350
rcu_do_batch kernel/rcu/tree.c:2617 [inline]
rcu_core+0x7cd/0x1070 kernel/rcu/tree.c:2869
handle_softirqs+0x22a/0x870 kernel/softirq.c:622
__do_softirq kernel/softirq.c:656 [inline]
invoke_softirq kernel/softirq.c:496 [inline]
__irq_exit_rcu+0x5f/0x150 kernel/softirq.c:723
irq_exit_rcu+0x9/0x30 kernel/softirq.c:739
instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1056 [inline]
sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1056
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:697
RIP: 0010:pv_native_safe_halt+0xf/0x20 arch/x86/kernel/paravirt.c:63
Code: 2e 6d 02 c3 cc cc cc cc cc cc cc 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 66 90 0f 00 2d e3 42 18 00 fb f4 <e9> fc e9 02 00 cc cc cc cc cc cc cc cc cc cc cc cc 90 90 90 90 90
RSP: 0018:ffffffff8e407dc0 EFLAGS: 00000246
RAX: 0000000000104be1 RBX: ffffffff819a913a RCX: 0000000080000001
RDX: 0000000000000001 RSI: ffffffff8df2727a RDI: ffffffff8c27ca80
RBP: ffffffff8e407eb0 R08: ffff8880b863399b R09: 1ffff110170c6733
R10: dffffc0000000000 R11: ffffed10170c6734 R12: 0000000000000000
R13: 1ffffffff1c929d8 R14: 0000000000000000 R15: 1ffffffff1c929d8
arch_safe_halt arch/x86/kernel/process.c:766 [inline]
default_idle+0x9/0x20 arch/x86/kernel/process.c:767
default_idle_call+0x72/0xb0 kernel/sched/idle.c:122
cpuidle_idle_call kernel/sched/idle.c:199 [inline]
do_idle+0x36a/0x5f0 kernel/sched/idle.c:352
cpu_startup_entry+0x43/0x60 kernel/sched/idle.c:451
rest_init+0x2de/0x300 init/main.c:760
start_kernel+0x385/0x3d0 init/main.c:1210
x86_64_start_reservations+0x24/0x30 arch/x86/kernel/head64.c:310
x86_64_start_kernel+0x143/0x1c0 arch/x86/kernel/head64.c:291
common_startup_64+0x13e/0x147
</TASK>
----------------
Code disassembly (best guess):
0: 2e 6d cs insl (%dx),%es:(%rdi)
2: 02 c3 add %bl,%al
4: cc int3
5: cc int3
6: cc int3
7: cc int3
8: cc int3
9: cc int3
a: cc int3
b: 90 nop
c: 90 nop
d: 90 nop
e: 90 nop
f: 90 nop
10: 90 nop
11: 90 nop
12: 90 nop
13: 90 nop
14: 90 nop
15: 90 nop
16: 90 nop
17: 90 nop
18: 90 nop
19: 90 nop
1a: 90 nop
1b: f3 0f 1e fa endbr64
1f: 66 90 xchg %ax,%ax
21: 0f 00 2d e3 42 18 00 verw 0x1842e3(%rip) # 0x18430b
28: fb sti
29: f4 hlt
* 2a: e9 fc e9 02 00 jmp 0x2ea2b <-- trapping instruction
2f: cc int3
30: cc int3
31: cc int3
32: cc int3
33: cc int3
34: cc int3
35: cc int3
36: cc int3
37: cc int3
38: cc int3
39: cc int3
3a: cc int3
3b: 90 nop
3c: 90 nop
3d: 90 nop
3e: 90 nop
3f: 90 nop


Tested on:

commit: cee10a01 net: macb: fix use of at91_default_usrio with..
console output: https://syzkaller.appspot.com/x/log.txt?x=1664d4d2580000
kernel config: https://syzkaller.appspot.com/x/.config?x=71d49d824b43a0d9
dashboard link: https://syzkaller.appspot.com/bug?extid=431f9a9e3f5227fbb904
compiler: Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch: https://syzkaller.appspot.com/x/patch.diff?x=176d65da580000

Reply all
Reply to author
Forward
0 new messages