Message ID | 20230411111426.55889-1-jiaxun.yang@flygoat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2497364vqo; Tue, 11 Apr 2023 04:29:30 -0700 (PDT) X-Google-Smtp-Source: AKy350baOOYTShXeFKkLNoPz8ZdCUG/re8+BO86yZmxEI0e/c+TMYvOyEBHnsF2i5N0SLbj8Uh/W X-Received: by 2002:a05:6a20:734a:b0:d8:d9ab:4b82 with SMTP id v10-20020a056a20734a00b000d8d9ab4b82mr21378282pzc.15.1681212570373; Tue, 11 Apr 2023 04:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681212570; cv=none; d=google.com; s=arc-20160816; b=cU1NO+LSa589e4VwwhfTrpIjQqhtrIOFPavjDimfzQ6T8exwNZRkg3kzv5/tAtECe4 Ivs4u11wXxVSr+2QmBEm11sIVmAZu5MIJON6EFPGLHCTMQM3a/g1mEaQ+Nc5rPzOd6u1 n4s7+MRCVG3tSjlt+hOu+Im/IQkT2lpUyTIC4EdmNPNggy1uBdmWMhsxe+IcJBqU7gOP xSsnHsLsN0xWJdAbo6F8hF5hD21PPZaN63VYvlNdEntTQKziU9xkJulFt0J/WJnGvWJm oBswbhBSxBNM5L+ybBsrn4ORIJ9nlk6WYN+YGOEwDsCOv6pQEzBAvDJdUkpS4Ho7CPbL hqmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=U6Fxzg96jCMbXos8W2IcNTwOEcFKqCEbDJjjFmLV69Y=; b=RIl8kE2uOggfCiXV56H0N3fPXz2KtWbbeSFeMcFdUoxfVwBYtwIsboFV03/l3Wj+fn afwKibH1rrvSwo34I2fE9B7gQj/F5o2S2nFujsbhkDWM119aAnE/SYSd1Uhi73U6vvKW QI/fgNaC7njcA8iNCBnolTgef+lzUEyGTaa4ro2+rfRJ7x5D/wGgkwvU3VIxsgkG3Jjt 1jk4lnOonmPw71lDdPRc429HYWrX9Hk8ungVnyGFF3vScoTUUI+1LoI0e0iyjflbT55f bALTaX2Q/zpFFtDWpxjTPTvm1NnaEe64h74gYV0s22Pmo2kcYDRC9i61XYiVV0N/2nqS kvWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=cX7LghG5; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=dPcZIN4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e35-20020a630f23000000b004fbba5bc71csi12678954pgl.75.2023.04.11.04.29.18; Tue, 11 Apr 2023 04:29:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=cX7LghG5; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=dPcZIN4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbjDKLPJ (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Tue, 11 Apr 2023 07:15:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229904AbjDKLPE (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 11 Apr 2023 07:15:04 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60004448E; Tue, 11 Apr 2023 04:14:47 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 752CE5C01E7; Tue, 11 Apr 2023 07:14:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Tue, 11 Apr 2023 07:14:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm1; t=1681211671; x=1681298071; bh=U6Fxzg96jC MbXos8W2IcNTwOEcFKqCEbDJjjFmLV69Y=; b=cX7LghG5CZ3L4u3+Ecxxfl3AGJ FYuHKu3H+sVf1bujXNhIfOoiBeotyCypvK9lpOa9LyJw2S4KFRyDN9Nn1Zbj8EkQ rPfSPdJ3R6TgaZcNBpnDqhwkdCqPP4W1Zl8RPnifNtGzq0UZoZLJ+FkmaEf41qmy YKU7qsIGM5Al+1T/1tnZBcUQwkJH8wDhMT0Nmy2od+vR/A9eiB2q8uDmRETh95KO HObAzkD/rFHIlkJutzcIzjsYGL8qlLyZ1lnUsh4ApX6DS05Wz0alz5al5qNQ76SL qdOCSIaj+2uzVvCoUdtfsaWDmdbHKQKj2Ds/YochBOi5AoxcxVK3yIW4rpQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1681211671; x=1681298071; bh=U6Fxzg96jCMbX os8W2IcNTwOEcFKqCEbDJjjFmLV69Y=; b=dPcZIN4sjLfCF6Xt5a4CXQKR7WHEX 1pGS8iXTTKhNbNvHvaz5enOjG+JbA1Wvv5qNhgNJp7XMwMh2T2d1bYiuiBFgOTfe 5yM1gjBDgov+mQugcnUaERLIgebfIqpXn1YQoeEnTglaj/+PIYkoUWoPhcWIJjsS FJeT4sQZQeqh2WLtw2Z1suGSjepk2f/e9LnLWElGUUwlSiFSmZH1OKn0RA4QHXsB 7SSPm5hu4DPo+Xtpnv2kwPnMGE8bOsYfMyHp+4mAq+vgcIlVNcObkXfvDet3K9ue Q9Kr+kSxI/FjYT22tB1AGmhEkZN/TK+2AyjQN+0xAudLLcyXkvcmW6lkg== X-ME-Sender: <xms:F0E1ZGH1rYcXjTDZmZi6Nc-PwKCmEdi38MauClB_sKEyvptuFDHm6Q> <xme:F0E1ZHW86Kplr3WOle_94loV57IXtXdj23YCc8yqxS7yjbCqMwahvh9cQ33n392ID zX46jwqnDgGHsCmk7U> X-ME-Received: <xmr:F0E1ZAK0pQeqPFSH549wghRmx2VI5idTjLupMn7XqsVRVJ5c7NGhIBmCjy7G> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekgedgfeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffoggfgsedtkeertd ertddtnecuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghes fhhlhihgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepgfdtheehiedvgeduudduvd duleegleffgeekjedttdfhhfefleetheevvefftefgnecuffhomhgrihhnpehgihhthhhu sgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: <xmx:F0E1ZAHdAhSufrLtdviMj18Oo2T1bFBbVgfMVhX3NDBlwxGSz2EMgw> <xmx:F0E1ZMXD9u7Bv76HMYD09NoaJQexq4uFieK6--ePEHXi9qNVwqOrBA> <xmx:F0E1ZDP1dkNAIxl8tMuLimX0IIJYr2W-HjgM57WwRdrsWl9FKnCdSQ> <xmx:F0E1ZKyDa8EYrneCSRNBAHZZKgR3lIMM7_nn1XOw3eEMj6pDb27Tjw> Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 11 Apr 2023 07:14:30 -0400 (EDT) From: Jiaxun Yang <jiaxun.yang@flygoat.com> To: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org, tsbogend@alpha.franken.de, and@gmx.com, Jiaxun Yang <jiaxun.yang@flygoat.com>, stable@vger.kernel.org Subject: [PATCH] MIPS: fw: Allow firmware to pass a empty env Date: Tue, 11 Apr 2023 12:14:26 +0100 Message-Id: <20230411111426.55889-1-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762879152324818449?= X-GMAIL-MSGID: =?utf-8?q?1762879152324818449?= |
Series |
MIPS: fw: Allow firmware to pass a empty env
|
|
Commit Message
Jiaxun Yang
April 11, 2023, 11:14 a.m. UTC
fw_getenv will use env entry to determine style of env,
however it is legal for firmware to just pass a empty list.
Check if first entry exist before running strchr to avoid
null pointer dereference.
Cc: stable@vger.kernel.org
Link: https://github.com/clbr/n64bootloader/issues/5
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
Note: Fixes tag is intentionally omitted for this patch, although
the booting issue only comes in 6.1, the logic issue is been since very start.
---
arch/mips/fw/lib/cmdline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Apr 11, 2023 at 12:14:26PM +0100, Jiaxun Yang wrote: > fw_getenv will use env entry to determine style of env, > however it is legal for firmware to just pass a empty list. > > Check if first entry exist before running strchr to avoid > null pointer dereference. > > Cc: stable@vger.kernel.org > Link: https://github.com/clbr/n64bootloader/issues/5 > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> > --- > Note: Fixes tag is intentionally omitted for this patch, although > the booting issue only comes in 6.1, the logic issue is been since very start. > --- > arch/mips/fw/lib/cmdline.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/mips/fw/lib/cmdline.c b/arch/mips/fw/lib/cmdline.c > index f24cbb4a39b5..892765b742bb 100644 > --- a/arch/mips/fw/lib/cmdline.c > +++ b/arch/mips/fw/lib/cmdline.c > @@ -53,7 +53,7 @@ char *fw_getenv(char *envname) > { > char *result = NULL; > > - if (_fw_envp != NULL) { > + if (_fw_envp != NULL && fw_envp(0) != NULL) { > /* > * Return a pointer to the given environment variable. > * YAMON uses "name", "value" pairs, while U-Boot uses > -- > 2.39.2 (Apple Git-143) applied to mips-next. Thomas.
diff --git a/arch/mips/fw/lib/cmdline.c b/arch/mips/fw/lib/cmdline.c index f24cbb4a39b5..892765b742bb 100644 --- a/arch/mips/fw/lib/cmdline.c +++ b/arch/mips/fw/lib/cmdline.c @@ -53,7 +53,7 @@ char *fw_getenv(char *envname) { char *result = NULL; - if (_fw_envp != NULL) { + if (_fw_envp != NULL && fw_envp(0) != NULL) { /* * Return a pointer to the given environment variable. * YAMON uses "name", "value" pairs, while U-Boot uses