diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2016-12-06 16:18:45 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2017-02-23 03:51:02 +0000 |
commit | 6d1f19c6c03cc1a2c6b8862a411db88d70f4e697 (patch) | |
tree | ba6692d54fb8b255a6852a5e78bf3a5868cdc88f /fs/fuse | |
parent | f05f3a72f505ed1ab46b6a50cb1e67c0cf975545 (diff) | |
download | linux-stable-6d1f19c6c03cc1a2c6b8862a411db88d70f4e697.tar.gz linux-stable-6d1f19c6c03cc1a2c6b8862a411db88d70f4e697.tar.bz2 linux-stable-6d1f19c6c03cc1a2c6b8862a411db88d70f4e697.zip |
fuse: fix clearing suid, sgid for chown()
commit c01638f5d919728f565bf8b5e0a6a159642df0d9 upstream.
Basically, the pjdfstests set the ownership of a file to 06555, and then
chowns it (as root) to a new uid/gid. Prior to commit a09f99eddef4 ("fuse:
fix killing s[ug]id in setattr"), fuse would send down a setattr with both
the uid/gid change and a new mode. Now, it just sends down the uid/gid
change.
Technically this is NOTABUG, since POSIX doesn't _require_ that we clear
these bits for a privileged process, but Linux (wisely) has done that and I
think we don't want to change that behavior here.
This is caused by the use of should_remove_suid(), which will always return
0 when the process has CAP_FSETID.
In fact we really don't need to be calling should_remove_suid() at all,
since we've already been indicated that we should remove the suid, we just
don't want to use a (very) stale mode for that.
This patch should fix the above as well as simplify the logic.
Reported-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: a09f99eddef4 ("fuse: fix killing s[ug]id in setattr")
Reviewed-by: Jeff Layton <jlayton@redhat.com>
[bwh: Backported to 3.2: adjust context, indentation]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/dir.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 4041f76dd6c4..d0f57b18c01c 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -1398,8 +1398,6 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr) int ret; if (attr->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID)) { - int kill; - attr->ia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_MODE); /* @@ -1411,12 +1409,11 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr) return ret; attr->ia_mode = inode->i_mode; - kill = should_remove_suid(entry); - if (kill & ATTR_KILL_SUID) { + if (inode->i_mode & S_ISUID) { attr->ia_valid |= ATTR_MODE; attr->ia_mode &= ~S_ISUID; } - if (kill & ATTR_KILL_SGID) { + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { attr->ia_valid |= ATTR_MODE; attr->ia_mode &= ~S_ISGID; } |