initd/coldplug: create /dev/null before running udevtrigger
authorSteev Klimaszewski <threeway@gmail.com>
Sat, 17 Jan 2026 04:10:22 +0000 (22:10 -0600)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 9 Feb 2026 11:09:58 +0000 (11:09 +0000)
commit58d7aaa686979eb852139915a30df33adcb08665
treeed5ca13612d40383e7ca9e9d1c341602f19f3dd5
parent64f97ffb6a26582ab0deac87c653723566efe9d9
initd/coldplug: create /dev/null before running udevtrigger

When procd_coldplug() runs, it unmounts /dev and mounts a fresh empty
tmpfs before forking udevtrigger to populate device nodes via hotplug
events. Since udevtrigger runs asynchronously, there is a race window
between the fresh mount and when the "null" device uevent is processed.

If any code executes a shell redirect to /dev/null during this window
(e.g., from hotplug handlers or other event processing), the shell
creates /dev/null as a regular file. When the null device uevent is
later processed, makedev()'s mknod() fails silently with EEXIST,
leaving /dev/null as a regular file permanently.

This causes all subsequent redirections to /dev/null to append to the
file instead of discarding output, eventually filling up the tmpfs.

Fix by explicitly creating /dev/null immediately after mounting the
fresh tmpfs, before any other code can run.

Signed-off-by: Steev Klimaszewski <threeway@gmail.com>
plug/coldplug.c