From patchwork Tue Sep 29 11:00:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 291225 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 58091C4727F for ; Tue, 29 Sep 2020 11:08:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B41223899 for ; Tue, 29 Sep 2020 11:08:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377703; bh=/ZAwuKiXNjc056PuV0zsg3VrZ2lpMBgP7TwugljyCZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=LULD+KBb2DHD/XAOve3F82v6s5mIMiyriF0602NvvuC9nH5kR879Mw8ze2ku7sxVt rOITTE+sOM/FDrwk+/lEHTA4DRC4ZzqLQ8GFEdjJ/7ARpbZ2PN4FxtmDa36j9lAw3V nJZv4v1AwclcA21wOzpiGEuAekUPbExX2O88rNFY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728678AbgI2LIW (ORCPT ); Tue, 29 Sep 2020 07:08:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:44064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728828AbgI2LGh (ORCPT ); Tue, 29 Sep 2020 07:06:37 -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 1470222574; Tue, 29 Sep 2020 11:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377590; bh=/ZAwuKiXNjc056PuV0zsg3VrZ2lpMBgP7TwugljyCZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kBW/EwfWKEDCzJ2bjFvXaJqoyAufzxC5BMXwGyJLpSlIjSDF4xqgBcxW1IYxoWtZZ xHlvF+zFVxK8WbVKowA2vdfQDjPH08cqf5rnYmVSnT0lHfuBKsMRrDNqXK7hg4tqcS F41Z+GgwwxY++BzNi+7MN8WlcK16/bZxrJCyXYuA= 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.4 64/85] printk: handle blank console arguments passed in. Date: Tue, 29 Sep 2020 13:00:31 +0200 Message-Id: <20200929105931.413526638@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105928.198942536@linuxfoundation.org> References: <20200929105928.198942536@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 e53a976ca28ea..b55dfb3e801f9 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2032,6 +2032,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;