From 9e61fb1f70cf844d68e9992d4e6670068cd0acc3 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 18 Jun 2020 09:53:34 +0200 Subject: [PATCH] tree-wide: wipe references to questionable apis from our public logs We can't do anything about the established kernel API but we can at least not propagate the terminology. Signed-off-by: Christian Brauner --- src/lxc/attach.c | 8 ++------ src/lxc/cmd/lxc_usernsexec.c | 2 +- src/lxc/conf.c | 19 +++++++++---------- src/lxc/conf.h | 2 +- src/lxc/lsm/apparmor.c | 2 +- src/lxc/lxccontainer.c | 20 +++++--------------- src/lxc/start.c | 2 +- src/lxc/storage/rsync.c | 8 ++------ src/lxc/storage/storage_utils.c | 7 ++----- 9 files changed, 24 insertions(+), 46 deletions(-) diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 1b7e5c650..38e16f2d1 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -194,12 +194,8 @@ int lxc_attach_remount_sys_proc(void) if (ret < 0) return log_error_errno(-1, errno, "Failed to unshare mount namespace"); - if (detect_shared_rootfs()) { - if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) { - SYSERROR("Failed to make / rslave"); - ERROR("Continuing..."); - } - } + if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) + SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing..."); /* Assume /proc is always mounted, so remount it. */ ret = umount2("/proc", MNT_DETACH); diff --git a/src/lxc/cmd/lxc_usernsexec.c b/src/lxc/cmd/lxc_usernsexec.c index 3c22482f4..aee7448ce 100644 --- a/src/lxc/cmd/lxc_usernsexec.c +++ b/src/lxc/cmd/lxc_usernsexec.c @@ -103,7 +103,7 @@ static int do_child(void *vargv) if (detect_shared_rootfs()) { ret = mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL); if (ret < 0) { - CMD_SYSINFO("Failed to make \"/\" rslave"); + CMD_SYSINFO("Failed to recursively turn root mount tree into dependent mount"); return -1; } } diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 13f7619fd..4aafca3cb 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -1232,7 +1232,7 @@ static int lxc_mount_rootfs(struct lxc_conf *conf) if (!rootfs->path) { ret = mount("", "/", NULL, MS_SLAVE | MS_REC, 0); if (ret < 0) - return log_error_errno(-1, errno, "Failed to remount \"/\" MS_REC | MS_SLAVE"); + return log_error_errno(-1, errno, "Failed to recursively turn root mount tree into dependent mount"); return 0; } @@ -1409,12 +1409,12 @@ static int lxc_pivot_root(const char *rootfs) if (ret < 0) return log_error_errno(-1, errno, "Failed to enter old root directory"); - /* Make oldroot rslave to make sure our umounts don't propagate to the + /* Make oldroot a depedent mount to make sure our umounts don't propagate to the * host. */ ret = mount("", ".", "", MS_SLAVE | MS_REC, NULL); if (ret < 0) - return log_error_errno(-1, errno, "Failed to make oldroot rslave"); + return log_error_errno(-1, errno, "Failed to recursively turn old root mount tree into dependent mount"); ret = umount2(".", MNT_DETACH); if (ret < 0) @@ -2923,8 +2923,8 @@ void tmp_proc_unmount(struct lxc_conf *lxc_conf) lxc_conf->tmp_umount_proc = false; } -/* Walk /proc/mounts and change any shared entries to slave. */ -void remount_all_slave(void) +/* Walk /proc/mounts and change any shared entries to dependent mounts. */ +void turn_into_dependent_mounts(void) { __do_free char *line = NULL; __do_fclose FILE *f = NULL; @@ -3001,13 +3001,12 @@ again: null_endofword(target); ret = mount(NULL, target, NULL, MS_SLAVE, NULL); if (ret < 0) { - SYSERROR("Failed to make \"%s\" MS_SLAVE", target); - ERROR("Continuing..."); + SYSERROR("Failed to recursively turn old root mount tree into dependent mount. Continuing..."); continue; } - TRACE("Remounted \"%s\" as MS_SLAVE", target); + TRACE("Recursively turned old root mount tree into dependent mount"); } - TRACE("Remounted all mount table entries as MS_SLAVE"); + TRACE("Turned all mount table entries into dependent mount"); } static int lxc_execute_bind_init(struct lxc_handler *handler) @@ -3083,7 +3082,7 @@ int lxc_setup_rootfs_prepare_root(struct lxc_conf *conf, const char *name, return log_trace(0, "Bind mounted container / onto itself"); } - remount_all_slave(); + turn_into_dependent_mounts(); ret = run_lxc_hooks(name, "pre-mount", conf, NULL); if (ret < 0) diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 17cec5d59..b72afbaa5 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -451,7 +451,7 @@ extern int parse_mntopts(const char *mntopts, unsigned long *mntflags, char **mntdata); extern int parse_propagationopts(const char *mntopts, unsigned long *pflags); extern void tmp_proc_unmount(struct lxc_conf *lxc_conf); -extern void remount_all_slave(void); +extern void turn_into_dependent_mounts(void); extern void suggest_default_idmap(void); extern FILE *make_anonymous_mount_file(struct lxc_list *mount, bool include_nesting_helpers); diff --git a/src/lxc/lsm/apparmor.c b/src/lxc/lsm/apparmor.c index cef95c854..02f824f97 100644 --- a/src/lxc/lsm/apparmor.c +++ b/src/lxc/lsm/apparmor.c @@ -121,7 +121,7 @@ static const char AA_PROFILE_BASE[] = " # deny reads from debugfs\n" " deny /sys/kernel/debug/{,**} rwklx,\n" "\n" -" # allow paths to be made slave, shared, private or unbindable\n" +" # allow paths to be made dependent, shared, private or unbindable\n" " # TODO: This currently doesn't work due to the apparmor parser treating those as allowing all mounts.\n" "# mount options=(rw,make-slave) -> **,\n" "# mount options=(rw,make-rslave) -> **,\n" diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c index f872a5f70..51422a56d 100644 --- a/src/lxc/lxccontainer.c +++ b/src/lxc/lxccontainer.c @@ -1065,7 +1065,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a ret = mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL); if (ret < 0) { - SYSERROR("Failed to make / rslave at startup"); + SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing..."); lxc_put_handler(handler); ret = 1; goto on_error; @@ -1345,14 +1345,8 @@ static bool create_run_template(struct lxc_container *c, char *tpath, _exit(EXIT_FAILURE); } - ret = detect_shared_rootfs(); - if (ret == 1) { - ret = mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL); - if (ret < 0) { - SYSERROR("Failed to make \"/\" rslave"); - ERROR("Continuing..."); - } - } + if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) + SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing..."); } if (strcmp(bdev->type, "dir") != 0 && strcmp(bdev->type, "btrfs") != 0) { @@ -3671,12 +3665,8 @@ static int clone_update_rootfs(struct clone_update_data *data) return -1; } - if (detect_shared_rootfs()) { - if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL)) { - SYSERROR("Failed to make / rslave"); - ERROR("Continuing..."); - } - } + if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) + SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing..."); if (bdev->ops->mount(bdev) < 0) { storage_put(bdev); diff --git a/src/lxc/start.c b/src/lxc/start.c index 5d5797226..fd969c433 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -1935,7 +1935,7 @@ int __lxc_start(struct lxc_handler *handler, struct lxc_operations *ops, } INFO("Unshared CLONE_NEWNS"); - remount_all_slave(); + turn_into_dependent_mounts(); ret = lxc_setup_rootfs_prepare_root(conf, name, lxcpath); if (ret < 0) { ERROR("Error setting up rootfs mount as root before spawn"); diff --git a/src/lxc/storage/rsync.c b/src/lxc/storage/rsync.c index 97678dea2..2e4df2537 100644 --- a/src/lxc/storage/rsync.c +++ b/src/lxc/storage/rsync.c @@ -78,12 +78,8 @@ int lxc_rsync(struct rsync_data *data) return -1; } - ret = detect_shared_rootfs(); - if (ret) { - ret = mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL); - if (ret < 0) - SYSERROR("Failed to make \"/\" a slave mount"); - } + if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) + SYSERROR("Failed to recursively turn root mount tree into dependent mount"); ret = orig->ops->mount(orig); if (ret < 0) { diff --git a/src/lxc/storage/storage_utils.c b/src/lxc/storage/storage_utils.c index a3ee353e5..f96bd520b 100644 --- a/src/lxc/storage/storage_utils.c +++ b/src/lxc/storage/storage_utils.c @@ -165,11 +165,8 @@ int detect_fs(struct lxc_storage *bdev, char *type, int len) if (unshare(CLONE_NEWNS) < 0) _exit(EXIT_FAILURE); - if (detect_shared_rootfs()) - if (mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) { - SYSERROR("Failed to make / rslave"); - ERROR("Continuing..."); - } + if (detect_shared_rootfs() && mount(NULL, "/", NULL, MS_SLAVE | MS_REC, NULL)) + SYSERROR("Failed to recursively turn root mount tree into dependent mount. Continuing..."); ret = mount_unknown_fs(srcdev, bdev->dest, bdev->mntopts); if (ret < 0) { -- 2.47.2