From: Alexey Nepomnyashih <sdl@nppct.ru>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Alexey Nepomnyashih <sdl@nppct.ru>, Jeremy Kerr <jk@ozlabs.org>,
linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: [PATCH 5.10 1/2] efi: vars: Use locking version to iterate over efivars linked lists
Date: Fri, 21 Mar 2025 18:21:24 +0000 [thread overview]
Message-ID: <20250321182126.1716111-1-sdl@nppct.ru> (raw)
From: Ard Biesheuvel <ardb@kernel.org>
commit 3a75f9f2f9ad19bb9a0f566373ae91d8f09db85e upstream.
Both efivars and efivarfs uses __efivar_entry_iter() to go over the
linked list that shadows the list of EFI variables held by the firmware,
but fail to call the begin/end helpers that are documented as a
prerequisite.
So switch to the proper version, which is efivar_entry_iter(). Given
that in both cases, efivar_entry_remove() is invoked with the lock held
already, don't take the lock there anymore.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Alexey Nepomnyashih <sdl@nppct.ru>
---
drivers/firmware/efi/efivars.c | 8 ++------
drivers/firmware/efi/vars.c | 9 +--------
fs/efivarfs/super.c | 9 +++------
include/linux/efi.h | 3 ++-
4 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index e6b16b3a17a8..b925571ee593 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -608,10 +608,7 @@ static int efivars_sysfs_callback(efi_char16_t *name, efi_guid_t vendor,
static int efivar_sysfs_destroy(struct efivar_entry *entry, void *data)
{
- int err = efivar_entry_remove(entry);
-
- if (err)
- return err;
+ efivar_entry_remove(entry);
efivar_unregister(entry);
return 0;
}
@@ -621,8 +618,7 @@ static void efivars_sysfs_exit(void)
/* Remove all entries and destroy */
int err;
- err = __efivar_entry_iter(efivar_sysfs_destroy, &efivar_sysfs_list,
- NULL, NULL);
+ err = efivar_entry_iter(efivar_sysfs_destroy, &efivar_sysfs_list, NULL);
if (err) {
pr_err("efivars: Failed to destroy sysfs entries\n");
return;
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index eaed1ddcc803..010febd2ab6b 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -534,17 +534,10 @@ EXPORT_SYMBOL_GPL(efivar_entry_add);
/**
* efivar_entry_remove - remove entry from variable list
* @entry: entry to remove from list
- *
- * Returns 0 on success, or a kernel error code on failure.
*/
-int efivar_entry_remove(struct efivar_entry *entry)
+void efivar_entry_remove(struct efivar_entry *entry)
{
- if (down_interruptible(&efivars_lock))
- return -EINTR;
list_del(&entry->list);
- up(&efivars_lock);
-
- return 0;
}
EXPORT_SYMBOL_GPL(efivar_entry_remove);
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 99d002438008..24a0c5ef4169 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -180,10 +180,7 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
static int efivarfs_destroy(struct efivar_entry *entry, void *data)
{
- int err = efivar_entry_remove(entry);
-
- if (err)
- return err;
+ efivar_entry_remove(entry);
kfree(entry);
return 0;
}
@@ -219,7 +216,7 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
err = efivar_init(efivarfs_callback, (void *)sb, true, &efivarfs_list);
if (err)
- __efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL, NULL);
+ efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL);
return err;
}
@@ -255,7 +252,7 @@ static void efivarfs_kill_sb(struct super_block *sb)
kill_litter_super(sb);
/* Remove all entries and destroy */
- __efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL, NULL);
+ efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL);
}
static struct file_system_type efivarfs_type = {
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 5554d26f91d8..7c5beec4287a 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -994,7 +994,8 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
void *data, bool duplicates, struct list_head *head);
int efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
-int efivar_entry_remove(struct efivar_entry *entry);
+void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
+void efivar_entry_remove(struct efivar_entry *entry);
int __efivar_entry_delete(struct efivar_entry *entry);
int efivar_entry_delete(struct efivar_entry *entry);
--
2.43.0
next reply other threads:[~2025-03-21 18:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 18:21 Alexey Nepomnyashih [this message]
2025-03-21 18:21 ` [PATCH 5.10 2/2] efivarfs: Add efivars_lock to synchronize list operations Alexey Nepomnyashih
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250321182126.1716111-1-sdl@nppct.ru \
--to=sdl@nppct.ru \
--cc=ardb@kernel.org \
--cc=jk@ozlabs.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox