[moderation] [net?] KCSAN: data-race in bpf_map_copy_value / bpf_prog_run_clear_cb

0 views
Skip to first unread message

syzbot

unread,
7:05 PM (1 hour ago) 7:05 PM
to syzkaller-upst...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 666539eecdf4 Merge tag 'assoc-array-fixes-v2'
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1571ce4d580000
kernel config: https://syzkaller.appspot.com/x/.config?x=b949a9d3c1d44ceb
dashboard link: https://syzkaller.appspot.com/bug?extid=e2387bdd52c8babb3419
compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
CC: [da...@davemloft.net edum...@kernel.org ho...@kernel.org ku...@kernel.org linux-...@vger.kernel.org net...@vger.kernel.org pab...@redhat.com willemdebr...@gmail.com]

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/a943b9915869/disk-666539ee.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/9bfd839d7ea5/vmlinux-666539ee.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0f20b9720a71/bzImage-666539ee.xz

AI-generated root cause summary:
In __migrate_disable() (inlined in include/linux/sched.h), guard(preempt)() is
used to disable preemption while modifying the runqueue counter this_rq_pinned()
(rq->nr_pinned). However, disabling preemption does not mask interrupts or
softirqs. If a hardware interrupt arrives on the same CPU while a task is
running __migrate_disable() (e.g. from bpf_disable_instrumentation()), softirq
handling can invoke BPF socket filter helpers like bpf_prog_run_pin_on_cpu(),
which also call migrate_disable() on the interrupted task. This causes
reentrant, unsynchronized read-modify-write accesses to rq->nr_pinned,
triggering a KCSAN data-race warning.

full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=e2387bdd52c8babb3419

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

==================================================================
BUG: KCSAN: data-race in bpf_map_copy_value / bpf_prog_run_clear_cb

read-write to 0xffff888237c2ccf0 of 4 bytes by interrupt on cpu 0:
__migrate_disable include/linux/sched.h:2495 [inline]
migrate_disable include/linux/sched.h:2512 [inline]
bpf_prog_run_pin_on_cpu include/linux/filter.h:836 [inline]
bpf_prog_run_clear_cb+0xa3/0x290 include/linux/filter.h:1119
run_filter net/packet/af_packet.c:2111 [inline]
packet_rcv+0x26e/0xba0 net/packet/af_packet.c:2184
deliver_skb+0x10b/0x170 net/core/dev.c:2564
deliver_ptype_list_skb net/core/dev.c:2579 [inline]
__netif_receive_skb_core+0x13e0/0x19a0 net/core/dev.c:6391
__netif_receive_skb_list_core+0x112/0x520 net/core/dev.c:6522
__netif_receive_skb_list net/core/dev.c:6589 [inline]
netif_receive_skb_list_internal+0x471/0x5e0 net/core/dev.c:6680
gro_normal_list include/net/gro.h:539 [inline]
gro_flush_normal include/net/gro.h:547 [inline]
napi_complete_done+0x19c/0x410 net/core/dev.c:7048
virtqueue_napi_complete drivers/net/virtio_net.c:736 [inline]
virtnet_poll+0x1a9a/0x1f60 drivers/net/virtio_net.c:3048
__napi_poll+0x73/0x350 net/core/dev.c:7997
napi_poll net/core/dev.c:8060 [inline]
net_rx_action+0x33f/0x850 net/core/dev.c:8217
handle_softirqs+0x109/0x310 kernel/softirq.c:669
__do_softirq kernel/softirq.c:703 [inline]
invoke_softirq kernel/softirq.c:542 [inline]
__irq_exit_rcu+0x40/0xf0 kernel/softirq.c:786
common_interrupt+0x83/0x90 arch/x86/kernel/irq.c:273
asm_common_interrupt+0x26/0x40 arch/x86/include/asm/idtentry.h:665
native_pause arch/x86/include/asm/vdso/processor.h:13 [inline]
delay_tsc+0x43/0xa0 arch/x86/lib/delay.c:76
udelay include/asm-generic/delay.h:64 [inline]
delay_access kernel/kcsan/core.c:332 [inline]
kcsan_setup_watchpoint+0x255/0x3f0 kernel/kcsan/core.c:622
__migrate_disable include/linux/sched.h:2495 [inline]
migrate_disable include/linux/sched.h:2512 [inline]
bpf_disable_instrumentation include/linux/bpf.h:2875 [inline]
bpf_map_copy_value+0xc5/0x500 kernel/bpf/syscall.c:317
generic_map_lookup_batch+0x674/0x980 kernel/bpf/syscall.c:2192
bpf_map_do_batch+0x1cb/0x3b0 kernel/bpf/syscall.c:5845
__sys_bpf+0x4c1/0xc50 kernel/bpf/syscall.c:-1
__do_sys_bpf kernel/bpf/syscall.c:6582 [inline]
__se_sys_bpf kernel/bpf/syscall.c:6579 [inline]
__x64_sys_bpf+0x69/0x80 kernel/bpf/syscall.c:6579
x64_sys_call+0xf26/0x2550 arch/x86/include/generated/asm/syscalls_64.h:322
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f

read-write to 0xffff888237c2ccf0 of 4 bytes by task 4653 on cpu 0:
__migrate_disable include/linux/sched.h:2495 [inline]
migrate_disable include/linux/sched.h:2512 [inline]
bpf_disable_instrumentation include/linux/bpf.h:2875 [inline]
bpf_map_copy_value+0xc5/0x500 kernel/bpf/syscall.c:317
generic_map_lookup_batch+0x674/0x980 kernel/bpf/syscall.c:2192
bpf_map_do_batch+0x1cb/0x3b0 kernel/bpf/syscall.c:5845
__sys_bpf+0x4c1/0xc50 kernel/bpf/syscall.c:-1
__do_sys_bpf kernel/bpf/syscall.c:6582 [inline]
__se_sys_bpf kernel/bpf/syscall.c:6579 [inline]
__x64_sys_bpf+0x69/0x80 kernel/bpf/syscall.c:6579
x64_sys_call+0xf26/0x2550 arch/x86/include/generated/asm/syscalls_64.h:322
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x11e/0x3a0 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f

Reported by Kernel Concurrency Sanitizer on:
CPU: 0 UID: 0 PID: 4653 Comm: syz.4.476 Not tainted syzkaller #0 PREEMPT(lazy)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================


---
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 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
Reply all
Reply to author
Forward
0 new messages