From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756863AbcBCLgz (ORCPT ); Wed, 3 Feb 2016 06:36:55 -0500 Received: from terminus.zytor.com ([198.137.202.10]:55804 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755931AbcBCLgw (ORCPT ); Wed, 3 Feb 2016 06:36:52 -0500 Date: Wed, 3 Feb 2016 03:35:42 -0800 From: tip-bot for Dave Hansen Message-ID: Cc: hpa@zytor.com, dvlasenk@redhat.com, peterz@infradead.org, bp@suse.de, brgerst@gmail.com, dave.hansen@linux.intel.com, bp@alien8.de, tglx@linutronix.de, mingo@kernel.org, torvalds@linux-foundation.org, luto@amacapital.net, linux-kernel@vger.kernel.org Reply-To: bp@alien8.de, dave.hansen@linux.intel.com, mingo@kernel.org, tglx@linutronix.de, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, luto@amacapital.net, bp@suse.de, peterz@infradead.org, dvlasenk@redhat.com, hpa@zytor.com, brgerst@gmail.com In-Reply-To: <20151222225241.15365E43@viggo.jf.intel.com> References: <20151222225241.15365E43@viggo.jf.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/boot] x86/boot: Simplify early command line parsing Git-Commit-ID: 4de07ea481361b08fe13735004dafae862482d38 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4de07ea481361b08fe13735004dafae862482d38 Gitweb: http://git.kernel.org/tip/4de07ea481361b08fe13735004dafae862482d38 Author: Dave Hansen AuthorDate: Tue, 22 Dec 2015 14:52:41 -0800 Committer: Ingo Molnar CommitDate: Wed, 3 Feb 2016 12:03:17 +0100 x86/boot: Simplify early command line parsing __cmdline_find_option_bool() tries to account for both NULL-terminated and non-NULL-terminated strings. It keeps 'pos' to look for the end of the buffer and also looks for '!c' in a bunch of places to look for NULL termination. But, it also calls strlen(). You can't call strlen on a non-NULL-terminated string. If !strlen(cmdline), then cmdline[0]=='\0'. In that case, we will go in to the while() loop, set c='\0', hit st_wordstart, notice !c, and will immediately return 0. So, remove the strlen(). It is unnecessary and unsafe. Signed-off-by: Dave Hansen Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: fenghua.yu@intel.com Cc: yu-cheng.yu@intel.com Link: http://lkml.kernel.org/r/20151222225241.15365E43@viggo.jf.intel.com Signed-off-by: Ingo Molnar --- arch/x86/lib/cmdline.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/lib/cmdline.c b/arch/x86/lib/cmdline.c index ff8d1be..945a639 100644 --- a/arch/x86/lib/cmdline.c +++ b/arch/x86/lib/cmdline.c @@ -39,9 +39,6 @@ int cmdline_find_option_bool(const char *cmdline, const char *option) if (!cmdline) return -1; /* No command line */ - if (!strlen(cmdline)) - return 0; - /* * This 'pos' check ensures we do not overrun * a non-NULL-terminated 'cmdline'