Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3429147imu; Sun, 11 Nov 2018 14:54:43 -0800 (PST) X-Google-Smtp-Source: AJdET5dl83CY2RMCKTwrkSSV3PJAlvANoRO0bZ7zyXSnLXjDFfC55WvwLXPjsjgeWepT9G8sDvqy X-Received: by 2002:a63:134f:: with SMTP id 15mr8899179pgt.19.1541976883408; Sun, 11 Nov 2018 14:54:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976883; cv=none; d=google.com; s=arc-20160816; b=MxCOBMZ6vrU6FQjsCHC1rjFeWMCT/yovLvYQxMqT8Xzsva7P2IrL0MOTs9JGsdgSEK QvbzeR/ltqv9kqknIuvzNpsnh3aGiPrwB8v1mmDqIBdi9qdfeqTkoZooBTF6nl6ndor7 bclNT53bPP0Mve0eqspW+6R/Pf2YxXJ7eVm8W9FI9aSR2iowypx5CK38QZmmZqb/jzkv NTRzJw24A7QgI1i3/PPvaoLi1AoGj1HUki9UAwiL6P6i6m+oo+sdXhl74a81JjHOswZd 8sevHjXJQA53SmuSa9tVGIzbgJWHvqzHUaiSb7AwPartJCajfjzigtrrTCzL6juulZ0e zxnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IVuSjefU+p2rOc09eTrfeJPPRvQuzlW1ELb5CFTW71s=; b=oZ2Pq1yiobPpGPQjfhlnXajg7QI634l3BlnUY5alJIiWxKbEASURFDGTrB2aRHZJBa whAxLk+S4HYEP/PYi/kEJBvj7UO/AfcCQP3rRQQmrwQpgKzsfjCFbtwVNqGKKL5zI18G pXtvA3ZxvoXyZoHNRXCFgsfIF5Z5i1x83+cS2o3eBg4lbrweCW+8pSJnSxPfDxVWk9wz STKECRr43NVkHq/nGeKPCxFGZPki2xVytYBWMUanNIamqPvF3pYLbBkEwGit8UFl7Z6r lrQWZSrY7s1JWWsFVdDeV4ugGnw7rek6LXMak+wUn1b3nGdRXoXyvPQ77mdtwY6HHftr oi3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M5HNc07G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b124-v6si16266373pfa.135.2018.11.11.14.54.28; Sun, 11 Nov 2018 14:54:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M5HNc07G; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403995AbeKLIW5 (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:54672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403979AbeKLIW4 (ORCPT ); Mon, 12 Nov 2018 03:22:56 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7B4C12241B; Sun, 11 Nov 2018 22:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975579; bh=wq1tv1xyMS6iEdxVGP7+pg41pVwTTeb5iR/y8wLYbw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M5HNc07Gg0/HzEH/TmlFXqtPpH3NZ8UlbH32di0j30UYxVPrkSaH1xU56cFpu44eM BsRTxlste8B4xT50+231HBbm+NcXJ9semgOsM9zArAER99eqqtJiA4vLsW3ntyvE7L hMd9txNebcBKfx9N20m/Nwfs6o9CAApdgTtnJOR8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, rostedt@goodmis.org, He Zhe , Sergey Senozhatsky , Petr Mladek Subject: [PATCH 4.14 167/222] printk: Fix panic caused by passing log_buf_len to command line Date: Sun, 11 Nov 2018 14:24:24 -0800 Message-Id: <20181111221702.192267883@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: He Zhe commit 277fcdb2cfee38ccdbe07e705dbd4896ba0c9930 upstream. log_buf_len_setup does not check input argument before passing it to simple_strtoull. The argument would be a NULL pointer if "log_buf_len", without its value, is set in command line and thus causes the following panic. PANIC: early exception 0xe3 IP 10:ffffffffaaeacd0d error 0 cr2 0x0 [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #1 [ 0.000000] RIP: 0010:_parse_integer_fixup_radix+0xd/0x70 ... [ 0.000000] Call Trace: [ 0.000000] simple_strtoull+0x29/0x70 [ 0.000000] memparse+0x26/0x90 [ 0.000000] log_buf_len_setup+0x17/0x22 [ 0.000000] do_early_param+0x57/0x8e [ 0.000000] parse_args+0x208/0x320 [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_options+0x29/0x2d [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_param+0x36/0x4d [ 0.000000] setup_arch+0x336/0x99e [ 0.000000] start_kernel+0x6f/0x4ee [ 0.000000] x86_64_start_reservations+0x24/0x26 [ 0.000000] x86_64_start_kernel+0x6f/0x72 [ 0.000000] secondary_startup_64+0xa4/0xb0 This patch adds a check to prevent the panic. Link: http://lkml.kernel.org/r/1538239553-81805-1-git-send-email-zhe.he@windriver.com Cc: stable@vger.kernel.org Cc: rostedt@goodmis.org Cc: linux-kernel@vger.kernel.org Signed-off-by: He Zhe Reviewed-by: Sergey Senozhatsky Signed-off-by: Petr Mladek Signed-off-by: Greg Kroah-Hartman --- kernel/printk/printk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1043,7 +1043,12 @@ static void __init log_buf_len_update(un /* save requested log_buf_len since it's too early to process it */ static int __init log_buf_len_setup(char *str) { - unsigned size = memparse(str, &str); + unsigned int size; + + if (!str) + return -EINVAL; + + size = memparse(str, &str); log_buf_len_update(size);