From patchwork Tue Sep 29 11:00:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 262944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E211EC4727C for ; Tue, 29 Sep 2020 12:34:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B93420789 for ; Tue, 29 Sep 2020 12:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601382899; bh=w1lb9REZr+ctoHFQ0Y5pTJcvB4ovwCQDN7W8p0KoojI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=mKtCpU2pBuynQHOU6LHDxQuK5VVKSS2fsjfH2+kLH1mY95mhOfmIDajIsKwaHa3dQ YZ9r3Ezlu7Ordu3P5g0WoBfppKCYgehJMY917t4PLcHSzgvn6Fw1r4uHK/TH6R7+Rb rNm/TzYyX5qpcimzNbq8ZxhwjeJTPyyPM8JcBRQc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733105AbgI2Me6 (ORCPT ); Tue, 29 Sep 2020 08:34:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:35540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729254AbgI2LVX (ORCPT ); Tue, 29 Sep 2020 07:21:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 A87EC23A34; Tue, 29 Sep 2020 11:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378361; bh=w1lb9REZr+ctoHFQ0Y5pTJcvB4ovwCQDN7W8p0KoojI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xwMl7wZolIb0tFgXC4/toIEmLN9Y4+K/oE3sckeVpv9Vca3SSumuskG0t3qC5pXDh IEwK11eoeQYRCBhR7SgdGQIS9QIueFYDUG/u9DylwNAH0cCLSIfI3/T7PspDj179DF gGrwX/hg+kpSt6WKkZNG35vKmzNgwg00opKuOFdE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shreyas Joshi , Sergey Senozhatsky , Petr Mladek , Sasha Levin Subject: [PATCH 4.14 124/166] printk: handle blank console arguments passed in. Date: Tue, 29 Sep 2020 13:00:36 +0200 Message-Id: <20200929105941.388170072@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105935.184737111@linuxfoundation.org> References: <20200929105935.184737111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Shreyas Joshi [ Upstream commit 48021f98130880dd74286459a1ef48b5e9bc374f ] If uboot passes a blank string to console_setup then it results in a trashed memory. Ultimately, the kernel crashes during freeing up the memory. This fix checks if there is a blank parameter being passed to console_setup from uboot. In case it detects that the console parameter is blank then it doesn't setup the serial device and it gracefully exits. Link: https://lore.kernel.org/r/20200522065306.83-1-shreyas.joshi@biamp.com Signed-off-by: Shreyas Joshi Acked-by: Sergey Senozhatsky [pmladek@suse.com: Better format the commit message and code, remove unnecessary brackets.] Signed-off-by: Petr Mladek Signed-off-by: Sasha Levin --- kernel/printk/printk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 4e50beb162c00..f96b22db5fe70 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2092,6 +2092,9 @@ static int __init console_setup(char *str) char *s, *options, *brl_options = NULL; int idx; + if (str[0] == 0) + return 1; + if (_braille_console_setup(&str, &brl_options)) return 1;