From: Alexey Dobriyan <adobriyan@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: aksgarg1989@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: Fw: [PATCH] lib/kstrtox.c Stop parsing integer on overflow
Date: Wed, 18 Feb 2015 10:44:42 +0300 [thread overview]
Message-ID: <20150218074442.GC1752@p183.telecom.by> (raw)
In-Reply-To: <20150217161724.65a9ff577f84917497d61b4e@linux-foundation.org>
On Tue, Feb 17, 2015 at 04:17:24PM -0800, Andrew Morton wrote:
> ?
>
> Begin forwarded message:
>
> Date: Mon, 16 Feb 2015 10:48:50 -0800
> From: Anshul Garg <aksgarg1989@gmail.com>
> To: linux-kernel@vger.kernel.org
> Cc: aksgarg1989@gmail.com, anshul.g@samsung.com, torvalds@linux-foundation.org
> Subject: [PATCH] lib/kstrtox.c Stop parsing integer on overflow
>
>
> From: Anshul Garg <aksgarg1989@gmail.com>
>
> While converting string representation to integer
> break the loop if overflow is detected.
>
> Signed-off-by: Anshul Garg <aksgarg1989@gmail.com>
> ---
> lib/kstrtox.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/kstrtox.c b/lib/kstrtox.c
> index ec8da78..6f30209 100644
> --- a/lib/kstrtox.c
> +++ b/lib/kstrtox.c
> @@ -70,8 +70,10 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long
> * it in the max base we support (16)
> */
> if (unlikely(res & (~0ull << 60))) {
> - if (res > div_u64(ULLONG_MAX - val, base))
> + if (res > div_u64(ULLONG_MAX - val, base)) {
> overflow = 1;
> + break;
> + }
> }
> res = res * base + val;
> rv++;
The _notion_ of a patch is OK if you want EVERY simple_strtoull() call
to stop parsing past overflow right now. It SHOULD have done so from day 1,
but it doesn't do that.
When I wrote kstrto*() code I deliberatedly didn't break this bug
because of the sheer number of call sites.
If you are OK with changing bug-for-bug compatibility,
then patch simply need to delete overflow detection code.
Alexey
next parent reply other threads:[~2015-02-18 7:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20150217161724.65a9ff577f84917497d61b4e@linux-foundation.org>
2015-02-18 7:44 ` Alexey Dobriyan [this message]
2015-02-19 17:53 ` Anshul Garg
2015-02-20 11:08 ` Alexey Dobriyan
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=20150218074442.GC1752@p183.telecom.by \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=aksgarg1989@gmail.com \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®