You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Two cleanup/parsing nits: nvc_cfg NULL deref on OOM paths, sscanf %x into int #409
Two smaller hardening notes from the same audit pass that reported #408 — bundling them in one issue since neither is urgent on its own.
1. nvc_cfg can be NULL on the OOM cleanup paths
src/cli/configure.c:481 and src/cli/list.c:293 both do:
if ((nvc=libnvc.context_new()) ==NULL|| (nvc_cfg=libnvc.config_new()) ==NULL) { warn(...); goto fail; }
...
fail:
free(nvc_cfg->imex.chans); /* nvc_cfg may be NULL here */
If context_new() fails (calloc returns NULL under memory pressure — runc hooks do run under container memory limits), the fail: path dereferences nvc_cfg->imex.chans with nvc_cfg == NULL. The sibling cleanups all guard their NULLs (libnvc.shutdown(nvc) etc. handle it); these two spots don't. Fix is the obvious guard:
- free(nvc_cfg->imex.chans);+ if (nvc_cfg != NULL) {+ free(nvc_cfg->imex.chans);+ }
Haven't reproduced at runtime (would need calloc failure injection), but the deref is clear from the code.
with int domainid, busid, deviceid. The upstream build log itself carries the gcc warning — %x wants unsigned int *, not int *. Input is attacker-controlled (NVIDIA_VISIBLE_DEVICES → --device=), and values ≥ INT_MAX are undefined per the C standard. In practice glibc's scanf just folds the value, and sanitized runs with ffffffff:99:99.0, ffffffffffffffff:99:99.0, etc. all produced clean "unknown device" rejections — no UBSan/ASan report, so this is paper UB rather than a live fault on glibc. Fix is to make the three variables unsigned int.
Both spotted during a full make debug (ASan/UBSan) audit pass of v1.20.2 (c7727e5); the sanitized end-to-end configure run itself was clean, so these are the only cleanup/parsing nits left standing from that pass besides #408.
Activity