From: Jan Kara <jack@suse.cz>
To: <fstests@vger.kernel.org>
Cc: Christian Brauner <christian.brauner@ubuntu.com>,
Jan Kara <jack@suse.cz>
Subject: [PATCH 2/2] generic/633: Avoid failure without CONFIG_USER_NS
Date: Thu, 31 Mar 2022 13:19:20 +0200 [thread overview]
Message-ID: <20220331111920.8377-3-jack@suse.cz> (raw)
In-Reply-To: <20220331111920.8377-1-jack@suse.cz>
Some tests in idmapped_mounts fail without CONFIG_USER_NS because they
have implicit dependence on user namespaces and these tests are run
despite idmapped mount support not being detected. Detect whether at
least user namespaces are supported and skip tests needing them when
they are not.
Signed-off-by: Jan Kara <jack@suse.cz>
---
src/idmapped-mounts/idmapped-mounts.c | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
index d3b27da6c085..93c44510348e 100644
--- a/src/idmapped-mounts/idmapped-mounts.c
+++ b/src/idmapped-mounts/idmapped-mounts.c
@@ -127,6 +127,8 @@ char t_buf[PATH_MAX];
/* whether the underlying filesystem supports idmapped mounts */
bool t_fs_allow_idmap;
+/* whether the system supports user namespaces */
+bool t_has_userns;
static void stash_overflowuid(void)
{
@@ -13831,6 +13833,7 @@ static const struct option longopts[] = {
/* Flags for which functionality is required by the test */
#define T_REQUIRE_IDMAPPED_MOUNTS (1U << 0)
+#define T_REQUIRE_USERNS (1U << 1)
struct t_idmapped_mounts {
int (*test)(void);
@@ -13841,7 +13844,7 @@ struct t_idmapped_mounts {
{ create_in_userns, T_REQUIRE_IDMAPPED_MOUNTS, "create operations in user namespace", },
{ device_node_in_userns, T_REQUIRE_IDMAPPED_MOUNTS, "device node in user namespace", },
{ expected_uid_gid_idmapped_mounts, T_REQUIRE_IDMAPPED_MOUNTS, "expected ownership on idmapped mounts", },
- { fscaps, 0, "fscaps on regular mounts", },
+ { fscaps, T_REQUIRE_USERNS, "fscaps on regular mounts", },
{ fscaps_idmapped_mounts, T_REQUIRE_IDMAPPED_MOUNTS, "fscaps on idmapped mounts", },
{ fscaps_idmapped_mounts_in_userns, T_REQUIRE_IDMAPPED_MOUNTS, "fscaps on idmapped mounts in user namespace", },
{ fscaps_idmapped_mounts_in_userns_separate_userns, T_REQUIRE_IDMAPPED_MOUNTS, "fscaps on idmapped mounts in user namespace with different id mappings", },
@@ -13853,7 +13856,7 @@ struct t_idmapped_mounts {
{ hardlink_from_idmapped_mount_in_userns, T_REQUIRE_IDMAPPED_MOUNTS, "hardlinks from idmapped mounts in user namespace", },
#ifdef HAVE_LIBURING_H
{ io_uring, 0, "io_uring", },
- { io_uring_userns, 0, "io_uring in user namespace", },
+ { io_uring_userns, T_REQUIRE_USERNS, "io_uring in user namespace", },
{ io_uring_idmapped, T_REQUIRE_IDMAPPED_MOUNTS, "io_uring from idmapped mounts", },
{ io_uring_idmapped_userns, T_REQUIRE_IDMAPPED_MOUNTS, "io_uring from idmapped mounts in user namespace", },
{ io_uring_idmapped_unmapped, T_REQUIRE_IDMAPPED_MOUNTS, "io_uring from idmapped mounts with unmapped ids", },
@@ -13939,8 +13942,9 @@ static bool run_test(struct t_idmapped_mounts suite[], size_t suite_size)
* If the underlying filesystems does not support idmapped
* mounts only run vfs generic tests.
*/
- if (t->support_flags & T_REQUIRE_IDMAPPED_MOUNTS &&
- !t_fs_allow_idmap) {
+ if ((t->support_flags & T_REQUIRE_IDMAPPED_MOUNTS &&
+ !t_fs_allow_idmap) ||
+ (t->support_flags & T_REQUIRE_USERNS && !t_has_userns)) {
log_debug("Skipping test %s", t->description);
continue;
}
@@ -13998,6 +14002,16 @@ static bool fs_allow_idmap(void)
return ret == 0;
}
+static bool sys_has_userns(void)
+{
+ int fd = get_userns_fd(0, 1000, 1);
+
+ if (fd < 0)
+ return false;
+ close(fd);
+ return true;
+}
+
int main(int argc, char *argv[])
{
int fret, ret;
@@ -14084,6 +14098,7 @@ int main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
+ t_has_userns = sys_has_userns();
stash_overflowuid();
stash_overflowgid();
--
2.34.1
next prev parent reply other threads:[~2022-03-31 11:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-31 11:19 [PATCH 0/2] Fix generic/633 failure on systems without CONFIG_USER_NS Jan Kara
2022-03-31 11:19 ` [PATCH 1/2] idmapped_mounts: Prepare for support for more features Jan Kara
2022-03-31 11:38 ` Christian Brauner
2022-03-31 11:19 ` Jan Kara [this message]
2022-03-31 11:38 ` [PATCH 2/2] generic/633: Avoid failure without CONFIG_USER_NS Christian Brauner
2022-03-31 11:39 ` [PATCH 0/2] Fix generic/633 failure on systems " Christian Brauner
2022-04-20 17:59 ` Christian Brauner
2022-04-25 13:18 ` Zorro Lang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220331111920.8377-3-jack@suse.cz \
--to=jack@suse.cz \
--cc=christian.brauner@ubuntu.com \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.