diff options
| author | Jan Kara <jack@suse.cz> | 2015-05-21 10:05:53 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-06-23 18:01:08 -0400 |
| commit | 5fa8e0a1c6a762857ae67d1628c58b9a02362003 (patch) | |
| tree | 53072ae36f38d4b3c1c56defff4b98acb274c077 /fs | |
| parent | 2426f3910069ed47c0cc58559a6d088af7920201 (diff) | |
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: Jan Kara <jack@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/btrfs/file.c | 2 | ||||
| -rw-r--r-- | fs/ceph/file.c | 2 | ||||
| -rw-r--r-- | fs/fuse/file.c | 2 | ||||
| -rw-r--r-- | fs/inode.c | 13 | ||||
| -rw-r--r-- | fs/ntfs/file.c | 2 | ||||
| -rw-r--r-- | fs/xfs/xfs_file.c | 2 |
6 files changed, 13 insertions, 10 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index b072e17479aa..86f97282779a 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
| @@ -1748,7 +1748,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, | |||
| 1748 | } | 1748 | } |
| 1749 | 1749 | ||
| 1750 | current->backing_dev_info = inode_to_bdi(inode); | 1750 | current->backing_dev_info = inode_to_bdi(inode); |
| 1751 | err = file_remove_suid(file); | 1751 | err = file_remove_privs(file); |
| 1752 | if (err) { | 1752 | if (err) { |
| 1753 | mutex_unlock(&inode->i_mutex); | 1753 | mutex_unlock(&inode->i_mutex); |
| 1754 | goto out; | 1754 | goto out; |
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 3b6b522b4b31..e55fe32c6224 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
| @@ -959,7 +959,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
| 959 | 959 | ||
| 960 | pos = iocb->ki_pos; | 960 | pos = iocb->ki_pos; |
| 961 | count = iov_iter_count(from); | 961 | count = iov_iter_count(from); |
| 962 | err = file_remove_suid(file); | 962 | err = file_remove_privs(file); |
| 963 | if (err) | 963 | if (err) |
| 964 | goto out; | 964 | goto out; |
| 965 | 965 | ||
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 5ef05b5c4cff..1344647965dc 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
| @@ -1169,7 +1169,7 @@ static ssize_t fuse_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
| 1169 | if (err <= 0) | 1169 | if (err <= 0) |
| 1170 | goto out; | 1170 | goto out; |
| 1171 | 1171 | ||
| 1172 | err = file_remove_suid(file); | 1172 | err = file_remove_privs(file); |
| 1173 | if (err) | 1173 | if (err) |
| 1174 | goto out; | 1174 | goto out; |
| 1175 | 1175 | ||
diff --git a/fs/inode.c b/fs/inode.c index 07f4cb5eab4b..849210c155dc 100644 --- a/fs/inode.c +++ b/fs/inode.c | |||
| @@ -1685,7 +1685,11 @@ static int __remove_suid(struct dentry *dentry, int kill) | |||
| 1685 | return notify_change(dentry, &newattrs, NULL); | 1685 | return notify_change(dentry, &newattrs, NULL); |
| 1686 | } | 1686 | } |
| 1687 | 1687 | ||
| 1688 | int file_remove_suid(struct file *file) | 1688 | /* |
| 1689 | * Remove special file priviledges (suid, capabilities) when file is written | ||
| 1690 | * to or truncated. | ||
| 1691 | */ | ||
| 1692 | int file_remove_privs(struct file *file) | ||
| 1689 | { | 1693 | { |
| 1690 | struct dentry *dentry = file->f_path.dentry; | 1694 | struct dentry *dentry = file->f_path.dentry; |
| 1691 | struct inode *inode = d_inode(dentry); | 1695 | struct inode *inode = d_inode(dentry); |
| @@ -1711,7 +1715,7 @@ int file_remove_suid(struct file *file) | |||
| 1711 | 1715 | ||
| 1712 | return error; | 1716 | return error; |
| 1713 | } | 1717 | } |
| 1714 | EXPORT_SYMBOL(file_remove_suid); | 1718 | EXPORT_SYMBOL(file_remove_privs); |
| 1715 | 1719 | ||
| 1716 | /** | 1720 | /** |
| 1717 | * file_update_time - update mtime and ctime time | 1721 | * file_update_time - update mtime and ctime time |
| @@ -1966,9 +1970,8 @@ EXPORT_SYMBOL(inode_dio_wait); | |||
| 1966 | * inode is being instantiated). The reason for the cmpxchg() loop | 1970 | * inode is being instantiated). The reason for the cmpxchg() loop |
| 1967 | * --- which wouldn't be necessary if all code paths which modify | 1971 | * --- which wouldn't be necessary if all code paths which modify |
| 1968 | * i_flags actually followed this rule, is that there is at least one | 1972 | * i_flags actually followed this rule, is that there is at least one |
| 1969 | * code path which doesn't today --- for example, | 1973 | * code path which doesn't today so we use cmpxchg() out of an abundance |
| 1970 | * __generic_file_aio_write() calls file_remove_suid() without holding | 1974 | * of caution. |
| 1971 | * i_mutex --- so we use cmpxchg() out of an abundance of caution. | ||
| 1972 | * | 1975 | * |
| 1973 | * In the long run, i_mutex is overkill, and we should probably look | 1976 | * In the long run, i_mutex is overkill, and we should probably look |
| 1974 | * at using the i_lock spinlock to protect i_flags, and then make sure | 1977 | * at using the i_lock spinlock to protect i_flags, and then make sure |
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index 7bb487e663b4..182bb93aa79c 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
| @@ -382,7 +382,7 @@ static ssize_t ntfs_prepare_file_for_write(struct kiocb *iocb, | |||
| 382 | base_ni = ni; | 382 | base_ni = ni; |
| 383 | if (NInoAttr(ni)) | 383 | if (NInoAttr(ni)) |
| 384 | base_ni = ni->ext.base_ntfs_ino; | 384 | base_ni = ni->ext.base_ntfs_ino; |
| 385 | err = file_remove_suid(file); | 385 | err = file_remove_privs(file); |
| 386 | if (unlikely(err)) | 386 | if (unlikely(err)) |
| 387 | goto out; | 387 | goto out; |
| 388 | /* | 388 | /* |
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 8121e75352ee..f3e4fbb59985 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
| @@ -623,7 +623,7 @@ restart: | |||
| 623 | * setgid bits if the process is not being run by root. This keeps | 623 | * setgid bits if the process is not being run by root. This keeps |
| 624 | * people from modifying setuid and setgid binaries. | 624 | * people from modifying setuid and setgid binaries. |
| 625 | */ | 625 | */ |
| 626 | return file_remove_suid(file); | 626 | return file_remove_privs(file); |
| 627 | } | 627 | } |
| 628 | 628 | ||
| 629 | /* | 629 | /* |
