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
Uninitialized mnt dereferenced on mount_with_flags failure path (src/nvc_mount.c) #408
mount_with_flags() in src/nvc_mount.c declares char *mnt without an initializer (:82) and the fail path does unmount(mnt) at :99. All the early exits — file_mode(src), file_create(dst), xmount returning EPERM — jump to fail: before mnt is ever assigned, so cleanup runs on a garbage stack pointer: str_empty() dereferences it (utils.c:171), and if the garbage is non-NULL it also umount2()s and file_remove()/nftw()s a random pointer.
Every other mount helper in the file handles this. mount_procfs_gpu/mount_procfs_mig use char *mnt = NULL, mount_device/mount_ipc fail with unmount(dst), nvc_imex_channel_mount initializes to NULL. mount_with_flags looks like it was missed in the same sweep that fixed the nvc_ldcache.c pointer UB in 1.17.8 (#316/#318) — this one is still broken in v1.20.2 (c7727e5) and on current main.
Deterministic repro: small harness that #includes nvc_mount.c and links the repo's own make debug objects, compiled with -ftrivial-auto-var-init=pattern, calling the function with a failing src:
==469703==ERROR: AddressSanitizer: SEGV on unknown address (pc 0x5583f862b232 bp 0x7fff18909f90 sp 0x7fff18909f78 T0)
==469703==The signal is caused by a READ memory access.
#0 str_empty src/utils.c:171
#1 unmount src/nvc_mount.c:512
#2 mount_with_flags src/nvc_mount.c:99
#3 t_mount_with_flags harness/h2_path.c:103
#4 main harness/h2_path.c:218
SUMMARY: AddressSanitizer: SEGV src/utils.c:171 in str_empty
Exactly where it should fault: unmount(mnt) at :99 reading the never-assigned mnt.
Also hit it end-to-end on the release build: nvidia-container-cli configure with the container rootfs bind-mounted read-only dies at file_create with "read-only file system", which is the same goto fail. In that run the stack slot happened to be benign, so it quietly umount2()d a garbage pointer and exited normally. So in default builds the outcome depends on stack contents: crash, or silent bogus cleanup — never a correct one.
Fix is one line, same as the siblings:
- char *mnt;+ char *mnt = NULL;
(For clarity vs #377: that one is about the cleanup being harmful when it runs correctly on a shared rootfs. Here the cleanup argument itself is uninitialized memory. Different bug, same code region.)
Activity