KCSAN: data-race in __seccomp_filter / bpf_sk_storage_free

Status: upstream: reported on 2026/11/19 02:53
Subsystems: net
Labels: prio:low race:harmful
[Documentation on labels]
Reported-by: syzbot+dbe9d09c93ae0bb86ae1@syzkaller.appspotmail.com
First crash: 2d01h, last: 2d01h
✨ AI-generated root cause summary:

Commit 378b7708194f moved __migrate_disable() and __migrate_enable() inline from kernel/sched/core.c (where KCSAN instrumentation is disabled via KCSAN_SANITIZE := n) into include/linux/sched.h. In __migrate_disable(), this_rq_pinned()++ is updated with only preemption disabled (via guard(preempt)()), without disabling hardware interrupts. When an interrupt fires on the same CPU while a task is executing __migrate_disable(), the interrupt exit path invokes softirqs (such as RCU core callbacks running deferred_put_nlk_sk -> bpf_sk_storage_free), which calls rcu_read_lock_dont_migrate() -> migrate_disable(), resulting in an uninstrumented/non-IRQ-safe nested read-modify-write on CPU 0's rq->nr_pinned that triggers KCSAN.

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

Root Cause Analysis

Involved Functions, Data Structures, and Files

  • Files: include/linux/sched.h, kernel/sched/core.c, net/core/bpf_sk_storage.c
  • Functions: __migrate_disable(), migrate_disable(), __migrate_enable(), migrate_enable(), bpf_sk_storage_free(), rcu_read_lock_dont_migrate()
  • Structs and Fields: struct rq::nr_pinned (accessed via macro this_rq_pinned()), struct task_struct::migration_disabled

Technical Mechanism

  1. Inlining of migrate_{disable,enable}: Commit 378b7708194f ("sched: Make migrate_{en,dis}able() inline") moved the definitions of __migrate_disable() and __migrate_enable() from kernel/sched/core.c into the header include/linux/sched.h. In kernel/sched/Makefile, KCSAN instrumentation is explicitly turned off for scheduler core files (KCSAN_SANITIZE := n). However, once __migrate_disable() was made an inline function in include/linux/sched.h, every compilation unit calling migrate_disable() (such as kernel/seccomp.c and net/core/bpf_sk_storage.c) compiled and inlined these functions with KCSAN instrumentation enabled.

  2. Concurrency Between Task and Softirq / Interrupt Contexts: Inside include/linux/sched.h, __migrate_disable() is implemented as follows:

    static inline void __migrate_disable(void)
    {
        struct task_struct *p = current;
    
        if (p->migration_disabled) {
            ...
            p->migration_disabled++;
            return;
        }
    
        guard(preempt)();
        this_rq_pinned()++;
        p->migration_disabled = 1;
    }
    

    guard(preempt)() only disables preemption (preempt_disable()), but does not disable local hardware interrupts or softirqs.

  3. Trigger Sequence Leading to KCSAN Report:

    • Task Context: Task 6079 enters __seccomp_filter() -> seccomp_run_filters() -> bpf_prog_run_pin_on_cpu() -> migrate_disable(). Because p->migration_disabled is 0, it disables preemption and performs a plain C read-modify-write on this_rq_pinned()++ (which accesses runqueues.nr_pinned on CPU 0 at address 0xffff888237c2ccf0).
    • Watchpoint Setup: KCSAN instruments the memory access to this_rq_pinned() and sets up a watchpoint delay (delay_tsc).
    • Interrupt and Softirq Preemption: While Task 6079 is executing at line 2495, an APIC timer interrupt (sysvec_apic_timer_interrupt) fires on CPU 0. On return from interrupt, __irq_exit_rcu() processes pending softirqs via handle_softirqs().
    • Nested migrate_disable() in Softirq: RCU softirq processing runs RCU callback batches (rcu_core() -> rcu_do_batch()), invoking deferred socket destruction (deferred_put_nlk_sk() -> sk_free() -> __sk_destruct() -> bpf_sk_storage_free()). bpf_sk_storage_free() calls rcu_read_lock_dont_migrate(), which under CONFIG_PREEMPT_RCU calls migrate_disable().
    • Data Race Detection: In softirq context on the same CPU, __migrate_disable() is entered and performs a read-modify-write access to the exact same per-CPU rq->nr_pinned memory address (0xffff888237c2ccf0) while the interrupted task's access is still active, causing KCSAN to report a data race.
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
8af949c2 repro-c 🏃 KCSAN: data-race in __seccomp_filter / bpf_sk_storage_free 2026/11/19 02:53 2026/11/19 02:53 2006bdcc
4d190f43 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in __seccomp_filter / bpf_sk_storage_free 2026/11/19 02:16 2026/11/19 02:16 2026/11/19 02:36 2006bdcc
0b1013d0 assessment-kcsan Benign: ❌ ❓ KCSAN: data-race in __seccomp_filter / bpf_sk_storage_free 2026/11/19 02:06 2026/11/19 02:06 2026/11/19 02:53 2006bdcc
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [net?] KCSAN: data-race in __seccomp_filter / bpf_sk_storage_free 0 (1) 2026/11/19 02:53

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

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]
 rcu_read_lock_dont_migrate include/linux/rcupdate.h:990 [inline]
 bpf_sk_storage_free+0x7b/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
 delay_tsc+0x32/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_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]
 seccomp_run_filters kernel/seccomp.c:426 [inline]
 __seccomp_filter+0x362/0x1400 kernel/seccomp.c:1283
 __seccomp_permit_syscall+0x7d/0x150 kernel/seccomp.c:1410
 syscall_trace_enter include/linux/entry-common.h:98 [inline]
 syscall_enter_from_user_mode_work include/linux/entry-common.h:147 [inline]
 do_syscall_64+0xce/0x3a0 arch/x86/entry/syscall_64.c:86
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

read-write to 0xffff888237c2ccf0 of 4 bytes by task 6079 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]
 seccomp_run_filters kernel/seccomp.c:426 [inline]
 __seccomp_filter+0x362/0x1400 kernel/seccomp.c:1283
 __seccomp_permit_syscall+0x7d/0x150 kernel/seccomp.c:1410
 syscall_trace_enter include/linux/entry-common.h:98 [inline]
 syscall_enter_from_user_mode_work include/linux/entry-common.h:147 [inline]
 do_syscall_64+0xce/0x3a0 arch/x86/entry/syscall_64.c:86
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

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

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