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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0E917C63797 for ; Thu, 2 Feb 2023 08:09:49 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E909685EBD; Thu, 2 Feb 2023 09:08:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=siemens.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; secure) header.d=siemens.com header.i=jan.kiszka@siemens.com header.b="Jczm1M8j"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A5E7985EB4; Thu, 2 Feb 2023 09:08:23 +0100 (CET) Received: from mta-64-227.siemens.flowmailer.net (mta-64-227.siemens.flowmailer.net [185.136.64.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8EE5085CE2 for ; Thu, 2 Feb 2023 09:08:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=siemens.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jan.kiszka@siemens.com Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 20230202080800be5852fc27bcae463e for ; Thu, 02 Feb 2023 09:08:00 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=jan.kiszka@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=blRkYJFW6RH1gA/p+YyXS6dyV0paFFjlmc0sjGDh3Lc=; b=Jczm1M8jWxz5UW6w974kEDHxlDWd5PF5qWSS0l7nqe5VUFJxra4Kbrt0D5zoyLVm88DC4m +w4J1KErvd+/tcI3bNOcid6o+Qka6KL+pc4qUmuI8PQD7LdIQPo6s8InSX5Rt7xmSg1fW3P1 FTI6ddoYY9N1scFqoky5dzvxsi7Eo=; From: Jan Kiszka To: U-Boot Mailing List Cc: Joe Hershberger , Marek Vasut , Stefan Herbrechtsmeier Subject: [PATCH V4 01/14] env: Complete generic support for writable list Date: Thu, 2 Feb 2023 09:07:46 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-294854:519-21489:flowmailer X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean From: Jan Kiszka This completes what 890feecaab72 started by selecting ENV_APPEND and loading the default env before any other sources. This ensures that load operations pick up all non-writable vars from the default env and only permitted parts from other locations according to the regular priorities. With this change, boards only need to define the list of writable variables but no longer have to provide a custom env_get_location implementation. CC: Joe Hershberger CC: Marek Vasut CC: Stefan Herbrechtsmeier Signed-off-by: Jan Kiszka Reviewed-by: Marek Vasut --- env/Kconfig | 1 + env/env.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/env/Kconfig b/env/Kconfig index c409ea71fe5..6e24eee55f2 100644 --- a/env/Kconfig +++ b/env/Kconfig @@ -733,6 +733,7 @@ config ENV_APPEND config ENV_WRITEABLE_LIST bool "Permit write access only to listed variables" + select ENV_APPEND help If defined, only environment variables which explicitly set the 'w' writeable flag can be written and modified at runtime. No variables diff --git a/env/env.c b/env/env.c index 06078c7f374..45e638fcd1f 100644 --- a/env/env.c +++ b/env/env.c @@ -195,6 +195,14 @@ int env_load(void) int best_prio = -1; int prio; + if (CONFIG_IS_ENABLED(ENV_WRITEABLE_LIST)) { + /* + * When using a list of writeable variables, the baseline comes + * from the built-in default env. So load this first. + */ + env_set_default(NULL, 0); + } + for (prio = 0; (drv = env_driver_lookup(ENVOP_LOAD, prio)); prio++) { int ret; -- 2.35.3