Patch "fs/kernfs/dir: obey S_ISGID" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    fs/kernfs/dir: obey S_ISGID

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     fs-kernfs-dir-obey-s_isgid.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 202d5beb3cac5db88e5930c9c3b01e7f9b293caf
Author: Max Kellermann <max.kellermann@xxxxxxxxx>
Date:   Fri Dec 8 10:33:10 2023 +0100

    fs/kernfs/dir: obey S_ISGID
    
    [ Upstream commit 5133bee62f0ea5d4c316d503cc0040cac5637601 ]
    
    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.
    
    --
    v1 -> v2: minor coding style fix (comment)
    
    Signed-off-by: Max Kellermann <max.kellermann@xxxxxxxxx>
    Acked-by: Tejun Heo <tj@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231208093310.297233-2-max.kellermann@xxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 44842e6cf0a9..a00e11ebfa77 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -669,6 +669,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) {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux