Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3426397imu; Sun, 11 Nov 2018 14:50:17 -0800 (PST) X-Google-Smtp-Source: AJdET5f9zsLLYAjuykjGHVDASzZ7qYL79ll5jlE8sqdIwHEfSwjrcoKTCMmchQgYM16jjnhg/gzM X-Received: by 2002:a63:3546:: with SMTP id c67mr7552889pga.284.1541976617858; Sun, 11 Nov 2018 14:50:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541976617; cv=none; d=google.com; s=arc-20160816; b=jTt0su+G5A3ARAk5ziG7N28T2LTR3OTa9aQdgMbVTK35Pwa2uBnNBBJ3CHcR584ko0 tlAxryLJVHDl4hrolyKIQGl+CCjBNgboj98jLA+pFYVT3j/ODtnPSn4T8zIzUiXXrK5n bNPmdaKEb3l+h1Feo7D0u7z40A0NOmerz5X+TP/9d+uc6NEJxAXz3iOZxvi4GIWuXD9O ytbsheImq5V/+nqAbZ8CyA7i1MdyI7viFCU6FslniO1n6m0/LP3RAs5IoO93QTDzzneT 6Xp0fwLMoxyuNxTD9OlU8zjSJ9i0+wL2UykFvqIAeuZN9Z3AROLdUCCt5gN4iBVOrXLf IsEg== 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=8+A7c33JwwafrNHM67lhEC5Sw/zdCo9B50n/K+dJ4iM=; b=XDRdAGKTLFokaKX1z2JIPMDGSeZnjMuOEJ9UIvw6QZD7ECXICfupQL4Q0rYqDa8tm/ FwSGo+ybhwx5yJpdJbtd7m1radzkF7yzuSXmu4h470wMu10W9k/irYbt7s+GcHxPCQMH 161iVRI2qmKwcCl2DFf1oJoY1R9AdbclPxyEwrJ6b7m8W8wjCEi4gUsS1dzgo3yYo+h4 faxBoeL7ROI1+yBiGMvlpn8/ICVL0yMVfkd3fmwUBQfy4ZYndK25HuYRsfEJTP3QSkrd i/9IyH6qbro2YBCXnR1naGo8xMCJlHW9aqbnxRTJSLmOQDb5Ujub1JCaO7o46uEmmBmg y2KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="OL0SyX/8"; 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 y11-v6si15444754plp.415.2018.11.11.14.50.02; Sun, 11 Nov 2018 14:50:17 -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="OL0SyX/8"; 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 S2390939AbeKLIjq (ORCPT + 99 others); Mon, 12 Nov 2018 03:39:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:56380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404289AbeKLIXO (ORCPT ); Mon, 12 Nov 2018 03:23:14 -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 1EB1B21582; Sun, 11 Nov 2018 22:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975597; bh=H8G5gK7cH5op4yyATg0chvif9sNRjlNJV6HEsDxRLAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OL0SyX/8SXJ0sZcgYb9kKdfHTWOqLYLv5rErgBv/GSqORYKjVBY8oIfRR0QkRkweB 832f7IsF4SB4dOT0H5LkDUzJONnqeoG4ntgODvr8ZQWW/NbM1Kopd0UdG0AusN3aHw KE8211R3CpNIvjNyzpVmLe2iYtUhxSgF4z+Jyg80= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, jason.wessel@windriver.com, jslaby@suse.com, He Zhe , Daniel Thompson Subject: [PATCH 4.14 181/222] kgdboc: Passing ekgdboc to command line causes panic Date: Sun, 11 Nov 2018 14:24:38 -0800 Message-Id: <20181111221703.221729367@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 1bd54d851f50dea6af30c3e6ff4f3e9aab5558f9 upstream. kgdboc_option_setup does not check input argument before passing it to strlen. The argument would be a NULL pointer if "ekgdboc", without its value, is set in command line and thus cause the following panic. PANIC: early exception 0xe3 IP 10:ffffffff8fbbb620 error 0 cr2 0x0 [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.18-rc8+ #1 [ 0.000000] RIP: 0010:strlen+0x0/0x20 ... [ 0.000000] Call Trace [ 0.000000] ? kgdboc_option_setup+0x9/0xa0 [ 0.000000] ? kgdboc_early_init+0x6/0x1b [ 0.000000] ? do_early_param+0x4d/0x82 [ 0.000000] ? parse_args+0x212/0x330 [ 0.000000] ? rdinit_setup+0x26/0x26 [ 0.000000] ? parse_early_options+0x20/0x23 [ 0.000000] ? rdinit_setup+0x26/0x26 [ 0.000000] ? parse_early_param+0x2d/0x39 [ 0.000000] ? setup_arch+0x2f7/0xbf4 [ 0.000000] ? start_kernel+0x5e/0x4c2 [ 0.000000] ? load_ucode_bsp+0x113/0x12f [ 0.000000] ? secondary_startup_64+0xa5/0xb0 This patch adds a check to prevent the panic. Cc: stable@vger.kernel.org Cc: jason.wessel@windriver.com Cc: gregkh@linuxfoundation.org Cc: jslaby@suse.com Signed-off-by: He Zhe Reviewed-by: Daniel Thompson Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/kgdboc.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -133,6 +133,11 @@ static void kgdboc_unregister_kbd(void) static int kgdboc_option_setup(char *opt) { + if (!opt) { + pr_err("kgdboc: config string not provided\n"); + return -EINVAL; + } + if (strlen(opt) >= MAX_CONFIG_LEN) { printk(KERN_ERR "kgdboc: config string too long\n"); return -ENOSPC;