Explorar o código

Remove suid/sgid bits on [f]truncate()

.. to match what we do on write().  This way, people who write to files
by using [f]truncate + writable mmap have the same semantics as if they
were using the write() family of system calls.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Linus Torvalds %!s(int64=18) %!d(string=hai) anos
pai
achega
7b82dc0e64
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      fs/open.c

+ 3 - 0
fs/open.c

@@ -210,6 +210,9 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
 		newattrs.ia_valid |= ATTR_FILE;
 		newattrs.ia_valid |= ATTR_FILE;
 	}
 	}
 
 
+	/* Remove suid/sgid on truncate too */
+	newattrs.ia_valid |= should_remove_suid(dentry);
+
 	mutex_lock(&dentry->d_inode->i_mutex);
 	mutex_lock(&dentry->d_inode->i_mutex);
 	err = notify_change(dentry, &newattrs);
 	err = notify_change(dentry, &newattrs);
 	mutex_unlock(&dentry->d_inode->i_mutex);
 	mutex_unlock(&dentry->d_inode->i_mutex);