Skip to content

Commit 7e4042a

Browse files
committed
selftests/landlock: Fix FS tests when run on a private mount point
According to the test environment, the mount point of the test's working directory may be shared or not, which changes the visibility of the nested "tmp" mount point for the test's parent process calling umount("tmp"). This was spotted while running tests in containers [1], where mount points are private. Cc: Günther Noack <[email protected]> Cc: Shuah Khan <[email protected]> Link: landlock-lsm/landlock-test-tools#4 [1] Fixes: 41cca05 ("selftests/harness: Fix TEST_F()'s vfork handling") Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mickaël Salaün <[email protected]>
1 parent 37dc2e0 commit 7e4042a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/testing/selftests/landlock/fs_test.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,15 @@ static void prepare_layout(struct __test_metadata *const _metadata)
293293
static void cleanup_layout(struct __test_metadata *const _metadata)
294294
{
295295
set_cap(_metadata, CAP_SYS_ADMIN);
296-
EXPECT_EQ(0, umount(TMP_DIR));
296+
if (umount(TMP_DIR)) {
297+
/*
298+
* According to the test environment, the mount point of the
299+
* current directory may be shared or not, which changes the
300+
* visibility of the nested TMP_DIR mount point for the test's
301+
* parent process doing this cleanup.
302+
*/
303+
ASSERT_EQ(EINVAL, errno);
304+
}
297305
clear_cap(_metadata, CAP_SYS_ADMIN);
298306
EXPECT_EQ(0, remove_path(TMP_DIR));
299307
}

0 commit comments

Comments
 (0)