KCSAN: data-race in inet_lookup_run_sk_lookup / tracing_gen_ctx_irq_test

Status: moderation: reported on 2026/11/20 00:07
Subsystems: trace
Labels: prio:high race:benign
[Documentation on labels]
Reported-by: syzbot+37663b1c84b88e64544a@syzkaller.appspotmail.com
First crash: 2d09h, last: 2d05h
✨ AI-generated root cause summary:

A data race occurs between task context and an interrupt on the same CPU when tracing_gen_ctx_irq_test() reads 'current->migration_disabled' via migration_disable_value() in kernel/trace/trace.c while migrate_disable() or migrate_enable() updates 'p->migration_disabled' in include/linux/sched.h. The task modifies 'p->migration_disabled' using plain C read/write operations without disabling hardware interrupts, and migration_disable_value() reads the field with a plain memory access without READ_ONCE() or data_race(). When a timer interrupt fires on the same CPU while the task is updating the counter and executes a tracing event (e.g., bpf_trace_printk), KCSAN detects concurrent unmarked memory accesses to 'current->migration_disabled'.

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

Root Cause Analysis

1. Functions, Structs, and Fields Involved

  • struct task_struct::migration_disabled (include/linux/sched.h:948): An unsigned short (2 bytes) counter tracking the nesting depth of migrate_disable() calls for a task.
  • __migrate_disable() and __migrate_enable() (include/linux/sched.h:2444-2497): Inlined sched functions that increment, decrement, and reset p->migration_disabled in task context.
  • migration_disable_value() and tracing_gen_ctx_irq_test() (kernel/trace/trace.c:1715-1748): Ftrace helper functions called during trace event buffer reservations (trace_event_buffer_reserve() -> tracing_gen_ctx()) to encode context flags, preempt depth, and migrate-disable depth into the ring-buffer trace entry header (struct trace_entry::preempt_count).

2. Mechanism of the Data Race

  1. Write Side (Task Context): A task running on CPU 1 (in the report, executing a network socket lookup BPF program via inet_lookup_run_sk_lookup() -> bpf_sk_lookup_run_v4()) enters migrate_enable() / migrate_disable(). Within include/linux/sched.h:

    • __migrate_disable() updates p->migration_disabled (p->migration_disabled++ or p->migration_disabled = 1).
    • __migrate_enable() updates p->migration_disabled (p->migration_disabled-- or p->migration_disabled = 0).

    These updates are performed via plain, unmarked C read-modify-write and assignment operations. Crucially, hardware interrupts are not disabled on these paths (even during 0 -> 1 and 1 -> 0 transitions, guard(preempt)() only disables preemption, leaving local IRQs enabled).

  2. Read Side (Interrupt Context on the Same CPU): When KCSAN sets a watchpoint on p->migration_disabled and delays execution during an unmarked write, a local APIC timer interrupt (sysvec_apic_timer_interrupt) triggers on CPU 1. Inside the timer interrupt, an hrtimer fires a perf sampling event (perf_swevent_hrtimer() -> __perf_event_overflow()), which triggers a BPF program calling bpf_trace_printk(). Emitting the trace event requires building the trace entry context via:

    trace_event_buffer_reserve()
      tracing_gen_ctx()
        tracing_gen_ctx_irq_test()
          migration_disable_value()
    

    In kernel/trace/trace.c:

    static unsigned short migration_disable_value(void)
    {
    #if defined(CONFIG_SMP)
        return current->migration_disabled;
    #else
        return 0;
    #endif
    }
    

    migration_disable_value() performs a plain, unmarked C load of current->migration_disabled. Because the interrupted task is the current task on CPU 1, the interrupt reads the exact memory address being watched by KCSAN for the task-context write.

  3. Violation: Because migration_disable_value() performs an unmarked load without READ_ONCE() or data_race(), and __migrate_enable() / __migrate_disable() modify the counter without WRITE_ONCE() or IRQ disabling, KCSAN detects a concurrent unmarked read and write to the same memory location (0xffff888103b1ebf8) across task and interrupt contexts on the same CPU.

▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
23b73c3a assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in inet_lookup_run_sk_lookup / tracing_gen_ctx_irq_test 2026/11/19 05:13 2026/11/19 05:13 2026/11/19 05:37 2006bdcc
45108938 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ✅ NetworkTrigger: ✅ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in inet_lookup_run_sk_lookup / tracing_gen_ctx_irq_test 2026/11/19 04:38 2026/11/19 04:38 2026/11/19 05:13 2006bdcc

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

