diff mbox series

fuse: pass ATTR_KILL_SUID/ATTR_KILL_SGID mode bits to user space

Message ID 20230921022436.1191166-1-xiubli@redhat.com (mailing list archive)
State New, archived
Headers show
Series fuse: pass ATTR_KILL_SUID/ATTR_KILL_SGID mode bits to user space | expand

Commit Message

Xiubo Li Sept. 21, 2023, 2:24 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

Such as for the xfstest-dev's generic/684 test case it will clear
suid and sgid if the fallocate request is commit by an unprivileged
user.

We need to pass the ATTR_KILL_SUID/ATTR_KILL_SGID flags to userspace.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/fuse/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Xiubo Li Oct. 7, 2023, 7:50 a.m. UTC | #1
Ping...

On 9/21/23 10:24, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
>
> Such as for the xfstest-dev's generic/684 test case it will clear
> suid and sgid if the fallocate request is commit by an unprivileged
> user.
>
> We need to pass the ATTR_KILL_SUID/ATTR_KILL_SGID flags to userspace.
>
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>   fs/fuse/dir.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index f67bef9d83c4..73dcf54efbff 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1938,11 +1938,11 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
>   
>   			attr->ia_mode = inode->i_mode;
>   			if (inode->i_mode & S_ISUID) {
> -				attr->ia_valid |= ATTR_MODE;
> +				attr->ia_valid |= ATTR_KILL_SUID | ATTR_MODE;
>   				attr->ia_mode &= ~S_ISUID;
>   			}
>   			if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
> -				attr->ia_valid |= ATTR_MODE;
> +				attr->ia_valid |= ATTR_KILL_SGID | ATTR_MODE;
>   				attr->ia_mode &= ~S_ISGID;
>   			}
>   		}
diff mbox series

Patch

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index f67bef9d83c4..73dcf54efbff 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1938,11 +1938,11 @@  static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
 
 			attr->ia_mode = inode->i_mode;
 			if (inode->i_mode & S_ISUID) {
-				attr->ia_valid |= ATTR_MODE;
+				attr->ia_valid |= ATTR_KILL_SUID | ATTR_MODE;
 				attr->ia_mode &= ~S_ISUID;
 			}
 			if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
-				attr->ia_valid |= ATTR_MODE;
+				attr->ia_valid |= ATTR_KILL_SGID | ATTR_MODE;
 				attr->ia_mode &= ~S_ISGID;
 			}
 		}