Commit 5fa8e0a1 authored by Jan Kara's avatar Jan Kara Committed by Al Viro

fs: Rename file_remove_suid() to file_remove_privs()

file_remove_suid() is a misnomer since it removes also file capabilities
stored in xattrs and sets S_NOSEC flag. Also should_remove_suid() tells
something else than whether file_remove_suid() call is necessary which
leads to bugs.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 2426f391
...@@ -1748,7 +1748,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, ...@@ -1748,7 +1748,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
} }
current->backing_dev_info = inode_to_bdi(inode); current->backing_dev_info = inode_to_bdi(inode);
err = file_remove_suid(file); err = file_remove_privs(file);
if (err) { if (err) {
mutex_unlock(&inode->i_mutex); mutex_unlock(&inode->i_mutex);
goto out; goto out;
......
...@@ -959,7 +959,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -959,7 +959,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from)
pos = iocb->ki_pos; pos = iocb->ki_pos;
count = iov_iter_count(from); count = iov_iter_count(from);
err = file_remove_suid(file); err = file_remove_privs(file);
if (err) if (err)
goto out; goto out;
......
...@@ -1169,7 +1169,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -1169,7 +1169,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (err <= 0) if (err <= 0)
goto out; goto out;
err = file_remove_suid(file); err = file_remove_privs(file);
if (err) if (err)
goto out; goto out;
......
...@@ -1685,7 +1685,11 @@ static int __remove_suid(struct dentry *dentry, int kill) ...@@ -1685,7 +1685,11 @@ static int __remove_suid(struct dentry *dentry, int kill)
return notify_change(dentry, &newattrs, NULL); return notify_change(dentry, &newattrs, NULL);
} }
int file_remove_suid(struct file *file) /*
* Remove special file priviledges (suid, capabilities) when file is written
* to or truncated.
*/
int file_remove_privs(struct file *file)
{ {
struct dentry *dentry = file->f_path.dentry; struct dentry *dentry = file->f_path.dentry;
struct inode *inode = d_inode(dentry); struct inode *inode = d_inode(dentry);
...@@ -1711,7 +1715,7 @@ int file_remove_suid(struct file *file) ...@@ -1711,7 +1715,7 @@ int file_remove_suid(struct file *file)
return error; return error;
} }
EXPORT_SYMBOL(file_remove_suid); EXPORT_SYMBOL(file_remove_privs);
/** /**
* file_update_time - update mtime and ctime time * file_update_time - update mtime and ctime time
...@@ -1966,9 +1970,8 @@ EXPORT_SYMBOL(inode_dio_wait); ...@@ -1966,9 +1970,8 @@ EXPORT_SYMBOL(inode_dio_wait);
* inode is being instantiated). The reason for the cmpxchg() loop * inode is being instantiated). The reason for the cmpxchg() loop
* --- which wouldn't be necessary if all code paths which modify * --- which wouldn't be necessary if all code paths which modify
* i_flags actually followed this rule, is that there is at least one * i_flags actually followed this rule, is that there is at least one
* code path which doesn't today --- for example, * code path which doesn't today so we use cmpxchg() out of an abundance
* __generic_file_aio_write() calls file_remove_suid() without holding * of caution.
* i_mutex --- so we use cmpxchg() out of an abundance of caution.
* *
* In the long run, i_mutex is overkill, and we should probably look * In the long run, i_mutex is overkill, and we should probably look
* at using the i_lock spinlock to protect i_flags, and then make sure * at using the i_lock spinlock to protect i_flags, and then make sure
......
...@@ -382,7 +382,7 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb, ...@@ -382,7 +382,7 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb,
base_ni = ni; base_ni = ni;
if (NInoAttr(ni)) if (NInoAttr(ni))
base_ni = ni->ext.base_ntfs_ino; base_ni = ni->ext.base_ntfs_ino;
err = file_remove_suid(file); err = file_remove_privs(file);
if (unlikely(err)) if (unlikely(err))
goto out; goto out;
/* /*
......
...@@ -623,7 +623,7 @@ xfs_file_aio_write_checks( ...@@ -623,7 +623,7 @@ xfs_file_aio_write_checks(
* setgid bits if the process is not being run by root. This keeps * setgid bits if the process is not being run by root. This keeps
* people from modifying setuid and setgid binaries. * people from modifying setuid and setgid binaries.
*/ */
return file_remove_suid(file); return file_remove_privs(file);
} }
/* /*
......
...@@ -2553,7 +2553,7 @@ extern struct inode *new_inode_pseudo(struct super_block *sb); ...@@ -2553,7 +2553,7 @@ extern struct inode *new_inode_pseudo(struct super_block *sb);
extern struct inode *new_inode(struct super_block *sb); extern struct inode *new_inode(struct super_block *sb);
extern void free_inode_nonrcu(struct inode *inode); extern void free_inode_nonrcu(struct inode *inode);
extern int should_remove_suid(struct dentry *); extern int should_remove_suid(struct dentry *);
extern int file_remove_suid(struct file *); extern int file_remove_privs(struct file *);
extern void __insert_inode_hash(struct inode *, unsigned long hashval); extern void __insert_inode_hash(struct inode *, unsigned long hashval);
static inline void insert_inode_hash(struct inode *inode) static inline void insert_inode_hash(struct inode *inode)
......
...@@ -2536,7 +2536,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -2536,7 +2536,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
/* We can write back this queue in page reclaim */ /* We can write back this queue in page reclaim */
current->backing_dev_info = inode_to_bdi(inode); current->backing_dev_info = inode_to_bdi(inode);
err = file_remove_suid(file); err = file_remove_privs(file);
if (err) if (err)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment