mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Prevent user DoS by mounting /run/lock as separate tmpfs
This patch does several things related to /run and system reliability. - Mount /run with MAX 10% of usable RAM - Create and mount /run/lock as a separate tmpfs with max 5 MiB As a spin-off, this patch also fixes permisions on /run/lock to 0777 so regular users can create lock files. Note: none of this code runs if /run is mounted alread in /etc/fstab Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
b1a058ccdd
commit
073b040981
1 file changed
+16
-3
+16
-3
@@ -215,9 +215,22 @@ static void fs_finalize(void)
|
|||||||
mount("devpts", "/dev/pts", "devpts", 0, "gid=5,mode=620,ptmxmode=0666");
|
mount("devpts", "/dev/pts", "devpts", 0, "gid=5,mode=620,ptmxmode=0666");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modern systems use tmpfs for /run */
|
/*
|
||||||
if (!fismnt("/run"))
|
* Modern systems use tmpfs for /run. Fallback to /var/run if
|
||||||
mount("tmpfs", "/run", "tmpfs", MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME, "mode=0755");
|
* /run doesn't exist is handled by the bootmisc plugin. It
|
||||||
|
* also sets up compat symlinks.
|
||||||
|
*
|
||||||
|
* The unconditional mount of /run/lock is for DoS prevention.
|
||||||
|
* To override any of this behavior, add entries to /etc/fstab
|
||||||
|
* for /run (and optionally /run/lock).
|
||||||
|
*/
|
||||||
|
if (fisdir("/run") && !fismnt("/run")) {
|
||||||
|
mount("tmpfs", "/run", "tmpfs", MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME, "mode=0755,size=10%");
|
||||||
|
|
||||||
|
/* This prevents user DoS of /run by filling /run/lock at the expense of another tmpfs, max 5MiB */
|
||||||
|
makedir("/run/lock", 1777);
|
||||||
|
mount("tmpfs", "/run/lock", "tmpfs", MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_RELATIME, "mode=0777,size=5252880");
|
||||||
|
}
|
||||||
|
|
||||||
/* Modern systems use tmpfs for /tmp */
|
/* Modern systems use tmpfs for /tmp */
|
||||||
if (!fismnt("/tmp"))
|
if (!fismnt("/tmp"))
|
||||||
|
|||||||
Reference in new issue
Block a user