read to 0xffff888103b1ebf8 of 2 bytes by interrupt on cpu 1:
 migration_disable_value kernel/trace/trace.c:1718 [inline]
 tracing_gen_ctx_irq_test+0xdd/0x110 kernel/trace/trace.c:1747
 tracing_gen_ctx_flags include/linux/trace_events.h:204 [inline]
 tracing_gen_ctx include/linux/trace_events.h:211 [inline]
 tracing_gen_ctx_dec include/linux/trace_events.h:218 [inline]
 trace_event_buffer_reserve+0xe4/0x180 kernel/trace/trace_events.c:720
 do_trace_event_raw_event_bpf_trace_printk kernel/trace/bpf_trace.h:11 [inline]
 trace_event_raw_event_bpf_trace_printk+0x9d/0x190 kernel/trace/bpf_trace.h:11
 __do_trace_bpf_trace_printk kernel/trace/bpf_trace.h:11 [inline]
 trace_bpf_trace_printk kernel/trace/bpf_trace.h:11 [inline]
 ____bpf_trace_printk kernel/trace/bpf_trace.c:409 [inline]
 bpf_trace_printk+0x1b9/0x1e0 kernel/trace/bpf_trace.c:392
 bpf_prog_484c593dea3d67e5+0x3b/0x41
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_overflow_handler kernel/events/core.c:10822 [inline]
 __perf_event_overflow+0x331/0x950 kernel/events/core.c:10921
 perf_event_overflow kernel/events/core.c:11004 [inline]
 perf_swevent_hrtimer+0x293/0x320 kernel/events/core.c:12424
 __run_hrtimer kernel/time/hrtimer.c:2079 [inline]
 __hrtimer_run_queues+0x1f8/0x540 kernel/time/hrtimer.c:2136
 hrtimer_interrupt+0x27b/0x870 kernel/time/hrtimer.c:2255
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1051 [inline]
 __sysvec_apic_timer_interrupt+0x5f/0x1f0 arch/x86/kernel/apic/apic.c:1068
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
 sysvec_apic_timer_interrupt+0x6f/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_enable include/linux/sched.h:2458 [inline]
 migrate_enable include/linux/sched.h:2517 [inline]
 bpf_sk_lookup_run_v4 include/linux/filter.h:1894 [inline]
 inet_lookup_run_sk_lookup+0x3a7/0x5f0 net/ipv4/inet_hashtables.c:453
 __udp4_lib_lookup+0x883/0x8c0 net/ipv4/udp.c:707
 sk_lookup+0x188/0x2d0 net/core/filter.c:7309
 __bpf_skc_lookup+0x1c2/0x2e0 net/core/filter.c:7367
 __bpf_sk_lookup net/core/filter.c:7407 [inline]
 ____bpf_tc_sk_lookup_udp net/core/filter.c:7557 [inline]
 bpf_tc_sk_lookup_udp+0x9d/0xe0 net/core/filter.c:7550
 bpf_prog_95065b2cf55c0447+0x39/0x4c
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_test_run+0x29b/0x620 net/bpf/test_run.c:422
 bpf_prog_test_run_skb+0xaa1/0x11d0 net/bpf/test_run.c:1226
 bpf_prog_test_run+0x21b/0x360 kernel/bpf/syscall.c:4860
 __sys_bpf+0x914/0xc50 kernel/bpf/syscall.c:6478
 __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 0xffff888103b1ebf8 of 2 bytes by task 3551 on cpu 1:
 __migrate_enable include/linux/sched.h:2458 [inline]
 migrate_enable include/linux/sched.h:2517 [inline]
 bpf_sk_lookup_run_v4 include/linux/filter.h:1894 [inline]
 inet_lookup_run_sk_lookup+0x3a7/0x5f0 net/ipv4/inet_hashtables.c:453
 __udp4_lib_lookup+0x883/0x8c0 net/ipv4/udp.c:707
 sk_lookup+0x188/0x2d0 net/core/filter.c:7309
 __bpf_skc_lookup+0x1c2/0x2e0 net/core/filter.c:7367
 __bpf_sk_lookup net/core/filter.c:7407 [inline]
 ____bpf_tc_sk_lookup_udp net/core/filter.c:7557 [inline]
 bpf_tc_sk_lookup_udp+0x9d/0xe0 net/core/filter.c:7550
 bpf_prog_95065b2cf55c0447+0x39/0x4c
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_test_run+0x29b/0x620 net/bpf/test_run.c:422
 bpf_prog_test_run_skb+0xaa1/0x11d0 net/bpf/test_run.c:1226
 bpf_prog_test_run+0x21b/0x360 kernel/bpf/syscall.c:4860
 __sys_bpf+0x914/0xc50 kernel/bpf/syscall.c:6478
 __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: 3551 Comm: syz.0.14 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================
==================================================================
BUG: KCSAN: data-race in inet_lookup_run_sk_lookup / tracing_gen_ctx_irq_test

