Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752676AbbBRHop (ORCPT ); Wed, 18 Feb 2015 02:44:45 -0500 Received: from mail-we0-f178.google.com ([74.125.82.178]:36266 "EHLO mail-we0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751933AbbBRHoo (ORCPT ); Wed, 18 Feb 2015 02:44:44 -0500 Date: Wed, 18 Feb 2015 10:44:42 +0300 From: Alexey Dobriyan To: Andrew Morton Cc: aksgarg1989@gmail.com, linux-kernel@vger.kernel.org Subject: Re: Fw: [PATCH] lib/kstrtox.c Stop parsing integer on overflow Message-ID: <20150218074442.GC1752@p183.telecom.by> References: <20150217161724.65a9ff577f84917497d61b4e@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Description: ue to a bug. Record at least task name (we can't take task_struct Content-Disposition: inline In-Reply-To: <20150217161724.65a9ff577f84917497d61b4e@linux-foundation.org> User-Agent: Mutt/1.5.22 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1814 Lines: 55 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 > 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 > > While converting string representation to integer > break the loop if overflow is detected. > > Signed-off-by: Anshul Garg > --- > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/