sysctl kern.stackgap_random accepts unbounded negative values: ALIGN(-gap) up to 2GB silently places every exec's stack contents outside the stack mapping β system-wide exec SIGSEGV from a single root sysctl (validation gap)
| Field | Value |
|---|---|
| ID | DF-2754 |
| Status | new |
| Severity | Info |
| CVSS 3.1 | CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H |
| CWE | CWE-20 Improper Input Validation |
| File | sys/kern/kern_exec.c |
| Lines | 159-161 (consumer :1170-1171, :1181-1188) |
| 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
sysctl_kern_stackgap() validates only positive values. Negative values
are a documented feature ("static gap if negative") consumed unbounded
in exec_copyout_strings(): sgap = ALIGN(-gap), subtracted from destp.
A root-set value such as β1073741824 passes validation, yields sgap=1GB,
and pushes destp/stack_base ~1GB below USRSTACK β outside the
maxssiz=512MB stack mapping. copyout/suword return values are ignored,
so execve() reports success while the new image enters userland with an
unmapped stack pointer and every program faults at entry. INT_MIN
additionally makes βgap signed-overflow UB. Root-only misconfiguration
β hardening/validation gap.
Recommended fix
Validate the magnitude of negative values symmetrically (unsigned negation avoiding INT_MIN UB), keeping the static-gap feature β diff above.
Timeline
- 2026-08-30 Discovered during pass-2 audit of kern_exec.c (GLM 5.3).
No comments yet.