Skip to content

Commit

Permalink
Remove suid/sgid bits on [f]truncate()
Browse files Browse the repository at this point in the history
.. 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>
  • Loading branch information
Linus Torvalds committed May 9, 2007
1 parent 1efd48b commit 7b82dc0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
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);
err = notify_change(dentry, &newattrs);
mutex_unlock(&dentry->d_inode->i_mutex);
Expand Down

0 comments on commit 7b82dc0

Please sign in to comment.