summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2020-11-26 00:55:20 +0000
committerDaniel Golle2020-11-27 01:06:09 +0000
commitdb5ef866497692d04f6476b08814842f0af4079f (patch)
treef49922236f2dff49a368bb3fcf75b0d4df17b548
parent4ba72ecf3a2c073fada50913655bf644aa389561 (diff)
downloadprocd-db5ef866497692d04f6476b08814842f0af4079f.tar.gz
jail: don't use NULL arguments for mount syscall
Make valgrind more happy Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--jail/fs.c10
-rw-r--r--jail/jail.c8
2 files changed, 9 insertions, 9 deletions
diff --git a/jail/fs.c b/jail/fs.c
index d3046aa..4201973 100644
--- a/jail/fs.c
+++ b/jail/fs.c
@@ -111,10 +111,10 @@ static int do_mount(const char *root, const char *orig_source, const char *targe
return error;
} else {
/* mount-bind 0-sized file having mode 000 */
- if (mount(UJAIL_NOAFILE, new, NULL, MS_BIND, NULL))
+ if (mount(UJAIL_NOAFILE, new, "bind", MS_BIND, NULL))
return error;
- if (mount(UJAIL_NOAFILE, new, NULL, MS_REMOUNT | MS_BIND | MS_RDONLY | MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_NOATIME, NULL))
+ if (mount(UJAIL_NOAFILE, new, "bind", MS_REMOUNT | MS_BIND | MS_RDONLY | MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_NOATIME, NULL))
return error;
}
@@ -137,7 +137,7 @@ static int do_mount(const char *root, const char *orig_source, const char *targe
}
if (is_bind) {
- if (mount(source?:new, new, filesystemtype, MS_BIND | (mountflags & MS_REC), optstr)) {
+ if (mount(source?:new, new, filesystemtype?:"bind", MS_BIND | (mountflags & MS_REC), optstr)) {
if (error)
ERROR("failed to mount -B %s %s: %m\n", source, new);
@@ -150,7 +150,7 @@ static int do_mount(const char *root, const char *orig_source, const char *targe
}
const char *hack_fstype = ((!filesystemtype || strcmp(filesystemtype, "cgroup"))?filesystemtype:"cgroup2");
- if (mount(source?:(is_bind?new:NULL), new, hack_fstype, mountflags, optstr)) {
+ if (mount(source?:(is_bind?new:NULL), new, hack_fstype?:"none", mountflags, optstr)) {
if (error)
ERROR("failed to mount %s %s: %m\n", source, new);
@@ -163,7 +163,7 @@ static int do_mount(const char *root, const char *orig_source, const char *targe
DEBUG("mount %s%s %s (%s)\n", (mountflags & MS_BIND)?"-B ":"", source, new,
(mountflags & MS_RDONLY)?"ro":"rw");
- if (propflags && mount(NULL, new, NULL, propflags, NULL)) {
+ if (propflags && mount("none", new, "none", propflags, NULL)) {
if (error)
ERROR("failed to mount --make-... %s \n", new);
diff --git a/jail/jail.c b/jail/jail.c
index 5f1ca6f..34fec71 100644
--- a/jail/jail.c
+++ b/jail/jail.c
@@ -389,7 +389,7 @@ static int create_dev_console(const char *jail_root)
snprintf(dev_console_path, sizeof(dev_console_path), "%s/dev/console", jail_root);
close(creat(dev_console_path, 0620));
- if (mount(console_fname, dev_console_path, NULL, MS_BIND, NULL))
+ if (mount(console_fname, dev_console_path, "bind", MS_BIND, NULL))
goto no_console;
/* use PTY slave for stdio */
@@ -641,13 +641,13 @@ static int build_jail_fs(void)
}
/* oldroot can't be MS_SHARED else pivot_root() fails */
- if (mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL)) {
+ if (mount("none", "/", "none", MS_REC|MS_PRIVATE, NULL)) {
ERROR("private mount failed %m\n");
return -1;
}
if (opts.extroot) {
- if (mount(opts.extroot, jail_root, NULL, MS_BIND, NULL)) {
+ if (mount(opts.extroot, jail_root, "bind", MS_BIND, NULL)) {
ERROR("extroot mount failed %m\n");
return -1;
}
@@ -761,7 +761,7 @@ static void enter_jail_fs(void)
free_and_exit(-1);
}
if (opts.ronly)
- mount(NULL, "/", NULL, MS_REMOUNT | MS_BIND | MS_RDONLY, 0);
+ mount(NULL, "/", "bind", MS_REMOUNT | MS_BIND | MS_RDONLY, 0);
umask(old_umask);
post_jail_fs();