]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fs: use consistent setgid checks in is_sxid()
authorChristian Brauner <brauner@kernel.org>
Sat, 18 Mar 2023 10:15:28 +0000 (12:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:30:08 +0000 (13:30 +0100)
commit 8d84e39d76bd83474b26cb44f4b338635676e7e8 upstream.

Now that we made the VFS setgid checking consistent an inode can't be
marked security irrelevant even if the setgid bit is still set. Make
this function consistent with all other helpers.

Note that enforcing consistent setgid stripping checks for file
modification and mode- and ownership changes will cause the setgid bit
to be lost in more cases than useed to be the case. If an unprivileged
user wrote to a non-executable setgid file that they don't have
privilege over the setgid bit will be dropped. This will lead to
temporary failures in some xfstests until they have been updated.

Reported-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/fs.h

index 57afa4fa5e7b1e2b4e89b93e8960926ebf9e8f19..8ce9e5c61ede805445ceeb2a53dfbc5c06c1c24b 100644 (file)
@@ -3408,7 +3408,7 @@ int __init get_filesystem_list(char *buf);
 
 static inline bool is_sxid(umode_t mode)
 {
-       return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP));
+       return mode & (S_ISUID | S_ISGID);
 }
 
 static inline int check_sticky(struct inode *dir, struct inode *inode)