From: Vyacheslav Dubeyko <slava@dubeyko.com>
To: Wenliang Fan <fanwlexca@gmail.com>
Cc: konishi.ryusuke@lab.ntt.co.jp, linux-nilfs@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs/nilfs2: Integer overflow in nilfs_ioctl_wrap_copy()
Date: Fri, 20 Dec 2013 12:23:28 +0400 [thread overview]
Message-ID: <1387527808.4022.6.camel@slavad-ubuntu> (raw)
In-Reply-To: <1387525568-30025-1-git-send-email-fanwlexca@gmail.com>
On Fri, 2013-12-20 at 15:46 +0800, Wenliang Fan wrote:
> 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;
>
What about check before enter into the cycle? If you are talking about
possible huge number then you can receive huge number from userspace
before entering in the cycle.
Thanks,
Vyacheslav Dubeyko.
> 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;
>
next prev parent reply other threads:[~2013-12-20 8:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-20 7:46 [PATCH] fs/nilfs2: Integer overflow in nilfs_ioctl_wrap_copy() Wenliang Fan
2013-12-20 8:23 ` Vyacheslav Dubeyko [this message]
-- 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=1387527808.4022.6.camel@slavad-ubuntu \
--to=slava@dubeyko.com \
--cc=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