diff mbox series

bootloader: EBG: Add explicit guard for environment creation

Message ID 20230602095251.55859-1-christian.storm@siemens.com
State Accepted
Headers show
Series bootloader: EBG: Add explicit guard for environment creation | expand

Commit Message

Storm, Christian June 2, 2023, 9:52 a.m. UTC
Add the explicit guarding condition !inflight for creating a new
environment. EBGENV_IN_PROGRESS may be (re-)set to 0 while SWUpdate
operation, incrementing EFI Boot Guard's revision counter needlessly
by one too much.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 bootloader/ebg.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Stefano Babic June 8, 2023, 10:21 a.m. UTC | #1
On 02.06.23 11:52, 'Christian Storm' via swupdate wrote:
> Add the explicit guarding condition !inflight for creating a new
> environment. EBGENV_IN_PROGRESS may be (re-)set to 0 while SWUpdate
> operation, incrementing EFI Boot Guard's revision counter needlessly
> by one too much.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>   bootloader/ebg.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/bootloader/ebg.c b/bootloader/ebg.c
> index edfc9047..4064f070 100644
> --- a/bootloader/ebg.c
> +++ b/bootloader/ebg.c
> @@ -195,6 +195,10 @@ static char *do_env_get(const char *name)
>   
>   static int create_new_environment(void)
>   {
> +	if (inflight) {
> +		DEBUG("Reusing already created new environment.");
> +		return 0;
> +	}
>   	uint32_t revision = _env_to_uint32(_env_get(EBGENV_REVISION));
>   	uint8_t in_progress = (uint8_t)_env_to_uint32(_env_get(EBGENV_IN_PROGRESS));
>   	if ((revision == UINT_MAX) || (in_progress == UINT8_MAX)) {

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/bootloader/ebg.c b/bootloader/ebg.c
index edfc9047..4064f070 100644
--- a/bootloader/ebg.c
+++ b/bootloader/ebg.c
@@ -195,6 +195,10 @@  static char *do_env_get(const char *name)
 
 static int create_new_environment(void)
 {
+	if (inflight) {
+		DEBUG("Reusing already created new environment.");
+		return 0;
+	}
 	uint32_t revision = _env_to_uint32(_env_get(EBGENV_REVISION));
 	uint8_t in_progress = (uint8_t)_env_to_uint32(_env_get(EBGENV_IN_PROGRESS));
 	if ((revision == UINT_MAX) || (in_progress == UINT8_MAX)) {