mirror of
https://github.com/systemd/systemd
synced 2024-07-21 10:17:21 +00:00
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.
This commit is contained in:
parent
ba9778d9b7
commit
0ffa4c7c4b
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue