public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 00/11] Introduce variables whitelisting in environment
@ 2017-12-22 21:13 Quentin Schulz
  2017-12-22 21:13 ` [U-Boot] [PATCH 01/11] env: fix ret not being set and fails when no env could have been init Quentin Schulz
                   ` (12 more replies)
  0 siblings, 13 replies; 18+ messages in thread
From: Quentin Schulz @ 2017-12-22 21:13 UTC (permalink / raw)
  To: u-boot

This patch series is based on this[1] patch series from Maxime.

This is an RFC. It's been only tested in a specific use case on a custom
i.MX6 board. It's known to break compilation on a few boards.

I have a use case where we want some variables from a first environment to
be overriden by variables from a second environment. For example, we want
to load variables from the default env (ENV_IS_NOWHERE) and then load only
a handful of other variables from, e.g., NAND.

In our use case, we basically can be sure that the default env in the
U-Boot binary is secure but we want only a few variables to be modified,
thus keeping control over the overall behaviour of U-Boot in secure mode.

It works in that way:
  - from highest to lowest priority, the first environment that can be
  loaded (that has successfully init and whose load function has returned
  no errors) will be the main environment,
  - then, all the following environment that could be successfully loaded
  (same conditions as the main environment) are secondary environment. The
  env variables that are defined both in CONFIG_ENV_VAR_WHITELIST_LIST and
  in the secondary environments override the ones in the main environment,
  - for saving, we save the whole environment to all environments
  available, be they main or secondary (it does not matter to save the
  whole environment on secondary environments as only the whitelisted
  variables will be overriden in the loading process,

I have also a few questions that could help me to get the whole thing to
work.

1) I can't really get my head around the use of gd->env_addr, what is it used
for? It is set in a bunch of different places but only once is it
explicitly used (basically to alternate the env_addr between the one
associated to main and redundant environment (in NAND for example)).

2) Why do we consider ENV_IS_NOWHERE an invalid environment? The only place I
found a use for it was to just say that if the environment is invalid, we
should set to default environment (in env_relocate in env/common.c). With
my patch series I guess that we could remove this fallback and force
ENV_IS_NOWHERE to be always there.

3) There are a few (20) boards that set gd->env_addr and gd->env_valid in
their board file. What is the reason to do such a thing? Isn't those
overriden anyway by the environment driver?

I'm looking forward to getting your feedback on this patch series.

Thanks,
Quentin

[1] https://patchwork.ozlabs.org/cover/842057/

Quentin Schulz (11):
  env: fix ret not being set and fails when no env could have been init
  lib: hashtable: support whitelisting env variables
  env: add support for whitelisting variables from secondary environments
  env: make nowhere an env medium like the others
  cmd: saveenv: enable the saveenv command when ENV_IS_NOWHERE is defined but another env medium is enabled too
  env: add env_driver to env_driver functions' arguments
  env: gd flags without ENV_READY is enough to discriminate in env_get_default
  env: add env_driver parameter to env_import_redund
  env: make env_locations a global variable
  env: introducing env_info struct for storing info per env
  env: store information about each environment in gd

 board/sunxi/board.c               |   2 +-
 cmd/nvedit.c                      |  16 ++-
 common/board_r.c                  |   8 +-
 env/Kconfig                       |  29 +++---
 env/common.c                      |  45 ++++++----
 env/eeprom.c                      |  40 ++++-----
 env/env.c                         | 142 +++++++++++++++++++++++++------
 env/ext4.c                        |   4 +-
 env/fat.c                         |   4 +-
 env/flash.c                       |  58 ++++++-------
 env/mmc.c                         |  14 +--
 env/nand.c                        |  46 +++++-----
 env/nowhere.c                     |  12 ++-
 env/nvram.c                       |  18 ++--
 env/onenand.c                     |   6 +-
 env/remote.c                      |  10 +-
 env/sata.c                        |   4 +-
 env/sf.c                          |  34 +++----
 env/ubi.c                         |  14 +--
 include/asm-generic/global_data.h |   5 +-
 include/environment.h             |  59 ++++++++-----
 include/search.h                  |   2 +-
 lib/hashtable.c                   |  17 +++-
 23 files changed, 379 insertions(+), 210 deletions(-)

base-commit: 5d41e28058e7b378c9fa5c61ecc074a682ba2db4
-- 
git-series 0.9.1

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-01-08  4:50 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-22 21:13 [U-Boot] [PATCH 00/11] Introduce variables whitelisting in environment Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 01/11] env: fix ret not being set and fails when no env could have been init Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 02/11] lib: hashtable: support whitelisting env variables Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 03/11] env: add support for whitelisting variables from secondary environments Quentin Schulz
2017-12-26 11:21   ` Lukasz Majewski
2018-01-03 11:07     ` Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 04/11] env: make nowhere an env medium like the others Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 05/11] cmd: saveenv: enable the saveenv command when ENV_IS_NOWHERE is defined Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 06/11] env: add env_driver to env_driver functions' arguments Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 07/11] env: gd flags without ENV_READY is enough to discriminate in Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 08/11] env: add env_driver parameter to env_import_redund Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 09/11] env: make env_locations a global variable Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 10/11] env: introducing env_info struct for storing info per env Quentin Schulz
2017-12-22 21:13 ` [U-Boot] [PATCH 11/11] env: store information about each environment in gd Quentin Schulz
2017-12-26 11:25 ` [U-Boot] [PATCH 00/11] Introduce variables whitelisting in environment Lukasz Majewski
2017-12-29  3:13 ` Simon Glass
2018-01-03  9:18   ` Quentin Schulz
2018-01-08  4:50     ` Simon Glass

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox