Uninitialized `mnt` dereferenced on `mount_with_flags` failure path (src/nvc_mount.c)
还没有人认领这个 Issue。
评估
调研方向
阅读 src/nvc_mount.c 中的 mount_with_flags(),尤其是清理路径 fail:,并将其与初始化 mnt 的相邻挂载辅助函数进行比较。Issue 提供了 AddressSanitizer 复现,并指出需要检查的早期失败情况。完成标准是失败路径能够安全处理未设置的挂载,且复现不再导致崩溃。
由索引模型根据 Issue 内容生成。
描述
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.)
- 主要语言
- C
- 星标
- 1.1k
- 派生
- 278
- 平均合并
- 3 天 7 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
NVIDIA/libnvidia-container 的其他 Issue
-
needs-triage
难度 2/5 1-3 小时 新手友好度 86/100
NVIDIA/libnvidia-container#406 ·
-
needs-triage
难度 2/5 1-3 小时 新手友好度 58/100
NVIDIA/libnvidia-container#409 ·
-
question
难度 3/5 1-2 天 新手友好度 45/100
NVIDIA/libnvidia-container#404 ·
-
OpenSuSE Leap 15.2 is missing可能已有人在做 @gusraggio 于 44 天前认领。 未关闭question
难度 3/5 1-2 天 新手友好度 48/100
NVIDIA/libnvidia-container#100 · 9 条评论 · 1 个 reaction ·
查看 NVIDIA/libnvidia-container 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
isolation2 lockmodes fails on cassert builds: extra AccessShareLock on partition root可能已有人在做 @tuhaihe 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
apache/cloudberry#2356 ·
维护者通常 2 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
-
难度 1/5 1-3 小时 新手友好度 78/100
crosspoint-reader/crosspoint-reader#4535 ·
维护者通常 1 天内回复
-
[core] Clients never advertise RNS_UD_CS_SUPPORT_ERRINFO_PDU, so a conforming server can't send them Set Error Info可能已有人在做 @akallabeth 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
FreeRDP/FreeRDP#14230 · 1 条评论 ·
维护者通常 1 天内回复