From: Evgeny Vereshchagin Date: Thu, 19 Jul 2018 10:24:07 +0000 (+0000) Subject: tests: skip test_get_process_cmdline_harder if `mount --make-rslave /` fails with... X-Git-Tag: v240~925 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0ffa4c7c4bd802b9c291cd94a644b983edeca840;p=thirdparty%2Fsystemd.git tests: skip test_get_process_cmdline_harder if `mount --make-rslave /` fails with EPERM or EACCESS That call to mount was added as a safeguard against a kernel bug which was fixed in torvalds/linux@bbd5192. In principle, the error could be ignored because * normally everything mounted on /proc/PID should disappear as soon as the PID has gone away * test-mount-util that had been confused by those phantom entries in /proc/self/mountinfo was taught to ignore them in 112cc3b. On the other hand, in practice, if the mount fails, then the next one is extremely unlikely to succeed, so it seems to be reasonable to just skip the rest of `test_get_process_cmdline_harder` if that happens. Closes https://github.com/systemd/systemd/issues/9649. --- diff --git a/src/test/test-process-util.c b/src/test/test-process-util.c index 7f3f502c56a..1b3b357913d 100644 --- a/src/test/test-process-util.c +++ b/src/test/test-process-util.c @@ -206,15 +206,21 @@ static void test_get_process_cmdline_harder(void) { assert_se(pid == 0); assert_se(unshare(CLONE_NEWNS) >= 0); - assert_se(mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) >= 0); + if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0) { + log_warning_errno(errno, "mount(..., \"/\", MS_SLAVE|MS_REC, ...) failed: %m"); + assert_se(IN_SET(errno, EPERM, EACCES)); + return; + } fd = mkostemp(path, O_CLOEXEC); assert_se(fd >= 0); + /* Note that we don't unmount the following bind-mount at the end of the test because the kernel + * will clear up its /proc/PID/ hierarchy automatically as soon as the test stops. */ if (mount(path, "/proc/self/cmdline", "bind", MS_BIND, NULL) < 0) { /* This happens under selinux… Abort the test in this case. */ log_warning_errno(errno, "mount(..., \"/proc/self/cmdline\", \"bind\", ...) failed: %m"); - assert(errno == EACCES); + assert_se(IN_SET(errno, EPERM, EACCES)); return; }