Skip to contentSkip to conversation

KCSAN: data-race in __seccomp_filter / bpf_sk_storage_free

syzbot syzbot 1 participant 1 message Nov 19

Subsystems (2)
lore
Share & tools
lore

syzbot

author syzbot
#0 lore raw

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=146ba4b5580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b949a9d3c1d44ceb
dashboard link: https://syzkaller.appspot.com/bug?extid=dbe9d09c93ae0bb86ae1
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:
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 analysis: https://syzkaller.appspot.com/x/ai_root_cause?x=dbe9d09c93ae0bb86ae1

IMPORTANT: if you fix the issue, please add the following tag to the commit:

Reported-by [email protected]

==================================================================

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
==================================================================

---
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