Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8a0ce7d99a4d19788e017f3138bc59b9962057ae
Commit:     8a0ce7d99a4d19788e017f3138bc59b9962057ae
Parent:     1ac564ecabc777636cf4eb88840802d7dc57d286
Author:     Jeff Layton <[EMAIL PROTECTED]>
AuthorDate: Thu Oct 18 03:05:19 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Thu Oct 18 14:37:22 2007 -0700

    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 <[EMAIL PROTECTED]>
    Cc: Neil Brown <[EMAIL PROTECTED]>
    Cc: "J. Bruce Fields" <[EMAIL PROTECTED]>
    Cc: Christoph Hellwig <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/nfsd/vfs.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 819545d..46934c9 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,
        if (iap->ia_valid & ATTR_MODE) {
                iap->ia_mode &= 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)
+                       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)
+                       iap->ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV;
+               if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
+                       iap->ia_valid |= ATTR_KILL_SGID;
        }
 
-       /* Revoke setuid/setgid bit on chown/chgrp */
-       if ((iap->ia_valid & ATTR_UID) && iap->ia_uid != inode->i_uid)
-               iap->ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV;
-       if ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid)
-               iap->ia_valid |= ATTR_KILL_SGID;
-
        /* Change the attributes. */
 
        iap->ia_valid |= ATTR_CTIME;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to