β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-2696

sorecvtcp(): MSG_OOB + sio path is missing 'm = m_free(m)' β€” repeated sbappend of the same mbuf corrupts the caller's sockbuf (latent, currently unreachable)

Field Value
ID DF-2696
Status new
Severity Low
CVSS 3.1 CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:N/A:L
CWE CWE-835 β†’ CWE-763 (latent)
File sys/kern/uipc_socket.c
Lines 1648-1653 (correct twin at 1294-1299)
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

In sorecvtcp()'s MSG_OOB handler with a non-NULL sio (in-kernel receive-into-mbuf callers), the loop appends m and decrements resid but omits the m = m_free(m); that the identical branch in generic soreceive() has. Consequences if ever reached: the same mbuf chain is appended into sio repeatedly (sb_cc over-accounting, self-referential m_next chains β†’ later m_freem walk never terminates) and an m_len==0 OOB reply spins the loop forever with no locks held. Currently unreachable: every sio!=NULL caller (nfs, ipfw3_sync, wg, smb, ng_ksocket) never passes MSG_OOB, and userland cannot supply sio.

--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1649,6 +1649,7 @@ sorecvtcp(struct socket *so, struct sockaddr **psa, struct uio *uio,
                sbappend(sio, m);
                KKASSERT(resid >= (size_t)m->m_len);
                resid -= (size_t)m->m_len;
+               m = m_free(m);
            } while (resid > 0 && m);

Timeline

  • 2026-08-30 Discovered during pass-2 audit of uipc_socket.c (GLM 5.3).

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2696 Β· 1 files
FileTypeDescriptionSize
fix.diff β€” 357 B view raw

Fix verification

not_testable
baseline no→ patch + rebuild →patched clean

One-line symmetry fix (m = m_free(m)) compile-validated in the fix-all kernel build; no runtime trigger exists (unreachable by construction).

compile-validated in the fix-all kernel build (make nativekernel, 0 errors)
↓ fix.diffper-fix-DF-2696

Confirmed kernel references

Detail

Evidence (decisive lines)

code diff between uipc_socket.c:1294-1299 (correct) and :1648-1653 (missing m_free)

PoC changes

n/a

Verified recommended fix

--- sys/kern/uipc_socket.c 2026-10-12 23:59:41.452294599 +0000

Verdict

Code-verified but unreachable at runtime, exactly as the finding itself states. The MSG_OOB+sio loop in sorecvtcp (sys/kern/uipc_socket.c:1648-1653) lacks the m = m_free(m) that the identical soreceive branch has at :1294-1299, so it would sbappend the same mbuf chain repeatedly (sb_cc over-accounting, self-referential chain, non-terminating m_freem). Every in-tree caller of the sio interface (nfs, ipfw3_sync, wg, smb, ng_ksocket) is kernel-internal and none passes MSG_OOB; userland cannot supply an sio. No runtime trigger exists on a stock guest, so the defect cannot be exercised without patching a caller. The one-line symmetry fix is included in fix.diff and compile-validated.