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 2D5A6C433F5 for ; Fri, 24 Sep 2021 11:41:17 +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 4739161164 for ; Fri, 24 Sep 2021 11:41:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4739161164 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 916F183457; Fri, 24 Sep 2021 13:41:13 +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="AGBnneEX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8C13B83460; Fri, 24 Sep 2021 13:41:10 +0200 (CEST) Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) (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 2BC088343C for ; Fri, 24 Sep 2021 13:41:04 +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-qk1-x736.google.com with SMTP id 138so27277266qko.10 for ; Fri, 24 Sep 2021 04:41:04 -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=G9BKNxa8kB86xnbUVvNB29j1sLX1VpyMAVfQxjgW5Xw=; b=AGBnneEXpThddOxEWDL/kTD/1bzJsKn2MC4ctEy9qq9/YtcUfobv3p6HP8fYbd+CU+ 7bYeKenHpXodlbg41u/ANJA6buSWB9OUYosgiZaI5+MJcdktSumVmZrltZ+n1GQMw9+M V0Gs0E00xgBtltzsjefZ/rDPK0O/1EEsAqtfk= 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=G9BKNxa8kB86xnbUVvNB29j1sLX1VpyMAVfQxjgW5Xw=; b=h8rGwMON/1Kg7FWRCrJBk9WWj2SEDT16Lcpm/Avj3spa0583XxHtMQsudhB3Z6DyLi V5gymHTdLK5J0021rqFdjfJMeCpM2zPgpHGTWh7d/tTxnpHEir54fSqYagMuzthome/Z hHOHSVIKVPXucAMU8QCjGt9U6nfSANsliLIGt4GmfpDPOtZ/mA3A3aLLbD38xATeCqJr H9YeTa/yLF5BqI/q4Fmc4j6WWaYSoY7Yc1k628SUc+CWSEmmQeEhmsSCHBgqiSfHMGze Jw14UZwOCZuzTKCmJbqIyN+3h5q072HQ7uegzo9aArYJ/aHsiGV3OZE+mVCmJSohFfmE 0pWg== X-Gm-Message-State: AOAM530TnqXRJqHLNBajvphV6i7ebZlcCKiFh3t91hu8tY/y0qAea9Cl myEfAn5TNWT8y71voS3sNXJt3w== X-Google-Smtp-Source: ABdhPJzwEXJrplBBfx47XK+af6qaOnu1MXUgW21Pl5S4GaoioKxeJljuqgr/2EmQ4CQ3E+/VnadZHQ== X-Received: by 2002:a37:a193:: with SMTP id k141mr9668690qke.447.1632483662792; Fri, 24 Sep 2021 04:41:02 -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 m27sm6120909qkm.57.2021.09.24.04.41.01 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Sep 2021 04:41:02 -0700 (PDT) Date: Fri, 24 Sep 2021 07:41:00 -0400 From: Tom Rini To: Marek Vasut Cc: =?iso-8859-1?Q?Pierre-Cl=E9ment?= Tosi , u-boot@lists.denx.de, Wolfgang Denk , Joe Hershberger Subject: Re: [PATCH] env: Make _init() expect _INVALID when _IS_NOWHERE Message-ID: <20210924114100.GZ31748@bill-the-cat> References: <20210812152831.vucrpalduzj25h26@google.com> <20210924024057.GG31748@bill-the-cat> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="pr2uf1USn+1lHhL+" Content-Disposition: inline In-Reply-To: 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 --pr2uf1USn+1lHhL+ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 24, 2021 at 05:04:27AM +0200, Marek Vasut wrote: > On 9/24/21 4:40 AM, Tom Rini wrote: > > On Thu, Aug 12, 2021 at 03:28:31PM +0000, Pierre-Cl=E9ment Tosi wrote: > >=20 > > > 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), lead= ing > > > 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 > >=20 > > Applied to u-boot/next, thanks! >=20 > Please drop this, quote from my previous reply to this patch: >=20 > " > Such patch was already posted, see the patch and the discussion, in the e= nd > there was a different fix for the relocation code: >=20 > https://patchwork.ozlabs.org/project/uboot/patch/1620828554-24013-1-git-s= end-email-hayashi.kunihiko@socionext.com/ > " I'll drop this. FWIW, my reading of the previous patch, and then this being posted afterwards is why I had applied this patch. --=20 Tom --pr2uf1USn+1lHhL+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmFNuUgACgkQFHw5/5Y0 tyyc6wwAsv4YgyMhtZt7kQMruRkQ8n7aN3q6ZZ2VwW6pcEJCbMkKGO9QiX+TxebC 9gp/WTIcvVaDXNvxbufbgM6meWMmTgdq6guJIA4mdqKjqq4xJobmfTcrt8oN/xyH P5T0xTXObOsAQhwrUB9yGBH5lyDamsO3Ey2SEvNUkJeu3bwjFC4FDKby0czPv8eH nlEDXi4bhafZ0W9dsJDVlck61m7CX+srHVVXZK7VunGhe+QoUMKGDWUR2myOiDDS YxWHy7cEZs9mbBrBiX4DnURnvjuCIrXMFdC/gsgAs1nFQAJWIoHRomqjIhMiV/xx vTAOT1hKxcUwjuGVk4HoDn/TCjvdzUVyEAQNeTP7NwPGmg4kRhkX7ulpE3v3TumG 7SBLsjTCSt3bSjfc4KAZfBxNtLTK2gjSZYXH0InlsKYmBy/JujxuboqeodAIHaji 96Z7CnFtUNZ/bdce+ALScKqPGmyOqocd1O/hgzPREiplLuK5bYLQVGBFW4rXyF/T St28gly8 =HHNP -----END PGP SIGNATURE----- --pr2uf1USn+1lHhL+--