ng_bridge constructor leaks priv->tab on ng_make_node_common failure
Summary
ng_bridge_constructor() allocates priv->tab (32 buckets, 256B) at :310-315; if ng_make_node_common() fails at :324 it kfrees priv but never kfrees the tab. Reachability effectively kmalloc-failure-only. Negligible standalone; filed for completeness (error-path leaks accumulate in long-lived netgraph deployments). Fix: one kfree.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-3522 Β· 2 files| File | Type | Description | Size | |
|---|---|---|---|---|
| VERDICT.md | verdict | code excerpt + one-line fix | 2.0 KB | β raw |
| verdict.json | verdict | machine verdict | 1.0 KB | view raw |
DF-3522 β ng_bridge constructor leaks priv->tab when ng_make_node_common fails
Status: untested (Low/Info-severity error-path leak; no PoC per the audit contract's skip rule for Info findings). Confidence: certain (code).
sys/netgraph/bridge/ng_bridge.c, constructor:
:310 priv->tab = kmalloc(MIN_BUCKETS * sizeof(*priv->tab), M_NETGRAPH,
:311 M_NOWAIT | M_ZERO);
:312 if (priv->tab == NULL) {
:313 kfree(priv, M_NETGRAPH);
:314 return (ENOMEM);
:315 }
...
:324 if ((error = ng_make_node_common(&ng_bridge_typestruct, nodep))) {
:325 kfree(priv, M_NETGRAPH); /* <-- priv->tab NOT freed */
:326 return (error);
:327 }
At :325 the successfully-allocated priv->tab (32 * sizeof(struct
ng_bridge_bucket) = 256 bytes) is leaked. Reachability: the only
non-ENOMEM failure of ng_make_node_common is "type not registered"
(ng_base.c:386) β impossible for our own registered type β or its
internal node kmalloc failure (M_NOWAIT), i.e. effectively
KMALLOC-failure-only. Impact: negligible in practice (256 B under
extreme memory pressure); filed for completeness since pass 1 missed it
and the fix is one line:
--- a/sys/netgraph/bridge/ng_bridge.c
+++ b/sys/netgraph/bridge/ng_bridge.c
@@ -322,6 +322,7 @@
/* Call superclass constructor */
if ((error = ng_make_node_common(&ng_bridge_typestruct, nodep))) {
+ kfree(priv->tab, M_NETGRAPH);
kfree(priv, M_NETGRAPH);
return (error);
}
Files
VERDICT.md(this file) β no binary PoC (Info severity).
Fix status (batch validation)
Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.
(No fix.diff for this item: documented recommendation only - see Fix above.)
Fix verification
not_testableConfirmed kernel references
Detail
Evidence (decisive lines)
VERDICT.md with code excerpt and one-line fix diff
Verified recommended fix
kfree(priv->tab, M_NETGRAPH) before kfree(priv) in the ng_make_node_common failure branch.
Verdict
Info-severity error-path leak, no PoC per audit contract skip rule for Low/Info: ng_bridge_constructor frees priv but not the successfully allocated priv->tab (256 B) when ng_make_node_common fails (ng_bridge.c:324-326). Only reachable under KMALLOC failure; one-line fix.
No comments yet.