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 <brauner@kernel.org>,
Eryu Guan <guaneryu@gmail.com>
Subject: [PATCH 2/3] idmapped-mounts: add more explanations to setgid tests
Date: Fri, 7 Jan 2022 15:58:17 +0100 [thread overview]
Message-ID: <20220107145818.336126-2-brauner@kernel.org> (raw)
In-Reply-To: <20220107145818.336126-1-brauner@kernel.org>
The explanations before were a bit thin and people not familiar with
setgid inheritance might get confused. Make it easier to understand the
tests.
Cc: Seth Forshee <sforshee@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>
---
/* v2 */
- Christian Brauner <brauner@kernel.org>:
- fix Seth's mail address in commit message
---
src/idmapped-mounts/idmapped-mounts.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/idmapped-mounts/idmapped-mounts.c b/src/idmapped-mounts/idmapped-mounts.c
index 56b26b0c..c53e1942 100644
--- a/src/idmapped-mounts/idmapped-mounts.c
+++ b/src/idmapped-mounts/idmapped-mounts.c
@@ -8128,6 +8128,14 @@ static int setgid_create_idmapped_in_userns(void)
if (wait_for_pid(pid))
goto out;
+ /*
+ * Below we verify that setgid inheritance for a newly created file or
+ * directory works correctly. As part of this we need to verify that
+ * newly created files or directories inherit their gid from their
+ * parent directory. So we change the parent directorie's gid to 1000
+ * and create a file with fs{g,u}id 0 and verify that the newly created
+ * file and directory inherit gid 1000, not 0.
+ */
if (fchownat(t_dir1_fd, "", -1, 1000, AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) {
log_stderr("failure: fchownat");
goto out;
@@ -8172,12 +8180,19 @@ static int setgid_create_idmapped_in_userns(void)
die("failure: is_setgid");
}
- /* Files and directories created in setgid directories inherit
- * the i_gid of the parent directory.
+ /*
+ * In setgid directories newly created files always inherit the
+ * gid from the parent directory. Verify that the file is owned
+ * by gid 1000, not by gid 0.
*/
if (!expected_uid_gid(open_tree_fd, FILE1, 0, 0, 1000))
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 1000, not by gid 0.
+ */
if (!expected_uid_gid(open_tree_fd, DIR1, 0, 0, 1000))
die("failure: check ownership");
--
2.32.0
next prev parent reply other threads:[~2022-01-07 14:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-07 14:58 [PATCH 1/3] idmapped-mounts: remove redundant fchownat() call in setgid tests Christian Brauner
2022-01-07 14:58 ` Christian Brauner [this message]
2022-01-10 9:10 ` [PATCH 2/3] idmapped-mounts: add more explanations to " Christoph Hellwig
2022-01-07 14:58 ` [PATCH 3/3] idmapped-mounts: add missing ownership comparisons " Christian Brauner
2022-01-10 9:11 ` Christoph Hellwig
2022-01-10 9:10 ` [PATCH 1/3] idmapped-mounts: remove redundant fchownat() call in " Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2022-01-07 14:44 Christian Brauner
2022-01-07 14:44 ` [PATCH 2/3] idmapped-mounts: add more explanations to " Christian Brauner
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=20220107145818.336126-2-brauner@kernel.org \
--to=brauner@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--cc=guaneryu@gmail.com \
--cc=hch@lst.de \
--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).