KCSAN: data-race in bpf_sk_storage_free / bpf_sk_storage_free

Status: moderation: reported on 2026/11/23 18:36
Subsystems: net
Labels: prio:high race:benign
[Documentation on labels]
Reported-by: syzbot+cd85d7348d002309b827@syzkaller.appspotmail.com
First crash: 6d17h, last: 6d01h
✨ AI-generated root cause summary:

KCSAN (with CONFIG_KCSAN_INTERRUPT_WATCHER=y) reports a data race on current->migration_disabled between __migrate_enable() in task context and __migrate_disable() in an RCU softirq on the same CPU, both invoked from bpf_sk_storage_free() via rcu_read_unlock_migrate() and rcu_read_lock_dont_migrate(). __migrate_enable() and __migrate_disable() in include/linux/sched.h access task_struct::migration_disabled using plain C reads and writes rather than READ_ONCE()/WRITE_ONCE() or data_race() annotations. Because interrupts on the same CPU always balance their migrate_disable()/migrate_enable() calls before returning, this race is benign and causes no functional or memory-safety issue.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 666539eecdf4:

Technical Root Cause Analysis

The KCSAN report captures a same-CPU data race on task_struct::migration_disabled (unsigned short, 2 bytes at 0xffff8881037ca6f8) between task context and an interrupt/softirq handler running on CPU 1:

  1. Task context read (include/linux/sched.h:2457): While closing a TCP socket (tcp_close() -> __sk_free() -> sk_destruct() -> __sk_destruct()), bpf_sk_storage_free() (net/core/bpf_sk_storage.c:47) brackets its execution with rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate() (include/linux/rcupdate.h:986,994). With CONFIG_PREEMPT_RCU=y, these call migrate_disable() and migrate_enable(), which inline __migrate_disable() and __migrate_enable() (include/linux/sched.h:2444-2497). Inside __migrate_enable() (at line 2457), task 3294 performs a plain read of p->migration_disabled (if (p->migration_disabled > 1)), where p == current and p->migration_disabled == 1.

  2. Interrupt/softirq write (include/linux/sched.h:2490): Because CONFIG_KCSAN_INTERRUPT_WATCHER=y (enabled via CONFIG_KCSAN_STRICT=y), kcsan_setup_watchpoint() in kernel/kcsan/core.c:589 does not disable interrupts while stalling in delay_access(). An APIC timer interrupt fires on CPU 1 and runs softirqs via __irq_exit_rcu() -> invoke_softirq() -> __do_softirq() -> rcu_core() -> rcu_do_batch(). An RCU callback (sctp_endpoint_destroy_rcu() -> sock_put() -> sk_free() -> __sk_destruct()) calls bpf_sk_storage_free(), which enters rcu_read_lock_dont_migrate() -> migrate_disable() -> __migrate_disable(). Because interrupts/softirqs execute with current still pointing to the interrupted task (p), __migrate_disable() observes p->migration_disabled == 1 (nonzero) and executes the plain read-modify-write p->migration_disabled++ at include/linux/sched.h:2490, triggering the KCSAN report.

  3. Why the underlying logic is benign (aside from KCSAN instrumentation):

    • On the interrupted CPU, current is the same task_struct across the interrupt, and every interrupt/softirq path pairs migrate_disable() with migrate_enable() before returning (restoring p->migration_disabled and the per-CPU rq->nr_pinned counter via this_rq_pinned() to their exact pre-interrupt values).
    • While p->migration_disabled > 0, the task cannot be migrated off CPU 1, and any nested interrupt seeing p->migration_disabled >= 1 only increments and decrements p->migration_disabled without reaching ___migrate_enable() or modifying this_rq_pinned().
    • Even if an interrupt occurs when p->migration_disabled == 0 (e.g., between this_rq_pinned()++ and p->migration_disabled = 1 in __migrate_disable(), or after p->migration_disabled = 0 and before this_rq_pinned()-- in __migrate_enable()), the interrupt executes a balanced 0 -> 1 -> 0 transition on both p->migration_disabled and this_rq_pinned().
    • The KCSAN warning arises because __migrate_enable() and __migrate_disable() in include/linux/sched.h use plain C accesses on p->migration_disabled rather than READ_ONCE()/WRITE_ONCE() or data_race() annotations under CONFIG_KCSAN_INTERRUPT_WATCHER=y.
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
ec5647c9 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in bpf_sk_storage_free / bpf_sk_storage_free 2026/11/19 18:19 2026/11/19 18:19 2026/11/19 18:25 229865fb
162369ca assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ✅ PeripheralTrigger: ❌ RemoteTrigger: ✅ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in bpf_sk_storage_free / bpf_sk_storage_free 2026/11/19 18:18 2026/11/19 18:18 2026/11/19 18:24 229865fb

