mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-18 23:54:26 +08:00
knfsd: only set ATTR_KILL_S*ID if ATTR_MODE isn't being explicitly set
It's theoretically possible for a single SETATTR call to come in that sets the mode and the uid/gid. In that case, don't set the ATTR_KILL_S*ID bits since that would trip the BUG() in notify_change. Just fix up the mode to have the same effect. Signed-off-by: Jeff Layton <jlayton@redhat.com> Cc: Neil Brown <neilb@suse.de> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
1ac564ecab
commit
8a0ce7d99a
@ -364,13 +364,22 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
|||||||
if (iap->ia_valid & ATTR_MODE) {
|
if (iap->ia_valid & ATTR_MODE) {
|
||||||
iap->ia_mode &= S_IALLUGO;
|
iap->ia_mode &= S_IALLUGO;
|
||||||
imode = iap->ia_mode |= (imode & ~S_IALLUGO);
|
imode = iap->ia_mode |= (imode & ~S_IALLUGO);
|
||||||
|
/* if changing uid/gid revoke setuid/setgid in mode */
|
||||||
|
if ((iap->ia_valid & ATTR_UID) && iap->ia_uid != inode->i_uid) {
|
||||||
|
iap->ia_valid |= ATTR_KILL_PRIV;
|
||||||
|
iap->ia_mode &= ~S_ISUID;
|
||||||
}
|
}
|
||||||
|
if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
|
||||||
/* Revoke setuid/setgid bit on chown/chgrp */
|
iap->ia_mode &= ~S_ISGID;
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* Revoke setuid/setgid bit on chown/chgrp
|
||||||
|
*/
|
||||||
if ((iap->ia_valid & ATTR_UID) && iap->ia_uid != inode->i_uid)
|
if ((iap->ia_valid & ATTR_UID) && iap->ia_uid != inode->i_uid)
|
||||||
iap->ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV;
|
iap->ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV;
|
||||||
if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
|
if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
|
||||||
iap->ia_valid |= ATTR_KILL_SGID;
|
iap->ia_valid |= ATTR_KILL_SGID;
|
||||||
|
}
|
||||||
|
|
||||||
/* Change the attributes. */
|
/* Change the attributes. */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user