]> git.baikalelectronics.ru Git - kernel.git/commitdiff
fs: use consistent setgid checks in is_sxid()
authorChristian Brauner <brauner@kernel.org>
Tue, 22 Nov 2022 10:40:32 +0000 (11:40 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Mar 2023 10:52:25 +0000 (11:52 +0100)
commit d239847da87d359541f6230703b620b9741bb613 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 ed555aa9bf4852dc607f22dabb07ad1281914730..f14ecbeab2a9d8b6aa8f1c9e695df0b8d52a902a 100644 (file)
@@ -3549,7 +3549,7 @@ int __init list_bdev_fs_names(char *buf, size_t size);
 
 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 user_namespace *mnt_userns,