From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Max Kellermann <max.kellermann@ionos.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Tejun Heo <tj@kernel.org>, Zefan Li <lizefan.x@bytedance.com>,
Johannes Weiner <hannes@cmpxchg.org>,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Subject: Re: [PATCH v2 2/2] fs/kernfs/dir: obey S_ISGID
Date: Thu, 21 Dec 2023 13:57:37 +0700 [thread overview]
Message-ID: <ZYPh4T21-6DAbxq5@archie.me> (raw)
In-Reply-To: <20231208093310.297233-2-max.kellermann@ionos.com>
[-- Attachment #1: Type: text/plain, Size: 1686 bytes --]
On Fri, Dec 08, 2023 at 10:33:10AM +0100, Max Kellermann wrote:
> Handling of S_ISGID is usually done by inode_init_owner() in all other
> filesystems, but kernfs doesn't use that function. In kernfs, struct
> kernfs_node is the primary data structure, and struct inode is only
> created from it on demand. Therefore, inode_init_owner() can't be
> used and we need to imitate its behavior.
>
> S_ISGID support is useful for the cgroup filesystem; it allows
> subtrees managed by an unprivileged process to retain a certain owner
> gid, which then enables sharing access to the subtree with another
> unprivileged process.
>
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> Acked-by: Tejun Heo <tj@kernel.org>
> --
> v1 -> v2: minor coding style fix (comment)
> ---
> fs/kernfs/dir.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 8b2bd65d70e7..62d39ecf0a46 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -676,6 +676,18 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent,
> {
> struct kernfs_node *kn;
>
> + if (parent->mode & S_ISGID) {
> + /* this code block imitates inode_init_owner() for
> + * kernfs
> + */
> +
> + if (parent->iattr)
> + gid = parent->iattr->ia_gid;
> +
> + if (flags & KERNFS_DIR)
> + mode |= S_ISGID;
> + }
> +
> kn = __kernfs_new_node(kernfs_root(parent), parent,
> name, mode, uid, gid, flags);
> if (kn) {
No noticeable regressions with this patch applied.
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
--
An old man doll... just what I always wanted! - Clara
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-12-21 6:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-08 9:33 [PATCH v2 1/2] kernel/cgroup: use kernfs_create_dir_ns() Max Kellermann
2023-12-08 9:33 ` [PATCH v2 2/2] fs/kernfs/dir: obey S_ISGID Max Kellermann
2023-12-21 6:57 ` Bagas Sanjaya [this message]
2023-12-20 16:33 ` [PATCH v2 1/2] kernel/cgroup: use kernfs_create_dir_ns() Michal Koutný
2023-12-21 6:56 ` Bagas Sanjaya
2023-12-21 21:29 ` Tejun Heo
2023-12-22 6:15 ` Greg Kroah-Hartman
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=ZYPh4T21-6DAbxq5@archie.me \
--to=bagasdotme@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan.x@bytedance.com \
--cc=max.kellermann@ionos.com \
--cc=tj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®