From: Christian Storm <[email protected]> If both two environments have the same revision, then bgenv_open_latest() and bgenv_open_oldest() return the exact same BGENV which then gets reset, losing the kernel, kernelfile, and watchdog timeout information.
The control flow-following memcpy() in ebg_env_create_new() at env/env_api.c:86, intended to preserve this information, is futile. Hence, only reset the env if latest and oldest differ. Signed-off-by: Christian Storm <[email protected]> --- env/env_api_fat.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/env/env_api_fat.c b/env/env_api_fat.c index d588e7f..503dedf 100644 --- a/env/env_api_fat.c +++ b/env/env_api_fat.c @@ -437,20 +437,22 @@ BGENV *bgenv_create_new(void) int new_rev = env_latest->data->revision + 1; - bgenv_close(env_latest); - env_new = bgenv_open_oldest(); if (!env_new) { + bgenv_close(env_latest); goto create_new_io_error; } - /* zero fields */ - memset(env_new->data, 0, sizeof(BG_ENVDATA)); + if (env_latest->data != env_new->data) { + /* zero fields */ + memset(env_new->data, 0, sizeof(BG_ENVDATA)); + /* set default watchdog timeout */ + env_new->data->watchdog_timeout_sec = DEFAULT_TIMEOUT_SEC; + } + bgenv_close(env_latest); /* update revision field and testing mode */ env_new->data->revision = new_rev; env_new->data->in_progress = 1; - /* set default watchdog timeout */ - env_new->data->watchdog_timeout_sec = DEFAULT_TIMEOUT_SEC; return env_new; -- 2.40.1 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20230602155739.106035-1-christian.storm%40siemens.com.
