aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2007-10-18 06:05:19 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-18 17:37:22 -0400
commit8a0ce7d99a4d19788e017f3138bc59b9962057ae (patch)
tree07b61f8760081e377274f055e0433dc1695b6549 /fs
parent1ac564ecabc777636cf4eb88840802d7dc57d286 (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/vfs.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 819545d21670..46934c97f8f7 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -364,14 +364,23 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
364 if (iap->ia_valid & ATTR_MODE) { 364 if (iap->ia_valid & ATTR_MODE) {
365 iap->ia_mode &= S_IALLUGO; 365 iap->ia_mode &= S_IALLUGO;
366 imode = iap->ia_mode |= (imode & ~S_IALLUGO); 366 imode = iap->ia_mode |= (imode & ~S_IALLUGO);
367 /* if changing uid/gid revoke setuid/setgid in mode */
368 if ((iap->ia_valid & ATTR_UID) && iap->ia_uid != inode->i_uid) {
369 iap->ia_valid |= ATTR_KILL_PRIV;
370 iap->ia_mode &= ~S_ISUID;
371 }
372 if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
373 iap->ia_mode &= ~S_ISGID;
374 } else {
375 /*
376 * Revoke setuid/setgid bit on chown/chgrp
377 */
378 if ((iap->ia_valid & ATTR_UID) && iap->ia_uid != inode->i_uid)
379 iap->ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV;
380 if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
381 iap->ia_valid |= ATTR_KILL_SGID;
367 } 382 }
368 383
369 /* Revoke setuid/setgid bit on chown/chgrp */
370 if ((iap->ia_valid & ATTR_UID) && iap->ia_uid != inode->i_uid)
371 iap->ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV;
372 if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
373 iap->ia_valid |= ATTR_KILL_SGID;
374
375 /* Change the attributes. */ 384 /* Change the attributes. */
376 385
377 iap->ia_valid |= ATTR_CTIME; 386 iap->ia_valid |= ATTR_CTIME;