From: Wenliang Fan <fanwlexca@gmail.com>
To: konishi.ryusuke@lab.ntt.co.jp
Cc: linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Wenliang Fan <fanwlexca@gmail.com>
Subject: [PATCH] fs/nilfs2: Integer overflow in nilfs_ioctl_wrap_copy()
Date: Fri, 20 Dec 2013 15:46:08 +0800 [thread overview]
Message-ID: <1387525568-30025-1-git-send-email-fanwlexca@gmail.com> (raw)
The local variable 'pos' comes from userspace. If a large number was
passed, there would be an integer overflow in the following line:
pos += n;
Signed-off-by: Wenliang Fan <fanwlexca@gmail.com>
---
fs/nilfs2/ioctl.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index b44bdb2..b2bac9a 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -90,8 +90,13 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
total += nr;
if ((size_t)nr < n)
break;
- if (pos == ppos)
+ if (pos == ppos) {
+ if (pos > ULONG_MAX - n) {
+ ret = -EINVAL;
+ break;
+ }
pos += n;
+ }
}
argv->v_nmembs = total;
--
1.8.5.rc1.28.g7061504
next reply other threads:[~2013-12-20 7:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-20 7:46 Wenliang Fan [this message]
2013-12-20 8:23 ` [PATCH] fs/nilfs2: Integer overflow in nilfs_ioctl_wrap_copy() Vyacheslav Dubeyko
-- strict thread matches above, loose matches on Subject: below --
2013-12-28 2:28 Wenliang Fan
2013-12-30 6:40 ` Vyacheslav Dubeyko
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=1387525568-30025-1-git-send-email-fanwlexca@gmail.com \
--to=fanwlexca@gmail.com \
--cc=konishi.ryusuke@lab.ntt.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.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