From patchwork Tue Sep 29 11:00:25 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: 263006 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=unavailable 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 7F283C47423 for ; Tue, 29 Sep 2020 12:23:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FF0F2076A for ; Tue, 29 Sep 2020 12:23:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601382213; bh=CViT9YanrobkeCxJtGqa5HogF32VB1HzO7rKTYXvse4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lYHKE3+blK42LRMLXSl67LoYUUBvNkCEPbxCVE3RKUCoxSW1HaAgcgF82DSmHDLHz uk1vY6TKOEsNEjHnU3nKlqHBjWrwdW0oSUoaO0Qkdpp7fIyLnt98maaAC2iBTtmTsZ lGWQPojR6W1h4B2PZ4XMu5/weMTWjeTLUe17lqTY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731139AbgI2MXU (ORCPT ); Tue, 29 Sep 2020 08:23:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:46898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729789AbgI2LfK (ORCPT ); Tue, 29 Sep 2020 07:35:10 -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 43D2E23D1F; Tue, 29 Sep 2020 11:29:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378959; bh=CViT9YanrobkeCxJtGqa5HogF32VB1HzO7rKTYXvse4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1a64qromDgJ1dhAMll0dxrW9n/nXtqwjiqnH1MVy/NP06ic4j0hrUB6Lmlmdc7Ok os1YLEKR8a37JaA6fe7Laxj2a4pc5rA3RS07Tf6sQpe8iBwLM14hF4odZTmY/2PHrR OdFgbqUPSO1T1ZUOARF/+SOdEHkkkdj47PV7pR1g= 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.19 174/245] printk: handle blank console arguments passed in. Date: Tue, 29 Sep 2020 13:00:25 +0200 Message-Id: <20200929105955.443878113@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105946.978650816@linuxfoundation.org> References: <20200929105946.978650816@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 3cb0e5b479ff3..cf272aba362be 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2148,6 +2148,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;