summaryrefslogtreecommitdiffstats
path: root/fs/efivarfs/vars.c
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2025-01-07 22:31:29 +0100
committerArd Biesheuvel <ardb@kernel.org>2025-01-22 13:28:17 +0100
commitb5d1e6ee761a109400e97ac6a1b91c57d0f6a43a (patch)
tree0d0e93990f4afe25b16ddbc5d395b7bdacbbc86c /fs/efivarfs/vars.c
parentefivarfs: abstract initial variable creation routine (diff)
downloadlinux-b5d1e6ee761a109400e97ac6a1b91c57d0f6a43a.tar.xz
linux-b5d1e6ee761a109400e97ac6a1b91c57d0f6a43a.zip
efivarfs: add variable resync after hibernation
Hibernation allows other OSs to boot and thus the variable state might be altered by the time the hibernation image is resumed. Resync the variable state by looping over all the dentries and update the size (in case of alteration) delete any which no-longer exist. Finally, loop over all efi variables creating any which don't have corresponding dentries. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> [ardb: - apply error pointer fixup from Dan Carpenter - rebase onto latest version of James's efivarfs rework] Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to '')
-rw-r--r--fs/efivarfs/vars.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/efivarfs/vars.c b/fs/efivarfs/vars.c
index d0beecbf9441..6edc10958ecf 100644
--- a/fs/efivarfs/vars.c
+++ b/fs/efivarfs/vars.c
@@ -364,6 +364,7 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
* efivar_init - build the initial list of EFI variables
* @func: callback function to invoke for every variable
* @data: function-specific data to pass to @func
+ * @duplicate_check: fail if a duplicate variable is found
*
* Get every EFI variable from the firmware and invoke @func. @func
* should populate the initial dentry and inode tree.
@@ -371,7 +372,7 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
* Returns 0 on success, or a kernel error code on failure.
*/
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
- void *data)
+ void *data, bool duplicate_check)
{
unsigned long variable_name_size = 512;
efi_char16_t *variable_name;
@@ -415,7 +416,8 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
* we'll ever see a different variable name,
* and may end up looping here forever.
*/
- if (efivarfs_variable_is_present(variable_name,
+ if (duplicate_check &&
+ efivarfs_variable_is_present(variable_name,
&vendor_guid, data)) {
dup_variable_bug(variable_name, &vendor_guid,
variable_name_size);