Commit 13d32f27 authored by Ben Hutchings's avatar Ben Hutchings Committed by Greg Kroah-Hartman

splice: Apply generic position and size checks to each write

commit 894c6350 from the 3.2-stable branch.

We need to check the position and size of file writes against various
limits, using generic_write_check().  This was not being done for
the splice write path.  It was fixed upstream by commit 8d020765
("->splice_write() via ->write_iter()") but we can't apply that.

CVE-2014-7822
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
[Ben fixed it in 3.2 stable, i ported it to 3.10 stable]
Signed-off-by: default avatarZhang Zhen <zhenzhang.zhang@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1ca630d9
...@@ -2459,12 +2459,14 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe, ...@@ -2459,12 +2459,14 @@ static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
struct address_space *mapping = out->f_mapping; struct address_space *mapping = out->f_mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
struct splice_desc sd = { struct splice_desc sd = {
.total_len = len,
.flags = flags, .flags = flags,
.pos = *ppos,
.u.file = out, .u.file = out,
}; };
ret = generic_write_checks(out, ppos, &len, 0);
if(ret)
return ret;
sd.total_len = len;
sd.pos = *ppos;
trace_ocfs2_file_splice_write(inode, out, out->f_path.dentry, trace_ocfs2_file_splice_write(inode, out, out->f_path.dentry,
(unsigned long long)OCFS2_I(inode)->ip_blkno, (unsigned long long)OCFS2_I(inode)->ip_blkno,
......
...@@ -1012,13 +1012,17 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out, ...@@ -1012,13 +1012,17 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
struct address_space *mapping = out->f_mapping; struct address_space *mapping = out->f_mapping;
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
struct splice_desc sd = { struct splice_desc sd = {
.total_len = len,
.flags = flags, .flags = flags,
.pos = *ppos,
.u.file = out, .u.file = out,
}; };
ssize_t ret; ssize_t ret;
ret = generic_write_checks(out, ppos, &len, S_ISBLK(inode->i_mode));
if (ret)
return ret;
sd.total_len = len;
sd.pos = *ppos;
pipe_lock(pipe); pipe_lock(pipe);
splice_from_pipe_begin(&sd); splice_from_pipe_begin(&sd);
......
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