cbq_getqstats leaks uninitialized kernel stack to userspace via class_stats_t
| Field | Value |
|---|---|
| ID | DF-0652 |
| Status | new |
| Severity | Low |
| CVSS 3.1 | CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:L/I:N/A:N |
| CWE | CWE-908 Use of Uninitialized Resource; CWE-200 Info Exposure |
| File | sys/net/altq/altq_cbq.c |
| Lines | 473 (uninit decl); 191-218 (partial fill); 503 (copyout) |
| Area | net/altq (CBQ statistics) |
| Confidence | certain |
| Discovered | 2026-07-02 |
| Reported | pending |
Summary
cbq_getqstats() declares class_stats_t stats on the stack without
zeroing it, then calls get_class_stats() which only partially
initializes the struct. The fields stats.handle (4 bytes) and
stats.red[3] (up to 144 bytes) are never assigned. copyout() then
ships the full ~240-byte struct β including ~148 bytes of raw kernel stack
β to userspace.
Root cause
In cbq_getqstats (altq_cbq.c:469-507) the local class_stats_t stats;
(line 473) is an uninitialized auto variable. get_class_stats()
(altq_cbq.c:191-220) populates many fields (xmit_cnt, drop_cnt, over,
borrows, etc.) but:
- Never assigns
statsp->handledespitecl->stats_.handlebeing available (set ataltq_cbq.c:383). Functional bug + leak. - Never assigns
statsp->red[3](3 Γstruct redstats, 48 bytes each peraltq_red.h:50-57) when ALTQ_RED/ALTQ_RIO are not compiled in or the queue is not RED/RIO. Even with RED compiled in andq_is_red()true,red_getstats()fills only&statsp->red[0]βred[1]andred[2](96 bytes) stay uninitialized.
copyout at line 503 copies sizeof(stats) bytes regardless, leaking the
uninitialized fields.
Threat model & preconditions
- Privilege: root (or a process with CAP rights on
/dev/pf, which is mode 0600root:wheelperpf_ioctl.c:3360). - Impact: ~148 bytes of kernel stack per call β may contain pointers
useful for KASLR bypass, stack canaries, or adjacent stack frames.
Marginal direct impact because root-only, but a real defense-in-depth
defect. The same pattern exists in
altq_priq.c,altq_hfsc.c, andaltq_fairq.c.
Recommended fix
(1) Zero-initialize stats before get_class_stats():
memset(&stats, 0, sizeof(stats));
(2) Fill statsp->handle from cl->stats_.handle:
statsp->handle = cl->stats_.handle;
References
sys/net/altq/altq_cbq.c:473β uninitializedclass_stats_t stats.sys/net/altq/altq_cbq.c:191-218βget_class_statspartial fill.sys/net/altq/altq_cbq.c:503βcopyoutof full struct.
Timeline
- 2026-07-02 Discovered during automated DragonFlyBSD kernel security audit.
- 2026-07-02 Reported to DragonFlyBSD security contact (pending).
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0652 Β· 5 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | bzero the stats struct before get_class_stats fills it. | 289 B | view raw |
| VERDICT.md | verdict | source-confirmation + fix | 1.0 KB | β raw |
| ../_batch_low/fix_build.log | build-log | combined 80-fix kernel build (rc=0, -Werror) | 5.6 MB | β download |
| ../_batch_low/combined_all.patch | suggested-fix | all 80 fixes batched | 20.0 KB | view raw |
| ../_batch_low/env.txt | environment | guest uname + kern.version | 247 B | view raw |
DF-0652 β Low-severity source-confirmation
Verdict: REPRODUCED
Impact: leak Confidence: certain
Kernel ref: sys/net/altq/altq_cbq.c:469
Mechanism / why
Source-confirmed: cbq_getqstats declares class_stats_t stats on the stack unzeroed; get_class_stats fills only some fields; whole struct copied to user -> kernel stack leak. altq (GENERIC).
Recommended fix
bzero the stats struct before get_class_stats fills it.
Phase 8 (combined build)
All 80 Low-severity fixes were batched into one patch (../_batch_low/combined_all.patch) and applied to the in-guest /usr/src. A single make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under -Werror (../_batch_low/fix_build.log). The GENERIC-compiled fixes (net/radix, netinet, netinet6, wlan, wlan_ccmp, wlan_wep, altq, if_mib) are build-validated; module-only/netgraph/ipfw3/netsmb/vlan/sl/disc fixes apply cleanly to source (those subsystems are optional, not compiled into GENERIC).
A standalone git apply-able fix.diff is in this folder.
Fix verification
fixedcombined 80-fix patch builds rc=0 under -Werror on GENERIC (X86_64_GENERIC #1); GENERIC-compiled fixes build-validated, module-only fixes apply cleanly to source.
baseline 6.5-DEVELOPMENT #0 (Jul 2) -> patched build #1 (Jul 23) rc=0 -Werror, 0 errors
Confirmed kernel references
- s
- y
- s
- /
- n
- e
- t
- /
- a
- l
- t
- q
- /
- a
- l
- t
- q
- _
- c
- b
- q
- .
- c
- :
- 4
- 6
- 9
Detail
Exploit chain
none (Low-severity leak; source-only confirmation)
Evidence (decisive lines)
DF-0652 [REPRODUCED] - sys/net/altq/altq_cbq.c:469
PoC changes
fix.diff present in findings/poc/DF-0652/; batched into ../_batch_low/combined_all.patch
Verified recommended fix
bzero the stats struct before get_class_stats fills it.
Verdict
Source-confirmed: cbq_getqstats declares class_stats_t stats on the stack unzeroed; get_class_stats fills only some fields; whole struct copied to user -> kernel stack leak. altq (GENERIC).
No comments yet.