sys_lwp_rtprio() with tid == -1 ignores the target pid and always operates on the caller's own lwp
| Field | Value |
|---|---|
| ID | DF-2794 |
| Status | new |
| Severity | Info |
| CVSS 3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:N |
| CWE | CWE-670 Inconsistent Implementation |
| File | sys/kern/kern_resource.c |
| Lines | 588-593 |
| Area | kern |
| Confidence | certain |
| Discovered | 2026-08-31 |
| Pass | 2 (GLM 5.3 second pass) |
| Bucket | base:kern |
| Reported | pending |
| Known CVE | none |
| CVE match | novel |
Summary
tid == -1 ("sadly, tid can be 0 so we can't use 0 here") resolves lp =
curthread->td_lwp regardless of uap->pid. RTP_SET/RTP_LOOKUP with
pid=
Recommended fix
When pid != 0 and tid == -1, resolve lp from the target (FIRST_LWP_IN_PROC(p) with the DF-2791 NULL check), or reject the combination with EINVAL.
Timeline
- 2026-08-31 Discovered during pass-2 audit of kern_resource.c (GLM 5.3).
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-2794 Β· 10 files| File | Type | Description | Size | |
|---|---|---|---|---|
| README.md | β | 706 B | β raw | |
| VERDICT.md | β | 947 B | β raw | |
| build.sh | β | 69 B | view raw | |
| env.txt | β | 509 B | view raw | |
| fix.diff | β | 640 B | view raw | |
| manifest.json | β | 545 B | view raw | |
| rtprio_tid.c | β | 1.5 KB | view raw | |
| run.log | β | 150 B | view raw | |
| run.sh | β | 83 B | view raw | |
| verdict.json | β | 2.3 KB | view raw |
DF-2794 β sys_lwp_rtprio tid==-1 mis-targets caller lwp (Info-tier hardening verification)
What
sys_lwp_rtprio tid==-1 mis-targets caller lwp
Build
cc -Wall -O2 -o rtprio_tid rtprio_tid.c
Run
./rtprio_tid (as root)
Expected
baseline (stock kernel): see verdict below fix kernel (all-41-fixes build): the bad behavior is gone
Files
README.md VERDICT.md build.sh env.txt fix.diff manifest.json rtprio_tid.c run.log run.sh verdict.json
Shared harness: h41.c (combined KLD, sysctl debug.h41.cmd=N driven).
Full batch context: the fix kernel contains all 41 hardening fixes of
this batch compiled together (build RC=0) and passed the complete A/B
suite plus a clean reboot.
DF-2794 β VERDICT
status: reproduced | reproduced: 1 | impact: none | confidence: certain
Mechanically reproduced as root on the stock guest: fork a child; lwp_rtprio(RTP_SET, pid=child, tid=-1, {RTP_PRIO_REALTIME,31}) returns 0 (success), and the CALLER parent's own rtprio then reads back type=0 prio=31 while the call was directed at the child pid - sys_lwp_rtprio resolves lp = curthread->td_lwp whenever tid==-1 regardless of the target pid (kern_resource.c:588-593 region), with the EPERM credentials check still evaluated against the TARGET process ucred (no privilege boundary is crossed; unprivileged RTP_SET on another pid is refused before any mis-targeting). On the fix kernel the same call leaves the parent at type=1 prio=0 (normal) and returns success - the operation went to the target process's first LWP.
Baseline vs fix kernel
baseline: see verdict above / run log fix: behavior changed as designed (see verdict)
Fix verification
fixedA/B: baseline parent becomes REALTIME/31 from a child-directed call; fix kernel parent stays NORMAL - the tid==-1 case now resolves from the target process (RB_ROOT with NULL check) when pid differs.
Confirmed kernel references
Detail
Evidence (decisive lines)
run.log baseline: parent type 1->0 prio 0->31 after a child-directed RTP_SET; fix kernel: parent unchanged (type=1 prio=0)
PoC changes
libc provides lwp_rtprio(3); RTP_real is RTP_PRIO_REALTIME on DragonFly; SYS number 498
Verified recommended fix
When pid differs from curproc resolve the target first LWP (RB_ROOT + ESRCH on empty)
Verdict
Mechanically reproduced as root on the stock guest: fork a child; lwp_rtprio(RTP_SET, pid=child, tid=-1, {RTP_PRIO_REALTIME,31}) returns 0 (success), and the CALLER parents own rtprio then reads back type=0 prio=31 while the call was directed at the child pid - sys_lwp_rtprio resolves lp = curthread->td_lwp whenever tid==-1 regardless of the target pid (kern_resource.c:588-593 region), with the EPERM credentials check still evaluated against the TARGET process ucred (no privilege boundary is crossed; unprivileged RTP_SET on another pid is refused before any mis-targeting). On the fix kernel the same call leaves the parent at type=1 prio=0 (normal) and returns success - the operation went to the target processs first LWP.
No comments yet.