Sample crash report:
==================================================================
BUG: KCSAN: data-race in bpf_sk_storage_free / bpf_sk_storage_free

write to 0xffff8881037ca6f8 of 2 bytes by interrupt on cpu 1:
 __migrate_disable include/linux/sched.h:2490 [inline]
 migrate_disable include/linux/sched.h:2512 [inline]
 rcu_read_lock_dont_migrate include/linux/rcupdate.h:990 [inline]
 bpf_sk_storage_free+0x4f/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
 sock_put include/net/sock.h:2024 [inline]
 sctp_endpoint_destroy_rcu+0x81/0xd0 net/sctp/endpointola.c:197
 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
 delay_tsc+0x37/0xa0 arch/x86/lib/delay.c:71
 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_enable include/linux/sched.h:2457 [inline]
 migrate_enable include/linux/sched.h:2517 [inline]
 rcu_read_unlock_migrate include/linux/rcupdate.h:999 [inline]
 bpf_sk_storage_free+0x129/0x210 net/core/bpf_sk_storage.c:61
 __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
 sock_put include/net/sock.h:2024 [inline]
 tcp_close+0xa6/0xe0 net/ipv4/tcp.c:3325
 inet_release+0xe2/0x110 net/ipv4/af_inet.c:443
 __sock_release+0x65/0x150 net/socket.c:735
 sock_close+0x19/0x30 net/socket.c:1529
 __fput+0x292/0x660 fs/file_table.c:512
 fput_close_sync+0xd5/0x1d0 fs/file_table.c:618
 filp_close_sync fs/open.c:1574 [inline]
 __do_sys_close fs/open.c:1597 [inline]
 __se_sys_close fs/open.c:1584 [inline]
 __x64_sys_close+0x55/0xf0 fs/open.c:1584
 x64_sys_call+0x812/0x2550 arch/x86/include/generated/asm/syscalls_64.h:4
 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 to 0xffff8881037ca6f8 of 2 bytes by task 3294 on cpu 1:
 __migrate_enable include/linux/sched.h:2457 [inline]
 migrate_enable include/linux/sched.h:2517 [inline]
 rcu_read_unlock_migrate include/linux/rcupdate.h:999 [inline]
 bpf_sk_storage_free+0x129/0x210 net/core/bpf_sk_storage.c:61
 __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
 sock_put include/net/sock.h:2024 [inline]
 tcp_close+0xa6/0xe0 net/ipv4/tcp.c:3325
 inet_release+0xe2/0x110 net/ipv4/af_inet.c:443
 __sock_release+0x65/0x150 net/socket.c:735
 sock_close+0x19/0x30 net/socket.c:1529
 __fput+0x292/0x660 fs/file_table.c:512
 fput_close_sync+0xd5/0x1d0 fs/file_table.c:618
 filp_close_sync fs/open.c:1574 [inline]
 __do_sys_close fs/open.c:1597 [inline]
 __se_sys_close fs/open.c:1584 [inline]
 __x64_sys_close+0x55/0xf0 fs/open.c:1584
 x64_sys_call+0x812/0x2550 arch/x86/include/generated/asm/syscalls_64.h:4
 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: 3294 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 18:05 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in bpf_sk_storage_free / bpf_sk_storage_free
2026/11/17 12:07 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in bpf_sk_storage_free / bpf_sk_storage_free
2026/11/17 02:16 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in bpf_sk_storage_free / bpf_sk_storage_free
* Struck through repros no longer work on HEAD.