nvidia-drm: NULL dereference in nv_drm_create_sync_file() when sync_file_create() fails (kernel oops when fs.file-max is exhausted)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
- #1606 來自 @mliemm —— 已關閉,未合併
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 82/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- c, linux
研究方向
閱讀 kernel-open/nvidia-drm/nvidia-drm-os-interface.c,重點查看 nv_drm_create_sync_file() 和回報中提到的 sync_file_create() 失敗行為。將失敗檢查與 issue 中引用的樹內 DRM 範例 drm_syncobj_export_sync_file() 進行比較。完成標準是:建立 sync file 失敗時,fence 建立會傳回錯誤並釋放已保留的 fd,且不解參照 NULL。
由索引模型根據 Issue 內容生成。
描述
NVIDIA Open GPU Kernel Modules Version
620.73.04
Please confirm this issue does not happen with the proprietary driver (of the same version). This issue tracker is only for bugs specific to the open kernel driver.
- I confirm that this does not happen with the proprietary driver package.
Operating System and Version
CachyOS (rolling)
Kernel Release
Linux 7.3.6-3-cachyos #1 SMP PREEMPT_DYNAMIC Thu, 26 Nov 2026 16:11:45 +0000 x86_64 GNU/Linux (distro kernel, not self-built)
Please confirm you are running a stable release kernel (e.g. not a -rc). We do not accept bug reports for unreleased kernels.
- I am running on a stable kernel release.
Hardware: GPU
GPU 0: NVIDIA GeForce RTX 5080 (UUID: GPU-f6c30581-16c3-721e-ecaf-685cda3f529b) GPU 1: NVIDIA GeForce RTX 5060 Ti (UUID: GPU-92315ee8-941f-bfbe-0d68-d09e038f3491)
Describe the bug
When the system-wide file table is full (fs.file-max reached), DRM_IOCTL_NVIDIA_SEMSURF_FENCE_CREATE oopses the kernel with a NULL pointer dereference in nv_drm_create_sync_file().
kernel-open/nvidia-drm/nvidia-drm-os-interface.c (tag 620.73.04):
int nv_drm_create_sync_file(struct dma_fence *fence)
{
struct sync_file *sync;
int fd = get_unused_fd_flags(O_CLOEXEC);
...
sync = sync_file_create(fence);
if (IS_ERR(sync)) { /* <-- sync_file_create() returns NULL on failure, not ERR_PTR */
put_unused_fd(fd);
return PTR_ERR(sync);
}
fd_install(fd, sync->file); /* <-- NULL dereference */
return fd;
}
sync_file_create() (drivers/dma-buf/sync_file.c) returns NULL when it fails. One way it fails is when anon_inode_getfile() returns -ENFILE because fs.file-max is reached. get_unused_fd_flags() only reserves a slot in the process's fd table, so it still succeeds at that point, and the failure appears only in sync_file_create(). IS_ERR(NULL) is false, so the driver goes on to read sync->file and dereferences NULL.
Oops (full logs attached):
VFS: file-max limit 2097152 reached
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor read access in kernel mode
Oops: Oops: 0000 [#1] SMP NOPTI
CPU: 21 UID: 1000 PID: 3320 Comm: ghostty Tainted: G OE 7.3.6-3-cachyos #1 PREEMPT(full)
RIP: 0010:nv_drm_create_sync_file+0x3e/0x60 [nvidia_drm]
RAX: 0000000000000000 ... R14: 0000000000000000
Call Trace:
nv_drm_semsurf_fence_create_ioctl+0x10e/0x1c0 [nvidia_drm]
drm_ioctl+0x268/0x530
x64_sys_call+0x328/0x3c0
do_syscall_64+0x93/0x390
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Expected: the ioctl fails with an error (e.g. -ENOMEM), and the client sees a failed call instead of the kernel oopsing. The in-tree DRM code that does the same thing (e.g. drm_syncobj_export_sync_file()) checks for NULL.
Suggested fix:
- if (IS_ERR(sync)) {
+ if (!sync) {
put_unused_fd(fd);
- return PTR_ERR(sync);
+ return -ENOMEM;
}
The file-table limit can be filled by an unprivileged process, so any unprivileged user can crash the kernel this way, in effect a local denial of service.
To Reproduce
What triggered it here:
- KDE Plasma 6.8 Wayland session (kwin) on the RTX 5080, with GPU clients running (ghostty, Firefox).
- fs.file-max = 2097152 (the CachyOS default).
- Start a large parallel Lean 4 build (
lake build, 32 jobs). Eachleanprocess memory-maps about 31K .olean files, which uses up the system-wide file table in about 2 minutes. - The next explicit-sync fence creation by any GPU client (ghostty, or Firefox's Renderer thread) oopses inside nv_drm_create_sync_file().
Simpler repro (not tested, but follows from the code above):
- Fill the system file table, e.g. lower fs.file-max to slightly above the current value in /proc/sys/fs/file-nr, or open/mmap files until you get ENFILE.
- Make any Wayland GL/Vulkan client render a frame (anything that issues DRM_IOCTL_NVIDIA_SEMSURF_FENCE_CREATE).
Workaround: raise fs.file-max so it isn't reached.
Bug Incidence
Always
nvidia-bug-report.log.gz
Attached. It was collected after the reboot, so it doesn't include the oops. The full oops logs from pstore are attached separately:
nvidia-bug-report.log.gz
panic1-0612-ghostty-7.3.6-2.txt
panic2-0635-firefox-renderer-7.3.6-3.txt
panic3-0638-ghostty-7.3.6-3.txt
More Info
- The machine has kernel.panic_on_oops=1 (set to capture crash dumps), so each oops became a full panic. With default settings, I'd expect the client to be killed and the system to keep running in a degraded state.
- An apparently identical earlier crash: Fedora ABRT report https://retrace.fedoraproject.org/faf/reports/1366876/ (Fedora 42, kernel 6.16.7, 2025-10-30):
RIP: nv_drm_create_sync_file+0x33/0x60 [nvidia_drm]called fromnv_drm_semsurf_fence_create_ioctl, NULL read. So the bug isn't specific to this kernel, GPU generation or driver release. - nvidia-drm source is shipped open in both the open and proprietary packages, so the proprietary package very likely has the same bug.
- 主要語言
- C
- 星號
- 17.7k
- 分支
- 2k
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
NVIDIA/open-gpu-kernel-modules 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
NVIDIA/open-gpu-kernel-modules#1479 · 2 則留言 ·
維護者通常 1 天內回覆
-
PlatformRequestHandler: missing !bInit guard on bSystemParamLimitUpdate causes NV_ERR_INVALID_DATA at boot可能已有人在做 @SammyTourani 於 69 天前認領。 未關閉
難度 1/5 1 小時以內 新手友好度 88/100
NVIDIA/open-gpu-kernel-modules#1360 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
NVIDIA/open-gpu-kernel-modules#1343 · 3 則留言 ·
維護者通常 1 天內回覆
-
HKC G27H7Pro redundant long-HPD loop after DisplayPort link training (RTX 5060 Laptop, 610.57.04)未關閉bug
難度 2/5 1-3 小時 新手友好度 88/100
NVIDIA/open-gpu-kernel-modules#1323 ·
維護者通常 1 天內回覆
查看 NVIDIA/open-gpu-kernel-modules 的全部 Issue
相似的 Issue
-
iOS: the "Edit controls" button never hides, even with a controller connected, and covers the game未關閉game: 010065A014024000 ios
難度 2/5 1-3 小時 新手友好度 76/100
seedds/nxnative#3714 · 1 則留言 ·
維護者通常 2 天內回覆
-
area/docdb kind/enhancement mvu-pg15-pg19 priority/low
難度 2/5 1-3 小時 新手友好度 76/100
yugabyte/yugabyte-db#40355 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 74/100
Jstar269/nakagawa-recomp#3753 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 72/100
ly05010419/MacNativeGames#2474 ·
維護者通常 1 天內回覆