pipe_size sysctl lacks power-of-two validation: non-pow2 buffer size silently aliases FIFO slots (in-bounds cross-process data corruption) on misconfigured systems
| Field | Value |
|---|---|
| ID | DF-2752 |
| Status | new |
| Severity | Low |
| CVSS 3.1 | CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:N |
| CWE | CWE-20 Improper Input Validation |
| File | sys/kern/sys_pipe.c |
| Lines | 125-127, 367-371 (indexing :539, :794) |
| Area | kern |
| Confidence | certain |
| Discovered | 2026-08-30 |
| Pass | 2 (GLM 5.3 second pass) |
| Bucket | base:kern |
| Reported | pending |
| Known CVE | none |
| CVE match | novel |
Summary
The FIFO maps logical byte counters to physical slots with
rindex & (size-1) / windex & (size-1), which is modulo only when
size is a power of two. pipespace() page-aligns and clamps size to
[16384, 1MB] but never validates the power-of-two property, and the
writable sysctl kern.pipe.size accepts any int (e.g. 20480). With a
non-pow2 size two distinct live offsets map to the same slot (e.g.
0x5000 & 0x4FFF == 0x4000), so a writer overwrites unread data —
silent data corruption between the pipe's users. All accesses remain
in-bounds, so integrity-only; requires a privileged sysctl write (an
administrator misconfiguration, not attacker-reachable). Sibling
FreeBSD code guards this with a power-of-two check.
Recommended fix
In pipespace(), after the clamps: if (size & (size - 1)) size =
1UL << (fls(size) - 1); if (size < 16384) size = 16384; and
optionally guard the sysctl writer with the same check.
Timeline
- 2026-08-30 Discovered during pass-2 audit of sys_pipe.c (GLM 5.3).
No comments yet.