Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3474361imu; Sun, 11 Nov 2018 15:56:58 -0800 (PST) X-Google-Smtp-Source: AJdET5csHkOeB9Pk8Rl1LhK+2NnfQPkKeRgLL9dKmYsEdqEQBHFMAXfoyg2xqdd4mHiQenRAeTgo X-Received: by 2002:a62:fc52:: with SMTP id e79mr723187pfh.8.1541980618851; Sun, 11 Nov 2018 15:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980618; cv=none; d=google.com; s=arc-20160816; b=t3oU1jOYbW6xb1UrLXOYJoS01wp9/f0NZ+1lQcjXVr94cAxq5J/qxvF81kXpBqz3Re 7zp2mzHQPRsNWwX6yMcC91A/Ms5HJDkGQLKNatuhff6Q03BLUzWzIPN/pDOYkFbnsA+E eFLRC2v6o2u1LQeMlzq1g5G94m7qYAtphingU2uDyNIf3xLThhWn+s/fcABcd6wSMaxC FlOTBgkiGWCQcp4alJL1pETVoIJaMcMfnk7ww34d2gexI2LTHpSQkbX33Y2Oes54SSd/ kgQqLjwl+23z9NqoVhbXSvV5BnTtsSVCfpjAoRUnWO5pk+qaDTo5qMZt6/LyCDAQkbcb Ma2Q== 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=jlY3pyy7lZgELGdyw3eihFWcYHTh2IevTDx3KR00Lk4=; b=n3hPQkdT90X/ZVL+MBLhb86jkOxMCWgiQPcc7G1faYIb6oD5vCPjgzQ3K4O4GPRDX2 KX7hibAXyp/BpLT7YQ0M1dcfmqgjLtYciG+E7vrWhKF9lsVTSfVNG0+Z3Bhyg780PjXb 3fwHyMKtkrcYzgOPxBJtr9XVFlZXShQ5dcHLk5naux1xMojsvro/4qRblhI1gujbz14F tIDJIRLqlsdU/OQJBzfRuExot/NZvlA4A4MdVKTU6YSNTjRHa0DLFMdX6UmuGjF/Hij+ 5F8DjByfBw4IqwEtxCiIpDHym5K0qhl3u63Cc4UZMI6cvoXPcJ8UrR+GwWTpBZiwM9hv QOJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AtRuODiB; 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 k8-v6si9527971plt.144.2018.11.11.15.56.44; Sun, 11 Nov 2018 15:56:58 -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=AtRuODiB; 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 S1732684AbeKLIST (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:37162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732672AbeKLIST (ORCPT ); Mon, 12 Nov 2018 03:18:19 -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 EBEFC21527; Sun, 11 Nov 2018 22:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975303; bh=HnnV8p3BYNFwNMMxW+odyZuFzPjj/y+ezEL0owagWtw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AtRuODiBsOpc3uvNeeuu6qwVWgvJuZOkY1AtqZ4mkHdeMSP89AOp0ase2ayDDNZGA V3n9nnBuZucFIMzGnmvNy/0dxqrSbzU7QxpkYPVy4D1d/Q89rMlvBjloPseCJvh+5j cKD0PS1VuiXFPSZvG7F8xlrhW+afyrukWNvfR4ew= 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.19 266/361] printk: Fix panic caused by passing log_buf_len to command line Date: Sun, 11 Nov 2018 14:20:13 -0800 Message-Id: <20181111221654.643310304@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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 @@ -1048,7 +1048,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);