summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteev Klimaszewski2026-01-17 04:10:22 +0000
committerDaniel Golle2026-03-14 00:29:08 +0000
commit6dafa862b16cc3dcd1ea7d67febc444b51aed3e2 (patch)
treeada3b6c756085f54d25aa90ef157c9978efd296e
parentc268f13ab8b8e60d69aabc9ee42b9c0b7d191ed5 (diff)
downloadprocd-6dafa862b16cc3dcd1ea7d67febc444b51aed3e2.tar.gz
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> (cherry picked from commit 58d7aaa686979eb852139915a30df33adcb08665)
-rw-r--r--plug/coldplug.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/plug/coldplug.c b/plug/coldplug.c
index f84acef..1925402 100644
--- a/plug/coldplug.c
+++ b/plug/coldplug.c
@@ -49,6 +49,7 @@ void procd_coldplug(void)
umount2("/dev/pts", MNT_DETACH);
umount2("/dev/", MNT_DETACH);
mount("tmpfs", "/dev", "tmpfs", MS_NOATIME | MS_NOEXEC | MS_NOSUID, "mode=0755,size=512K");
+ mknod("/dev/null", S_IFCHR | 0666, makedev(1, 3));
mkdir("/dev/pts", 0755);
mount("devpts", "/dev/pts", "devpts", MS_NOATIME | MS_NOEXEC | MS_NOSUID, 0);
}