summaryrefslogtreecommitdiff
path: root/fs/efivarfs/vars.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2023-12-08 17:39:29 +0100
committerArd Biesheuvel <ardb@kernel.org>2023-12-11 11:19:18 +0100
commitcdb46a8aefbf7fd36772bb206aaaf7e45d7cf8f6 (patch)
treeb0eb3387296b811d060af9ce3e5f57b2b9d392ae /fs/efivarfs/vars.c
parent547713d502f7b4b8efccd409cff84d731a23853b (diff)
efivarfs: Move efivarfs list into superblock s_fs_info
syzbot reports issues with concurrent fsopen()/fsconfig() invocations on efivarfs, which are the result of the fact that the efivarfs list (which caches the names and GUIDs of existing EFI variables) is a global structure. In normal use, these issues are unlikely to trigger, even in the presence of multiple mounts of efivarfs, but the execution pattern used by the syzkaller reproducer may result in multiple instances of the superblock that share the global efivarfs list, and this causes list corruption when the list is reinitialized by one user while another is traversing it. So let's move the list head into the superblock s_fs_info field, so that it will never be shared between distinct instances of the superblock. In the common case, there will still be a single instance of this list, but in the artificial syzkaller case, no list corruption can occur any longer. Reported-by: syzbot+1902c359bfcaf39c46f2@syzkaller.appspotmail.com Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'fs/efivarfs/vars.c')
-rw-r--r--fs/efivarfs/vars.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/efivarfs/vars.c b/fs/efivarfs/vars.c
index 9e4f47808bd5..114ff0fd4e55 100644
--- a/fs/efivarfs/vars.c
+++ b/fs/efivarfs/vars.c
@@ -369,7 +369,8 @@ 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 *),
+int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
+ struct list_head *),
void *data, bool duplicates, struct list_head *head)
{
unsigned long variable_name_size = 1024;
@@ -420,7 +421,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
status = EFI_NOT_FOUND;
} else {
err = func(variable_name, vendor_guid,
- variable_name_size, data);
+ variable_name_size, data, head);
if (err)
status = EFI_NOT_FOUND;
}