CVE-2023-53368: tracing: Fix race issue between cpu buffer write and swap
In the Linux kernel, the following vulnerability has been resolved:
tracing: Fix race issue between cpu buffer write and swap
Warning happened in rb_end_commit() at code:
if (RB_WARN_ON(cpu_buffer, !local_read(&cpu_buffer->committing)))
WARNING: CPU: 0 PID: 139 at kernel/trace/ring_buffer.c:3142
rb_commit+0x402/0x4a0
Call Trace:
ring_buffer_unlock_commit+0x42/0x250
trace_buffer_unlock_commit_regs+0x3b/0x250
trace_event_buffer_commit+0xe5/0x440
trace_event_buffer_reserve+0x11c/0x150
trace_event_raw_event_sched_switch+0x23c/0x2c0
__traceiter_sched_switch+0x59/0x80
__schedule+0x72b/0x1580
schedule+0x92/0x120
worker_thread+0xa0/0x6f0
It is because the race between writing event into cpu buffer and swapping
cpu buffer through file per_cpu/cpu0/snapshot:
Write on CPU 0 Swap buffer by per_cpu/cpu0/snapshot on CPU 1
-------- --------
tracing_snapshot_write()
[...]
ring_buffer_lock_reserve()
cpu_buffer = buffer->buffers[cpu]; // 1. Suppose find 'cpu_buffer_a';
[...]
rb_reserve_next_event()
[...]
ring_buffer_swap_cpu()
if (local_read(&cpu_buffer_a->committing))
goto out_dec;
if (local_read(&cpu_buffer_b->committing))
goto out_dec;
buffer_a->buffers[cpu] = cpu_buffer_b;
buffer_b->buffers[cpu] = cpu_buffer_a;
// 2. cpu_buffer has swapped here.
rb_start_commit(cpu_buffer);
if (unlikely(READ_ONCE(cpu_buffer->buffer)
!= buffer)) { // 3. This check passed due to 'cpu_buffer->buffer'
[...] // has not changed here.
return NULL;
}
cpu_buffer_b->buffer = buffer_a;
cpu_buffer_a->buffer = buffer_b;
[...]
// 4. Reserve event from 'cpu_buffer_a'.
ring_buffer_unlock_commit()
[...]
cpu_buffer = buffer->buffers[cpu]; // 5. Now find 'cpu_buffer_b' !!!
rb_commit(cpu_buffer)
rb_end_commit() // 6. WARN for the wrong 'committing' state !!!
Based on above analysis, we can easily reproduce by following testcase:
``` bash
#!/bin/bash
dmesg -n 7
sysctl -w kernel.panic_on_warn=1
TR=/sys/kernel/tracing
echo 7 > ${TR}/buffer_size_kb
echo "sched:sched_switch" > ${TR}/set_event
while [ true ]; do
echo 1 > ${TR}/per_cpu/cpu0/snapshot
done &
while [ true ]; do
echo 1 > ${TR}/per_cpu/cpu0/snapshot
done &
while [ true ]; do
echo 1 > ${TR}/per_cpu/cpu0/snapshot
done &
```
To fix it, IIUC, we can use smp_call_function_single() to do the swap on
the target cpu where the buffer is located, so that above race would be
avoided.
Security readout for executives and security teams
Plain-English summary
CVE-2023-53368 is a Linux kernel tracing bug that can crash or destabilize a system when a local user triggers a race in tracing buffer snapshot handling. It is not remotely exploitable from the evidence provided, but it can affect availability on systems that expose tracing controls to local users.
Executive priority
Treat this as a routine but real availability risk. Prioritize internet-facing multi-tenant hosts, shared build systems, and environments with local untrusted users. It does not warrant emergency response based on the provided evidence, but it should be included in the next kernel patch cycle.
Technical view
The flaw is a CWE-362 race between event writes to a per-CPU ring buffer and swapping that buffer through the tracing snapshot interface. The race can make commit logic operate on the wrong CPU buffer state, producing a kernel warning and potential availability impact. Stable Linux commits are referenced as fixes.
Likely exposure
Exposure is most relevant on Linux systems running affected kernels where low-privileged local users can reach kernel tracing snapshot interfaces. Systems without local untrusted users, or with tracing/debugfs access tightly restricted, have lower practical exposure.
Exploitation context
The source bundle does not cite active exploitation, and KEV is false. The CVSS vector requires local access, low privileges, high attack complexity, and no user interaction, with availability as the impacted security property.
Researcher notes
The bug is in kernel/trace ring buffer commit accounting during per-CPU buffer swap. The provided analysis shows rb_end_commit can observe an unexpected committing state after swap. Fix references indicate upstream stable remediation, but distro-specific affected and fixed package versions must be confirmed separately.
Mitigation direction
Update to a vendor kernel that includes the referenced stable Linux fixes.
Confirm distribution backports rather than relying only on upstream version numbers.
Restrict access to kernel tracing and debugfs interfaces to trusted administrators.
Disable unnecessary tracing interfaces on production systems where operationally feasible.
Review vendor guidance for affected kernel packages and supported upgrade paths.
Validation and detection
Inventory Linux kernel versions across servers, containers hosts, and appliances.
Check package changelogs or source trees for the referenced stable commits.
Review permissions and mounts for /sys/kernel/tracing and debugfs access.
Confirm no untrusted local users can write tracing snapshot controls.
Track vendor advisories for backport status and regression notes.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-362: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-362 · source CWE mapping
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition') represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.