diff options
-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 | ||||
-rw-r--r-- | include/linux/fs.h | 2 | ||||
-rw-r--r-- | mm/filemap.c | 2 |
8 files changed, 15 insertions, 12 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 | /* |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 2c135ad741a9..641e68d850cf 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2553,7 +2553,7 @@ extern struct inode *new_inode_pseudo(struct super_block *sb); | |||
2553 | extern struct inode *new_inode(struct super_block *sb); | 2553 | extern struct inode *new_inode(struct super_block *sb); |
2554 | extern void free_inode_nonrcu(struct inode *inode); | 2554 | extern void free_inode_nonrcu(struct inode *inode); |
2555 | extern int should_remove_suid(struct dentry *); | 2555 | extern int should_remove_suid(struct dentry *); |
2556 | extern int file_remove_suid(struct file *); | 2556 | extern int file_remove_privs(struct file *); |
2557 | 2557 | ||
2558 | extern void __insert_inode_hash(struct inode *, unsigned long hashval); | 2558 | extern void __insert_inode_hash(struct inode *, unsigned long hashval); |
2559 | static inline void insert_inode_hash(struct inode *inode) | 2559 | static inline void insert_inode_hash(struct inode *inode) |
diff --git a/mm/filemap.c b/mm/filemap.c index 6bf5e42d560a..f851e36802d5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -2536,7 +2536,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) | |||
2536 | 2536 | ||
2537 | /* We can write back this queue in page reclaim */ | 2537 | /* We can write back this queue in page reclaim */ |
2538 | current->backing_dev_info = inode_to_bdi(inode); | 2538 | current->backing_dev_info = inode_to_bdi(inode); |
2539 | err = file_remove_suid(file); | 2539 | err = file_remove_privs(file); |
2540 | if (err) | 2540 | if (err) |
2541 | goto out; | 2541 | goto out; |
2542 | 2542 | ||