From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752882AbcBEKt5 (ORCPT ); Fri, 5 Feb 2016 05:49:57 -0500 Received: from smtp-out4.electric.net ([192.162.216.182]:51771 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751926AbcBEKtx convert rfc822-to-8bit (ORCPT ); Fri, 5 Feb 2016 05:49:53 -0500 From: David Laight To: "'Kees Cook'" , Andrew Morton CC: Amitkumar Karwar , Nishant Sarmukadam , Kalle Valo , Steve French , "linux-cifs@vger.kernel.org" , Joe Perches , Andy Shevchenko , Rasmus Villemoes , Daniel Borkmann , Michael Ellerman , Heiko Carstens , "Martin Schwidefsky" , "x86@kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-s390@vger.kernel.org" , "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2 2/4] lib: update single-char callers of strtobool Thread-Topic: [PATCH v2 2/4] lib: update single-char callers of strtobool Thread-Index: AQHRX47iidar7wynZ0+OT0Jr4CB7fp8dQkgw Date: Fri, 5 Feb 2016 10:46:19 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CCD6FE5@AcuExch.aculab.com> References: <1454619643-14444-1-git-send-email-keescook@chromium.org> <1454619643-14444-3-git-send-email-keescook@chromium.org> In-Reply-To: <1454619643-14444-3-git-send-email-keescook@chromium.org> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook > Sent: 04 February 2016 21:01 > Some callers of strtobool were passing a pointer to unterminated strings. > In preparation of adding multi-character processing to kstrtobool, update > the callers to not pass single-character pointers, and switch to using the > new kstrtobool_from_user helper where possible. Personally I think you should change the name of the function so that the compiler (and linker) will pick up places that have not been changed. Relying on people to make the required changes will cause problems. The current code (presumably) treats "no", "nyet" and "nkjkkrkjrkjterkj" as false. Changing that behaviour will break things. If you want to support "on" and "off", then maybe check for the supplied string starting with the character sequences "on\0" and "off\0" (as well as any others). This doesn't need the input string be '\0' terminated - since you match y and n without looking at the 2nd byte. You'd have to be extremely unlucky to get a page fault in the 3 bytes following an 'o' if the caller supplied a single byte buffer. David