diff mbox

[3.13.y-ckt,stable] Patch "splice: Apply generic position and size checks to each write" has been added to staging queue

Message ID 1424808283.20843.9.camel@fourier
State New
Headers show

Commit Message

Kamal Mostafa Feb. 24, 2015, 8:04 p.m. UTC
Hi Jiri-

FYI, the attached CVE patch (a port of Ben's 3.2 patch, thanks Ben!) is
likely suitable for 3.12-stable as well.

 -Kamal


On Tue, 2015-02-24 at 12:00 -0800, Kamal Mostafa wrote:
> This is a note to let you know that I have just added a patch titled
> 
>     splice: Apply generic position and size checks to each write
> 
> to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
> which can be found at:
> 
>  http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue
> 
> This patch is scheduled to be released in version 3.13.11-ckt17.
> 
> If you, or anyone else, feels it should not be added to this tree, please 
> reply to this email.
> 
> For more information about the 3.13.y-ckt tree, see
> https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
> 
> Thanks.
> -Kamal

Comments

Ben Hutchings Feb. 24, 2015, 8:13 p.m. UTC | #1
On Tue, 2015-02-24 at 12:04 -0800, Kamal Mostafa wrote:
> Hi Jiri-
> 
> FYI, the attached CVE patch (a port of Ben's 3.2 patch, thanks Ben!) is
> likely suitable for 3.12-stable as well.

Please check that ocfs2_file_splice_write() is the only splice_write
implementation that doesn't call generic_file_splice_write().  That
might possibly have changed at some point after 3.2.

Ben.

>  -Kamal
> 
> 
> On Tue, 2015-02-24 at 12:00 -0800, Kamal Mostafa wrote:
> > This is a note to let you know that I have just added a patch titled
> > 
> >     splice: Apply generic position and size checks to each write
> > 
> > to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
> > which can be found at:
> > 
> >  http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue
> > 
> > This patch is scheduled to be released in version 3.13.11-ckt17.
> > 
> > If you, or anyone else, feels it should not be added to this tree, please 
> > reply to this email.
> > 
> > For more information about the 3.13.y-ckt tree, see
> > https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
> > 
> > Thanks.
> > -Kamal
>
Kamal Mostafa Feb. 24, 2015, 8:16 p.m. UTC | #2
On Tue, 2015-02-24 at 20:13 +0000, Ben Hutchings wrote:
> On Tue, 2015-02-24 at 12:04 -0800, Kamal Mostafa wrote:
> > Hi Jiri-
> > 
> > FYI, the attached CVE patch (a port of Ben's 3.2 patch, thanks Ben!) is
> > likely suitable for 3.12-stable as well.
> 
> Please check that ocfs2_file_splice_write() is the only splice_write
> implementation that doesn't call generic_file_splice_write().  That
> might possibly have changed at some point after 3.2.

I had done so.  All the other splice_writes did indeed end up resolving
down to generic_file_splice_write(), as of 3.13-stable.

Thanks again Ben!

 -Kamal


> > On Tue, 2015-02-24 at 12:00 -0800, Kamal Mostafa wrote:
> > > This is a note to let you know that I have just added a patch titled
> > > 
> > >     splice: Apply generic position and size checks to each write
> > > 
> > > to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
> > > which can be found at:
> > > 
> > >  http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue
> > > 
> > > This patch is scheduled to be released in version 3.13.11-ckt17.
> > > 
> > > If you, or anyone else, feels it should not be added to this tree, please 
> > > reply to this email.
> > > 
> > > For more information about the 3.13.y-ckt tree, see
> > > https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable
> > > 
> > > Thanks.
> > > -Kamal
> > 
>
Jiri Slaby March 12, 2015, 1:14 p.m. UTC | #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 02/24/2015, 09:13 PM, Ben Hutchings wrote:
> On Tue, 2015-02-24 at 12:04 -0800, Kamal Mostafa wrote:
>> Hi Jiri-
>> 
>> FYI, the attached CVE patch (a port of Ben's 3.2 patch, thanks
>> Ben!) is likely suitable for 3.12-stable as well.
> 
> Please check that ocfs2_file_splice_write() is the only
> splice_write implementation that doesn't call
> generic_file_splice_write().  That might possibly have changed at
> some point after 3.2.

Applied and checked. Thanks.


- -- 
js
suse labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJVAZEkAAoJEL0lsQQGtHBJsBoP/1+r7PPdzjj10eI9WIz7fkVr
tRirZuVxWoE2rrztficeE/4TVI2dOQgW1B7qHMc1TjhT76wg7um8A70AUNd0n10k
BOeLNCHzjG5jk8klTV/tfrd5dBSBcQtUae4glI1K0EpwsQn86AhiCXgcCI5ZvjFh
sORVr/Twk6ndtcwSiGmFQM68E3sDBuhFX1WcpE6kWWHNxXetIIzWm2BFEdQnsAea
faTCmA4jiF8djr0sspvE8Lsf6NWVK2yS5zbW83fGrSpb9ZR3fs6ZVcuUfNIUvWVp
vwE/CS7hy8bl0AZg/718G5dWE9Xp8SKIYpdMiKtWEivUhzvaDykfzaU+6r3lVZBg
+vu/sH6ojxMj7DT6OM/tqlvFB2Glbkr+JHafZyV+lmVs6v+G/NNLUncIWkXRWWfy
bMD7IUMPcuB9LEj5GHlQ9tXxMsP1fcb8V437o+bCjcUrnrXuTd1Vvfo/Wjvrl9dF
l102rM50Iad5X2W5Ns1OXc3sINM38EInoXsNMKRWRGjiai2lDZqXp2nnDksvLtw0
1NE1n4R6vndZfJcHy+busnXxHRFU1pgwkVqUSAspdE5oKJzH2UWsIpJfbM0QD6wo
ZtWEesmh4R2KdpC5Ofdj1KQz/2EdquSoYLjXJGL0KEyC/7xwGIuPw+6D27DaHarj
b2dSM9IoTyFyp4xd+Wyx
=uFPk
-----END PGP SIGNATURE-----
diff mbox

Patch

From 9a0955f27c69609377a757a8aa0dcf51d5b5a4e1 Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben@decadent.org.uk>
Date: Thu, 29 Jan 2015 02:50:33 +0000
Subject: splice: Apply generic position and size checks to each write

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 8d0207652cbe
("->splice_write() via ->write_iter()") but we can't apply that.

CVE-2014-7822

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
[ kamal: port to 3.13-stable: context ]
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 fs/ocfs2/file.c | 8 ++++++--
 fs/splice.c     | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 9c65949..5850a81 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2449,9 +2449,7 @@  static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
 	struct address_space *mapping = out->f_mapping;
 	struct inode *inode = mapping->host;
 	struct splice_desc sd = {
-		.total_len = len,
 		.flags = flags,
-		.pos = *ppos,
 		.u.file = out,
 	};
 
@@ -2461,6 +2459,12 @@  static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe,
 			out->f_path.dentry->d_name.len,
 			out->f_path.dentry->d_name.name, len);
 
+	ret = generic_write_checks(out, ppos, &len, 0);
+	if (ret)
+		return ret;
+	sd.total_len = len;
+	sd.pos = *ppos;
+
 	pipe_lock(pipe);
 
 	splice_from_pipe_begin(&sd);
diff --git a/fs/splice.c b/fs/splice.c
index 12028fa..f345d53 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1012,13 +1012,17 @@  generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
 	struct address_space *mapping = out->f_mapping;
 	struct inode *inode = mapping->host;
 	struct splice_desc sd = {
-		.total_len = len,
 		.flags = flags,
-		.pos = *ppos,
 		.u.file = out,
 	};
 	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);
 
 	splice_from_pipe_begin(&sd);
-- 
1.9.1