Browse Source

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse

Pull fuse fix from Miklos Szeredi:
 "Fix a regression spotted by Jeff Layton"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse:
  fuse: fix clearing suid, sgid for chown()
Linus Torvalds 8 years ago
parent
commit
ce779d6b5b
1 changed files with 2 additions and 5 deletions
  1. 2 5
      fs/fuse/dir.c

+ 2 - 5
fs/fuse/dir.c

@@ -1739,8 +1739,6 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
 		 * This should be done on write(), truncate() and chown().
 		 * This should be done on write(), truncate() and chown().
 		 */
 		 */
 		if (!fc->handle_killpriv) {
 		if (!fc->handle_killpriv) {
-			int kill;
-
 			/*
 			/*
 			 * ia_mode calculation may have used stale i_mode.
 			 * ia_mode calculation may have used stale i_mode.
 			 * Refresh and recalculate.
 			 * Refresh and recalculate.
@@ -1750,12 +1748,11 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
 				return ret;
 				return ret;
 
 
 			attr->ia_mode = inode->i_mode;
 			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_valid |= ATTR_MODE;
 				attr->ia_mode &= ~S_ISUID;
 				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_valid |= ATTR_MODE;
 				attr->ia_mode &= ~S_ISGID;
 				attr->ia_mode &= ~S_ISGID;
 			}
 			}