libnvidia-egl-wayland2.so.1.0.1 opens the DRM render node without O_CLOEXEC, so the descriptor survives exec() and is inherited by every child process an EGL-Wayland client spawns. Those children keep a GPU handle open for their entire lifetime without knowing it.
Reproducible on a healthy system in one command, driver 595.91.07:
$ strace -f -e trace=openat eglinfo 2>&1 | grep 'dri/render'
openat(AT_FDCWD, "/dev/dri/renderD128", O_RDWR) = 27 <- no O_CLOEXEC
openat(AT_FDCWD, "/dev/dri/renderD128", O_RDWR|O_CLOEXEC) = 11
… eight further opens in the same run, all with O_CLOEXEC …
Ten opens in one eglinfo run: eight set the flag, two do not. strace -k shows the caller is the driver stack, not the application:
> /usr/lib/x86_64-linux-gnu/libc.so.6(__libc_open64+0x57)
> /usr/lib/x86_64-linux-gnu/libnvidia-egl-wayland2.so.1.0.1() [0x805b]
> /usr/lib/x86_64-linux-gnu/libnvidia-egl-wayland2.so.1.0.1() [0x908b]
> /usr/lib/x86_64-linux-gnu/libnvidia-egl-wayland2.so.1.0.1() [0x6261]
> /usr/lib/x86_64-linux-gnu/libEGL_nvidia.so.595.91.07() [0xb4bc9]
> /usr/lib/x86_64-linux-gnu/libEGL_nvidia.so.595.91.07() [0x4f50f]
> /usr/lib/x86_64-linux-gnu/libEGL.so.1.1.0() [0x795e]
Two distinct call paths inside that library leak — return offsets 0x908b/0x6261 and 0x8ef4/0x536c — both entered from libEGL_nvidia.
The file is shipped by the proprietary driver package (libnvidia-gl-595 on Ubuntu), not by the distribution’s separate libnvidia-egl-wayland1 package (1:1.1.21-1 here), so this is NVIDIA’s own build.
Observed effect on a running desktop
A live descriptor census matches the trace exactly. Each EGL-Wayland client holds several render-node descriptors, nearly all O_CLOEXEC, plus one or more that are not:
| process | leaking fd(s) | correct fds |
|---|---|---|
| GPU-accelerated terminal | 7 | 16, 24 |
mutter-x11-frames |
8 | 15, 23 |
gnome-remote-desktop |
33 | 19, 25, 32 |
| an Electron app | 15, 41, 51 | 22, 28, 32, 49 |
gnome-shell |
none | ten, all correct |
Xwayland |
none | all correct |
The inheritance is visible by descriptor number: the terminal’s fd 7 appears as fd 7 in the shell it spawns, and fd 7 in that shell’s children. gnome-shell and Xwayland holding only correct descriptors shows this is one code path rather than the whole stack.
Why it is worth fixing rather than shrugging at
nvidia_drm cannot be unloaded while any process holds a render-node descriptor. Because these leak into arbitrary unrelated children, a long-running process that is not graphical, not using the GPU, and unaware it holds a GPU handle pins the module indefinitely.
I hit this concretely: recovering from a wedged GPU required unloading the driver, and modprobe -r nvidia_drm failed with FATAL: Module nvidia_drm is in use. After stopping the display manager, gnome-remote-desktop and nvidia-persistenced, fuser named a single remaining holder — a terminal multiplexer started months earlier from a GPU-accelerated terminal, holding one leaked descriptor. Freeing it without killing the process required attaching gdb and calling close() on the descriptor, which is not a reasonable recovery step to expect of anyone.
So beyond being a straightforward descriptor-hygiene bug, this actively blocks in-place GPU recovery.
Request
Please add O_CLOEXEC to both open paths in libnvidia-egl-wayland2. Every other render-node open in the same process already sets it, so this looks like an oversight in two specific call sites rather than a deliberate choice.
(Context for why I was unloading the driver at all — an unrelated Xid 62 PMU halt — is in a separate thread: Xid 62 PMU halt on RTX 2080 Ti: identical payload 3x, GSP on and off, GPU unrecoverable. That one is a much harder problem; this one looks like a one-line fix.)