KCSAN: data-race in 0x0 / ns_capable_noaudit

Status: moderation: reported on 2026/11/18 06:58
Subsystems: lsm
Labels: prio:low race:benign
[Documentation on labels]
Reported-by: syzbot+14042284e8dd53d6b714@syzkaller.appspotmail.com
First crash: 1d05h, last: 13h32m
✨ AI-generated root cause summary:

In ns_capable_common() (kernel/capability.c), testing a capability successfully results in an unmarked read-modify-write operation (current->flags |= PF_SUPERPRIV;) on the calling task's task_struct::flags. KCSAN flagged a data race on current->flags when a watchpoint was placed on this access and a concurrent read of current->flags occurred on the same CPU while current was still the active task. Because the unwinder could not resolve any frames for the racing read (yielding 0 frames, printed as 0x0 with an empty stack trace), KCSAN attributed the race to 0x0 / ns_capable_noaudit. This is a benign race under the kernel's single-writer invariant for task_struct::flags.

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

Root Cause Analysis

1. Functions, Structs, and Fields Involved

  • File: kernel/capability.c (invoked via net/sysctl_net.c)
  • Function: ns_capable_common() (inlined into ns_capable_noaudit())
  • Struct & Field: struct task_struct::flags (offset 0x2c, size 4 bytes, matching address 0xffff888101d2452c on the reported task_struct)
  • Constants: PF_SUPERPRIV (0x00000100 in include/linux/sched.h)

2. Mechanism and Lifecycle Violation

When a process opens a sysctl node under /proc/sys/net/ (here triggered by dhcpcd opening /proc/sys/net/... via openat), permission checking in fs/proc/proc_sysctl.c:proc_sys_permission() invokes the network sysctl permission handler net_ctl_permissions() in net/sysctl_net.c:

