From: Christian Brauner <brauner@kernel.org>
To: fstests@vger.kernel.org, Eryu Guan <guan@eryu.me>
Cc: Christoph Hellwig <hch@lst.de>,
Seth Forshee <sforshee@digitalocean.com>,
Christian Brauner <christian.brauner@ubuntu.com>,
Seth Forshee <seth.forshee@digitalocean.com>,
Eryu Guan <guaneryu@gmail.com>
Subject: [PATCH 3/3] idmapped-mounts: add missing ownership comparisons to setgid tests
Date: Fri, 7 Jan 2022 15:44:36 +0100 [thread overview]
Message-ID: <20220107144436.332389-3-brauner@kernel.org> (raw)
In-Reply-To: <20220107144436.332389-1-brauner@kernel.org>
From: Christian Brauner <christian.brauner@ubuntu.com>
In some setgid tests we missed to check ownership right after file or
directory creation in order to verify whether gid ownership inheritance
from the parent directory to the newly created file or directory works
correctly. Add the missing ones.
Cc: Seth Forshee <seth.forshee@digitalocean.com>
Cc: Eryu Guan <guaneryu@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: fstests@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
src/idmapped-mounts/idmapped-mounts.c | 38 +++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
index c53e1942..a5c0a983 100644
--- a/src/idmapped-mounts/idmapped-mounts.c
+++ b/src/idmapped-mounts/idmapped-mounts.c
@@ -7863,6 +7863,12 @@ static int setgid_create(void)
if (!is_setgid(t_dir1_fd, DIR1, 0))
die("failure: is_setgid");
+ if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0))
+ die("failure: check ownership");
+
+ if (!expected_uid_gid(t_dir1_fd, DIR1, 0, 0, 0))
+ die("failure: check ownership");
+
if (unlinkat(t_dir1_fd, FILE1, 0))
die("failure: delete");
@@ -7911,6 +7917,22 @@ static int setgid_create(void)
die("failure: is_setgid");
}
+ /*
+ * In setgid directories newly created files always inherit the
+ * gid from the parent directory. Verify that the file is owned
+ * by gid 0, not by gid 10000.
+ */
+ if (!expected_uid_gid(t_dir1_fd, FILE1, 0, 0, 0))
+ die("failure: check ownership");
+
+ /*
+ * In setgid directories newly created directories always
+ * inherit the gid from the parent directory. Verify that the
+ * directory is owned by gid 0, not by gid 10000.
+ */
+ if (!expected_uid_gid(t_dir1_fd, DIR1, 0, 0, 0))
+ die("failure: check ownership");
+
exit(EXIT_SUCCESS);
}
if (wait_for_pid(pid))
@@ -8013,6 +8035,22 @@ static int setgid_create_idmapped(void)
die("failure: is_setgid");
}
+ /*
+ * In setgid directories newly created files always inherit the
+ * gid from the parent directory. Verify that the file is owned
+ * by gid 10000, not by gid 11000.
+ */
+ if (!expected_uid_gid(open_tree_fd, FILE1, 0, 10000, 10000))
+ die("failure: check ownership");
+
+ /*
+ * In setgid directories newly created directories always
+ * inherit the gid from the parent directory. Verify that the
+ * directory is owned by gid 10000, not by gid 11000.
+ */
+ if (!expected_uid_gid(open_tree_fd, DIR1, 0, 10000, 10000))
+ die("failure: check ownership");
+
exit(EXIT_SUCCESS);
}
if (wait_for_pid(pid))
--
2.32.0
next prev parent reply other threads:[~2022-01-07 14:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-07 14:44 [PATCH 1/3] idmapped-mounts: remove redundant fchownat() call in setgid tests Christian Brauner
2022-01-07 14:44 ` [PATCH 2/3] idmapped-mounts: add more explanations to " Christian Brauner
2022-01-07 14:44 ` Christian Brauner [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-01-07 14:58 [PATCH 1/3] idmapped-mounts: remove redundant fchownat() call in " Christian Brauner
2022-01-07 14:58 ` [PATCH 3/3] idmapped-mounts: add missing ownership comparisons to " Christian Brauner
2022-01-10 9:11 ` Christoph Hellwig
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=20220107144436.332389-3-brauner@kernel.org \
--to=brauner@kernel.org \
--cc=christian.brauner@ubuntu.com \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--cc=guaneryu@gmail.com \
--cc=hch@lst.de \
--cc=seth.forshee@digitalocean.com \
--cc=sforshee@digitalocean.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).