KCSAN: data-race in bpf_map_update_value / bpf_sk_storage_free
Subsystems (2)
syzbot
syzbotHello,
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=12be594d580000 kernel config: https://syzkaller.appspot.com/x/.config?x=b949a9d3c1d44ceb dashboard link: https://syzkaller.appspot.com/bug?extid=30dc80192107a6515bb5 compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
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:
A KCSAN data race occurs between task context and softirq context on the 2-byte field current->migration_disabled. While a syscall thread in bpf_map_update_value() calls migrate_disable() -> __migrate_disable(), it disables preemption via guard(preempt)() and performs a plain store to current->migration_disabled = 1. Preempt disable does not mask hardware interrupts, allowing a timer interrupt on the same CPU to run softirq RCU callbacks on irq exit, which invokes socket destruction (__sk_destruct() -> bpf_sk_storage_free()). In bpf_sk_storage_free(), rcu_read_lock_dont_migrate() unnecessarily invokes migrate_disable() in softirq context, re-entering __migrate_disable() and reading current->migration_disabled concurrently with the interrupted plain store.
full analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=30dc80192107a6515bb5
IMPORTANT: if you fix the issue, please add the following tag to the commit:
==================================================================
BUG: KCSAN: data-race in bpf_map_update_value / bpf_sk_storage_free
read to 0xffff888101d295b8 of 2 bytes by interrupt on cpu 1:
__migrate_disable include/linux/sched.h:2483 [inline] migrate_disable include/linux/sched.h:2512 [inline] rcu_read_lock_dont_migrate include/linux/rcupdate.h:990 [inline] bpf_sk_storage_free+0x2b/0x210 net/core/bpf_sk_storage.c:52 __sk_destruct+0x12e/0x4d0 net/core/sock.c:2398 sk_destruct net/core/sock.c:2448 [inline] __sk_free+0x23c/0x280 net/core/sock.c:2459 sk_free+0x55/0x90 net/core/sock.c:2470 deferred_put_nlk_sk+0x89/0xc0 net/netlink/af_netlink.c:712 rcu_do_batch kernel/rcu/tree.c:2650 [inline] rcu_core+0x76e/0xcb0 kernel/rcu/tree.c:2919 rcu_core_si+0xd/0x20 kernel/rcu/tree.c:2936 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 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline] sysvec_apic_timer_interrupt+0x74/0x80 arch/x86/kernel/apic/apic.c:1062 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674 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:2496 [inline] migrate_disable include/linux/sched.h:2512 [inline] bpf_disable_instrumentation include/linux/bpf.h:2875 [inline] bpf_map_update_value+0x1cf/0x570 kernel/bpf/syscall.c:270 generic_map_update_batch+0x4e6/0x700 kernel/bpf/syscall.c:2125 bpf_map_do_batch+0x26a/0x3b0 kernel/bpf/syscall.c:5849 __sys_bpf+0x784/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
write to 0xffff888101d295b8 of 2 bytes by task 12002 on cpu 1:
__migrate_disable include/linux/sched.h:2496 [inline] migrate_disable include/linux/sched.h:2512 [inline] bpf_disable_instrumentation include/linux/bpf.h:2875 [inline] bpf_map_update_value+0x1cf/0x570 kernel/bpf/syscall.c:270 generic_map_update_batch+0x4e6/0x700 kernel/bpf/syscall.c:2125 bpf_map_do_batch+0x26a/0x3b0 kernel/bpf/syscall.c:5849 __sys_bpf+0x784/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: 1 UID: 0 PID: 12002 Comm: syz.0.4076 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 [email protected].
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