static int net_ctl_permissions(struct ctl_table_header *head,
			       const struct ctl_table *table)
{
	struct net *net = container_of(head->set, struct net, sysctls);

	/* Allow network administrator to have same access as root. */
	if (ns_capable_noaudit(net->user_ns, CAP_NET_ADMIN)) {
...

ns_capable_noaudit() delegates to ns_capable_common() in kernel/capability.c:

static bool ns_capable_common(struct user_namespace *ns,
			      int cap,
			      unsigned int opts)
{
	int capable;
...
	capable = security_capable(current_cred(), ns, cap, opts);
	if (capable == 0) {
		current->flags |= PF_SUPERPRIV;
		return true;
	}
	return false;
}

At line 343, ns_capable_common() performs an unmarked read-modify-write on current->flags (current->flags |= PF_SUPERPRIV;).

In the Linux kernel's task concurrency model, task_struct::flags stores process flags (PF_*), which are written strictly by the task itself (current) in task context. Concurrent tasks only read certain flags (or write separate fields like atomic_flags). However, because current->flags |= PF_SUPERPRIV; is an unmarked plain memory access rather than an annotated access (READ_ONCE()/WRITE_ONCE() or atomic flag operations), KCSAN instruments this write.

3. How the KCSAN Splat (0x0 / ns_capable_noaudit) Occurred

  1. Watchpoint Setup: KCSAN instrumented the read-modify-write on current->flags in ns_capable_common(), setting a watchpoint on 0xffff888101d2452c and entering delay_access().
  2. Watchpoint Hit: When CONFIG_KCSAN_INTERRUPT_WATCHER=y, kcsan_setup_watchpoint() leaves local IRQs enabled and preemption unblocked across delay_access(). A subsequent instrumented read of current->flags on CPU 1 (while current was still task 3018, e.g. during an interrupt exit / preemption window entering __schedule() or scheduler code) tripped the watchpoint.
  3. in_task() Context: Because in_task() checks !(preempt_count() & (NMI_MASK | HARDIRQ_MASK | SOFTIRQ_OFFSET)), any read outside hardirq/NMI/softirq (for example, after irq_exit_rcu() clears the hardirq mask and calls into scheduler preemption) evaluated in_task() as true. This caused get_ctx() to return &current->kcsan_ctx and recorded the racing access with task_pid = 3018 and cpu_id = 1.
  4. Empty Stack Trace / 0x0: For standard non-scoped memory accesses, ai.ip is recorded as 0 (kernel/kcsan/report.c:652). In prepare_report_producer(), stack_trace_save() attempted to unwind the stack for the racing read. In this context (e.g., within an entry/exit or assembly stub lacking ORC unwind information), the unwinder returned 0 entries. In sanitize_stack_entries(), get_stack_skipnr() returned 0, leaving other_frame = 0x0. Consequently, print_report() printed BUG: KCSAN: data-race in 0x0 / ns_capable_noaudit, and print_stack_trace() printed 0 frames for the first access.
  5. No Value Change: Because dhcpcd was already running with UID 0 / root, PF_SUPERPRIV was already set on task_struct::flags, so the read-modify-write resulted in identical values (old == new), producing no value changed: line in the KCSAN report.
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
da12fd5b assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in 0x0 / ns_capable_noaudit 2026/11/18 06:50 2026/11/18 06:50 2026/11/18 07:14 eb4895d7
87505d17 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in 0x0 / ns_capable_noaudit 2026/11/18 06:30 2026/11/18 06:30 2026/11/18 06:54 eb4895d7

Sample crash report:
==================================================================
BUG: KCSAN: data-race in 0x0 / ns_capable_noaudit

read to 0xffff888101d2452c of 4 bytes by task 3018 on cpu 1:

read-write to 0xffff888101d2452c of 4 bytes by task 3018 on cpu 1:
 ns_capable_common kernel/capability.c:343 [inline]
 ns_capable_noaudit+0x83/0xb0 kernel/capability.c:380
 net_ctl_permissions+0x3d/0x70 net/sysctl_net.c:48
 sysctl_perm fs/proc/proc_sysctl.c:442 [inline]
 proc_sys_permission+0x126/0x260 fs/proc/proc_sysctl.c:817
 do_inode_permission fs/namei.c:583 [inline]
 inode_permission+0x2b4/0x3c0 fs/namei.c:653
 lookup_inode_permission_may_exec fs/namei.c:-1 [inline]
 may_lookup fs/namei.c:1967 [inline]
 link_path_walk+0x881/0xde0 fs/namei.c:2610
 path_openat+0x142/0x11e0 fs/namei.c:5012
 do_file_open+0x16c/0x290 fs/namei.c:5045
 do_sys_openat2+0xa1/0x140 fs/open.c:1443
 do_sys_open fs/open.c:1449 [inline]
 __do_sys_openat fs/open.c:1465 [inline]
 __se_sys_openat fs/open.c:1460 [inline]
 __x64_sys_openat+0xf2/0x120 fs/open.c:1460
 x64_sys_call+0x1f72/0x2550 arch/x86/include/generated/asm/syscalls_64.h:258
 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: 3018 Comm: dhcpcd Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
==================================================================
8021q: adding VLAN 0 to HW filter on device eth13
8021q: adding VLAN 0 to HW filter on device eth14
8021q: adding VLAN 0 to HW filter on device eth15
8021q: adding VLAN 0 to HW filter on device eth16
8021q: adding VLAN 0 to HW filter on device eth25
8021q: adding VLAN 0 to HW filter on device eth26
8021q: adding VLAN 0 to HW filter on device eth27
8021q: adding VLAN 0 to HW filter on device eth28

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/17 19:38 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / ns_capable_noaudit
2026/11/17 19:12 upstream 666539eecdf4 122f94d5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / ns_capable_noaudit
2026/11/17 11:47 upstream 666539eecdf4 43af6cac .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / ns_capable_noaudit
2026/11/17 08:52 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / ns_capable_noaudit
2026/11/17 06:16 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / ns_capable_noaudit
2026/11/17 03:35 upstream 666539eecdf4 a3e64cfc .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in 0x0 / ns_capable_noaudit
* Struck through repros no longer work on HEAD.