From: Sasha Levin <sasha.levin@oracle.com>
To: mingo@kernel.org, akpm@linux-foundation.org,
torvalds@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, Sasha Levin <sasha.levin@oracle.com>
Subject: [RFC v2 2/2] fs: correctly check for signed integer overflow in vfs_fallocate
Date: Wed, 26 Nov 2014 18:58:02 -0500 [thread overview]
Message-ID: <1417046282-31825-2-git-send-email-sasha.levin@oracle.com> (raw)
In-Reply-To: <1417046282-31825-1-git-send-email-sasha.levin@oracle.com>
Both "offset" and "len" are signed integers who's addition may overflow
and trigger undefined behaviour.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
fs/open.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/open.c b/fs/open.c
index 813be03..33d5cae 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -287,7 +287,8 @@ int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
return -ENODEV;
/* Check for wrap through zero too */
- if (((offset + len) > inode->i_sb->s_maxbytes) || ((offset + len) < 0))
+ if (check_add_overflow(offset, len) ||
+ (offset + len) > inode->i_sb->s_maxbytes)
return -EFBIG;
if (!file->f_op->fallocate)
--
1.7.10.4
next prev parent reply other threads:[~2014-11-26 23:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-26 23:58 [RFC v2 1/2] compiler: use compiler to detect integer overflows Sasha Levin
2014-11-26 23:58 ` Sasha Levin [this message]
2014-11-27 0:33 ` Linus Torvalds
2014-11-27 1:37 ` Sasha Levin
2014-11-27 3:13 ` Linus Torvalds
2014-11-29 15:07 ` Sasha Levin
2014-11-29 18:08 ` Linus Torvalds
2014-11-30 3:47 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417046282-31825-2-git-send-email-sasha.levin@oracle.com \
--to=sasha.levin@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).