From: Sasha Levin <sasha.levin@oracle.com>
To: linux-kernel@vger.kernel.org
Cc: Sasha Levin <sasha.levin@oracle.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH] fs: sync_file_range: avoid overflowing signed calculation
Date: Mon, 1 Dec 2014 23:04:10 -0500 [thread overview]
Message-ID: <1417493050-13594-6-git-send-email-sasha.levin@oracle.com> (raw)
In-Reply-To: <1417493050-13594-1-git-send-email-sasha.levin@oracle.com>
When calculating the end byte for the sync we preform an addition which might
result in an overflow, which is undefined. Avoid it by doing unsigned
addition.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
fs/sync.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/sync.c b/fs/sync.c
index 6ccfc38..f9cb38f 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -286,7 +286,7 @@ SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes,
if (flags & ~VALID_FLAGS)
goto out;
- endbyte = offset + nbytes;
+ endbyte = offset + (u64)nbytes;
if ((s64)offset < 0)
goto out;
--
1.7.10.4
prev parent reply other threads:[~2014-12-02 4:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1417493050-13594-1-git-send-email-sasha.levin@oracle.com>
2014-12-02 4:04 ` [PATCH] vfs: calculate seek offsets using unsigned variables Sasha Levin
2014-12-02 4:04 ` Sasha Levin [this message]
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=1417493050-13594-6-git-send-email-sasha.levin@oracle.com \
--to=sasha.levin@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).