aboutsummaryrefslogtreecommitdiffstats
path: root/fs/splice.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2006-10-17 13:43:22 -0400
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-10-19 14:53:09 -0400
commit8c34e2d63231d4bf4852bac8521883944d770fe3 (patch)
tree13e3332384bd1c5844d7827066815ae0ae75f8aa /fs/splice.c
parent01de85e057328ecbef36e108673b1e81059d54c1 (diff)
[PATCH] Remove SUID when splicing into an inode
Originally from Mark Fasheh <mark.fasheh@oracle.com> generic_file_splice_write() does not remove S_ISUID or S_ISGID. This is inconsistent with the way we generally write to files. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'fs/splice.c')
-rw-r--r--fs/splice.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/splice.c b/fs/splice.c
index 68e20e65c6e1..49fb9f129938 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -845,6 +845,10 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
845 ssize_t ret; 845 ssize_t ret;
846 int err; 846 int err;
847 847
848 err = remove_suid(out->f_dentry);
849 if (unlikely(err))
850 return err;
851
848 ret = __splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file); 852 ret = __splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
849 if (ret > 0) { 853 if (ret > 0) {
850 *ppos += ret; 854 *ppos += ret;
@@ -883,12 +887,21 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
883 loff_t *ppos, size_t len, unsigned int flags) 887 loff_t *ppos, size_t len, unsigned int flags)
884{ 888{
885 struct address_space *mapping = out->f_mapping; 889 struct address_space *mapping = out->f_mapping;
890 struct inode *inode = mapping->host;
886 ssize_t ret; 891 ssize_t ret;
892 int err;
893
894 err = should_remove_suid(out->f_dentry);
895 if (unlikely(err)) {
896 mutex_lock(&inode->i_mutex);
897 err = __remove_suid(out->f_dentry, err);
898 mutex_unlock(&inode->i_mutex);
899 if (err)
900 return err;
901 }
887 902
888 ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file); 903 ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file);
889 if (ret > 0) { 904 if (ret > 0) {
890 struct inode *inode = mapping->host;
891
892 *ppos += ret; 905 *ppos += ret;
893 906
894 /* 907 /*
@@ -896,8 +909,6 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
896 * sync it. 909 * sync it.
897 */ 910 */
898 if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) { 911 if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) {
899 int err;
900
901 mutex_lock(&inode->i_mutex); 912 mutex_lock(&inode->i_mutex);
902 err = generic_osync_inode(inode, mapping, 913 err = generic_osync_inode(inode, mapping,
903 OSYNC_METADATA|OSYNC_DATA); 914 OSYNC_METADATA|OSYNC_DATA);