read to 0xffff888103b1ebf8 of 2 bytes by interrupt on cpu 1:
 migration_disable_value kernel/trace/trace.c:1718 [inline]
 tracing_gen_ctx_irq_test+0xdd/0x110 kernel/trace/trace.c:1747
 tracing_gen_ctx_flags include/linux/trace_events.h:204 [inline]
 tracing_gen_ctx include/linux/trace_events.h:211 [inline]
 tracing_gen_ctx_dec include/linux/trace_events.h:218 [inline]
 trace_event_buffer_reserve+0xe4/0x180 kernel/trace/trace_events.c:720
 do_trace_event_raw_event_bpf_trace_printk kernel/trace/bpf_trace.h:11 [inline]
 trace_event_raw_event_bpf_trace_printk+0x9d/0x190 kernel/trace/bpf_trace.h:11
 __do_trace_bpf_trace_printk kernel/trace/bpf_trace.h:11 [inline]
 trace_bpf_trace_printk kernel/trace/bpf_trace.h:11 [inline]
 ____bpf_trace_printk kernel/trace/bpf_trace.c:409 [inline]
 bpf_trace_printk+0x1b9/0x1e0 kernel/trace/bpf_trace.c:392
 bpf_prog_484c593dea3d67e5+0x3b/0x41
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_overflow_handler kernel/events/core.c:10822 [inline]
 __perf_event_overflow+0x331/0x950 kernel/events/core.c:10921
 perf_event_overflow kernel/events/core.c:11004 [inline]
 perf_swevent_hrtimer+0x293/0x320 kernel/events/core.c:12424
 __run_hrtimer kernel/time/hrtimer.c:2079 [inline]
 __hrtimer_run_queues+0x1f8/0x540 kernel/time/hrtimer.c:2136
 hrtimer_interrupt+0x27b/0x870 kernel/time/hrtimer.c:2255
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1051 [inline]
 __sysvec_apic_timer_interrupt+0x5f/0x1f0 arch/x86/kernel/apic/apic.c:1068
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
 sysvec_apic_timer_interrupt+0x6f/0x80 arch/x86/kernel/apic/apic.c:1062
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674
 rdtsc_ordered arch/x86/include/asm/tsc.h:57 [inline]
 delay_tsc+0x5b/0xa0 arch/x86/lib/delay.c:70
 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:2490 [inline]
 migrate_disable include/linux/sched.h:2512 [inline]
 bpf_sk_lookup_run_v4 include/linux/filter.h:1894 [inline]
 inet_lookup_run_sk_lookup+0x14a/0x5f0 net/ipv4/inet_hashtables.c:453
 __udp4_lib_lookup+0x883/0x8c0 net/ipv4/udp.c:707
 sk_lookup+0x188/0x2d0 net/core/filter.c:7309
 __bpf_skc_lookup+0x1c2/0x2e0 net/core/filter.c:7367
 __bpf_sk_lookup net/core/filter.c:7407 [inline]
 ____bpf_tc_sk_lookup_udp net/core/filter.c:7557 [inline]
 bpf_tc_sk_lookup_udp+0x9d/0xe0 net/core/filter.c:7550
 bpf_prog_95065b2cf55c0447+0x39/0x4c
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_test_run+0x29b/0x620 net/bpf/test_run.c:422
 bpf_prog_test_run_skb+0xaa1/0x11d0 net/bpf/test_run.c:1226
 bpf_prog_test_run+0x21b/0x360 kernel/bpf/syscall.c:4860
 __sys_bpf+0x914/0xc50 kernel/bpf/syscall.c:6478
 __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 0xffff888103b1ebf8 of 2 bytes by task 3551 on cpu 1:
 __migrate_disable include/linux/sched.h:2490 [inline]
 migrate_disable include/linux/sched.h:2512 [inline]
 bpf_sk_lookup_run_v4 include/linux/filter.h:1894 [inline]
 inet_lookup_run_sk_lookup+0x14a/0x5f0 net/ipv4/inet_hashtables.c:453
 __udp4_lib_lookup+0x883/0x8c0 net/ipv4/udp.c:707
 sk_lookup+0x188/0x2d0 net/core/filter.c:7309
 __bpf_skc_lookup+0x1c2/0x2e0 net/core/filter.c:7367
 __bpf_sk_lookup net/core/filter.c:7407 [inline]
 ____bpf_tc_sk_lookup_udp net/core/filter.c:7557 [inline]
 bpf_tc_sk_lookup_udp+0x9d/0xe0 net/core/filter.c:7550
 bpf_prog_95065b2cf55c0447+0x39/0x4c
 bpf_dispatcher_nop_func include/linux/bpf.h:1547 [inline]
 __bpf_prog_run include/linux/filter.h:813 [inline]
 bpf_prog_run include/linux/filter.h:820 [inline]
 bpf_test_run+0x29b/0x620 net/bpf/test_run.c:422
 bpf_prog_test_run_skb+0xaa1/0x11d0 net/bpf/test_run.c:1226
 bpf_prog_test_run+0x21b/0x360 kernel/bpf/syscall.c:4860
 __sys_bpf+0x914/0xc50 kernel/bpf/syscall.c:6478
 __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: 3551 Comm: syz.0.14 Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================
syz.0.14 (3551) used greatest stack depth: 11024 bytes left

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 20:33 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in inet_lookup_run_sk_lookup / tracing_gen_ctx_irq_test
2026/11/17 20:32 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in inet_lookup_run_sk_lookup / tracing_gen_ctx_irq_test
2026/11/17 15:41 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in inet_lookup_run_sk_lookup / tracing_gen_ctx_irq_test
2026/11/17 15:40 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in inet_lookup_run_sk_lookup / tracing_gen_ctx_irq_test
* Struck through repros no longer work on HEAD.