Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3472376imu; Sun, 11 Nov 2018 15:54:07 -0800 (PST) X-Google-Smtp-Source: AJdET5ekUfQ0Vfnzj/UXKTGdK7q5uM4CXpIEb4yi8lsmtomf4KSDxag7DpPP/ZDQJ2qF5RmkFyaQ X-Received: by 2002:a62:14d1:: with SMTP id 200mr45971pfu.103.1541980447095; Sun, 11 Nov 2018 15:54:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980447; cv=none; d=google.com; s=arc-20160816; b=j3taE10u8kY8xTBxjVYZjeOfZeJJZb0uAOk535AFvnKaMsoHubyxtAhbgnB1VSvOql xtrn+OCXQ79dyNPifcAu+MOYBW7ZTyQS2YzdDjgXtdNEwT1ko+5JW2FYjF21i+Shji0L 5kNAlQyxGX9WdthZ7qptZEt+q5q5GSfwazNaDsGqE8+1Z4wq7nbxLQr2VoEWKKDQh/c1 NCjG24fCEA9Qe4rY2Tb3GdCMmEp7JQJajI1N5GAWyxlAuUOgmqpUZeq99avBkac/51jt xiro8uBVb6RmqX2aLMnAib4Pwvwpi0K6yDfgZavHopdXMwyKBcgGVB17dtrphzO0UQTl z8eQ== 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=5543Vw5ke8OasrdACPhoXbtotIUMRStNpUbdbgCB2ZI=; b=olJG02Sec+xyxtg2roxLP6KLm1h713eE928p7RB3F64CXsHeua1z3lDgOVv3zjV8GR ySkokrBVLP+v2SjJR6jmxcdW95hXzEbizp159kcKdfq/MmeE02t4VJGQ8NQyVM/RAGRQ 4716WnCzN7Mto3VHcSfvyH+hOZno9UuGHsk+xtIXCbyEb5bNWdYBDlXKb464MmxszIe3 5GtBNxJRoaNJWy7rKM9LGhNr6jQ5D+NwO2xFUMwMlqPHcQJrr+FrAZ3XP9qcvYpNRJvQ w96Fjw8yimqZfiODflPgUEYWyj885IugEcxmOHSHZrXnKInCBKSBm2U6RTty0tEl4i+v 2nEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O7vt7rKH; 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 91-v6si8361588ply.335.2018.11.11.15.53.52; Sun, 11 Nov 2018 15:54:07 -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=O7vt7rKH; 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 S1732988AbeKLJmn (ORCPT + 99 others); Mon, 12 Nov 2018 04:42:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:37518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732821AbeKLIS3 (ORCPT ); Mon, 12 Nov 2018 03:18:29 -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 92F36223AE; Sun, 11 Nov 2018 22:28:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975312; bh=hF5axpUJ13yGnHAeeg5fbLjVnnrH+5RS0iRiOX7dG6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O7vt7rKHgsQCB3xzmqnnK5U7C3bnPhjTNdFUjTIWIEkEfLNtuqy99CkSPuWonkZns ET4rkxXscnyC8yLwBCarTs6VbjeYK8wy3w3Xz+/+CNF32nTYQb+VD4m6waidBM99hx jH5JG0yALvAKRKxlpk4M1QQEQp7olj2adgTcRD6E= 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.19 295/361] kgdboc: Passing ekgdboc to command line causes panic Date: Sun, 11 Nov 2018 14:20:42 -0800 Message-Id: <20181111221657.016073631@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 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 @@ -130,6 +130,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;