From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 61975C433EF for ; Fri, 24 Sep 2021 02:41:14 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA47F6105A for ; Fri, 24 Sep 2021 02:41:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AA47F6105A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC60C8342C; Fri, 24 Sep 2021 04:41:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="lfezXc+B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C0A708341C; Fri, 24 Sep 2021 04:41:09 +0200 (CEST) Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E2FA28342D for ; Fri, 24 Sep 2021 04:41:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x831.google.com with SMTP id t2so1704909qtx.8 for ; Thu, 23 Sep 2021 19:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TTYwy2hzPiArlAaXNmi8jgLRwWt2mWktB6ysqSJX3e8=; b=lfezXc+BTalmBMwMYMRVHfc47tv5BmRpLEd7Yj+I1rOnLUhAgHFK97bWsAWKvEB0Q1 NgTT9FWY7F62fvTqO8/XC96LVmGbaed94/ue10sb+/WW8w125iyo05Hu8oxQT6nGUVTk cdKA3Yr85CrEJQzxNn3FJCI/SSOcRG2c8tOZ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=TTYwy2hzPiArlAaXNmi8jgLRwWt2mWktB6ysqSJX3e8=; b=eU5UFr9B7FH+/GTYRbjaM8AlAjJOreQRy+DPbbmqtOYlpsibM4YFeeZmX/A8WcO9TQ ospmmYvh79wd6S3wTdB2TCjC5tAjey9MxHPxR9FUCF5X/V3tneywMLLHX43ONfNh0IMI faBPfybZqkDTsQ19f6YBUl3ZQScXSb00Q1TBsv82KAsPdq5D8i38yRNT7pvbYfj6ldY2 atLQDMusy9rceVGQSORsfZJbqWwnL8Hm8hoAPZfb0XYlWrVeFO2c+0QOtL+ZOj8KAoGB sc4DTmc2mppCWQVAazzils9bynWtpnBUKJDr2KaDCPVPtftFt1c696auG4IckdqDAl5P uZTQ== X-Gm-Message-State: AOAM533/++ssfUPv1Ql4fgaWjc2H0a1JYv5NxBPnBChCAZL54ssx5EuG OsnGmmlKN5FL1QM1v340IIBn6A== X-Google-Smtp-Source: ABdhPJzMyyESHdDG8M0UklhmsUdpd7wgI3laHD3W9ABNZJzCfMKV46KQOJIUg2MJwFMnssFDbbDlzw== X-Received: by 2002:ac8:4d87:: with SMTP id a7mr1974545qtw.260.1632451260489; Thu, 23 Sep 2021 19:41:00 -0700 (PDT) Received: from bill-the-cat (2603-6081-7b01-cbda-11b7-7bd8-71db-92e9.res6.spectrum.com. [2603:6081:7b01:cbda:11b7:7bd8:71db:92e9]) by smtp.gmail.com with ESMTPSA id o19sm4422989qtv.85.2021.09.23.19.40.59 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Sep 2021 19:40:59 -0700 (PDT) Date: Thu, 23 Sep 2021 22:40:57 -0400 From: Tom Rini To: =?iso-8859-1?Q?Pierre-Cl=E9ment?= Tosi Cc: u-boot@lists.denx.de, Marek Vasut , Wolfgang Denk , Joe Hershberger Subject: Re: [PATCH] env: Make _init() expect _INVALID when _IS_NOWHERE Message-ID: <20210924024057.GG31748@bill-the-cat> References: <20210812152831.vucrpalduzj25h26@google.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="VuBTcNUPe5zwk2q6" Content-Disposition: inline In-Reply-To: <20210812152831.vucrpalduzj25h26@google.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean --VuBTcNUPe5zwk2q6 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 12, 2021 at 03:28:31PM +0000, Pierre-Cl=E9ment Tosi wrote: > Avoid applying the "fix" introduced by commit 5557eec01cbf ("env: Fix > invalid env handling in env_init()") to the environment "nowhere". >=20 > This is necessary as that commit, by setting the return value of > env_init() to -ENOENT if gd->env_valid is ENV_INVALID, forces that > function to reset gd->env_valid to ENV_VALID. By doing so, it breaks the > assumption (required by ENV_IS_NOWHERE) that gd->env_valid must be > ENV_INVALID. >=20 > This, in turn, results in env_relocate() calling env_load() (it should > not), which itself, calls U_BOOT_ENV_LOCATION(nowhere).load() i.e. > env_nowhere_load(). That function, being implemented under the > assumption mentioned above, calls env_set_default(), which in turn, > seeing that gd->env_valid is ENV_VALID (it should not), tries to > dereference whatever lies in gd->env_addr (most likely garbage), leading > to a faulty memory access. >=20 > Note that other env_locations might be concerned by this bug but that > this commit only intends to fix it for when ENV_IS_NOWHERE. >=20 > Fixes: 5557eec01cbf ("env: Fix invalid env handling in env_init()") > Signed-off-by: Pierre-Cl=E9ment Tosi Applied to u-boot/next, thanks! --=20 Tom --VuBTcNUPe5zwk2q6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmFNOrYACgkQFHw5/5Y0 tyx++gv+KUmQM3K79NLqJ3iGHnXNLTrQR0E3KGPf2sQz68S3WkwkXLay3oBlZ6OJ s2j+n9On3RTBRuonlDJZeq7Zxz3i7dnvymKpiAn0nhKnkb/d3Xx4zzSrXUum9o0g ydAAZe2xXmbO+7uA3I6NUNOyb55b1s1DUNuoQkpexMJ24S9bW+c/cXnLzvNZIJE9 6UsP1xmv9uFKPViV/KmmGfdWOKGUdBoMhR0Y4k9FZA7cd9fW1iYkOWmWP1c6hpYX qDeddGlfVDN20HOgJeL7aHqXcDawnYDRW46c44djb0XyvtnCNZ9CVdGYFrb0xRq7 8Tq0Bg7pu4jH9BjPEsJnDUhUgITuhaAoTjkQEG9305g+i2Gz/+AtJ9kTf6+/E2Xh jeBobWX/gRCPNQQaEJsuk9qnTMI1z5tbce00nWsdMy6BLYkZ83/L8lSog1HEQel1 pYGURbWmhdz24yVf78ZWQeCllUy5pnX9e/tx13Wi5dLJhwlCoXfZIFusvj1aqA/w uOZERiuK =k9UJ -----END PGP SIGNATURE----- --VuBTcNUPe5zwk2q6--