Skip to contentSkip to conversation

fs/efivarfs: Permit read-only access on platforms that lack SetVariable

PATCH Superseded Ard Biesheuvel 1 participant 1 message Jul 8, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ard Biesheuvel

author maintainer
#0 lore raw

PATCH 1/1 fs/efivarfs: Permit read-only access on platforms that lack SetVariable

Commit

bf67fad19e493b ("efi: Use more granular check for availability for variable services")

introduced a check into the efivarfs init code that aborts loading of the module if not all three variable runtime services (GetVariable, SetVariable and GetNextVariable) are supported. However, this results in efivarfs being unavailable entirely if only SetVariable support is missing, which is only needed if you want to make any modifications.

So let's relax this restriction, and only require the GetVariable services, but force efivarfs to be mounted read-only if SetVariable is unsupported.

Cc Ilias Apalodimas <[email protected]>
Fixes bf67fad19e493b ("efi: Use more granular check for availability for variable services")
---
 fs/efivarfs/super.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
fs/efivarfs/super.c +5 -1
index 12c66f5d92dd..c12608f0dcd9 100644
@@ -201,6 +201,9 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	sb->s_d_op		= &efivarfs_d_ops;
 	sb->s_time_gran         = 1;
 
+	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_SET_VARIABLE))
+		sb->s_flags |= SB_RDONLY;
+
 	inode = efivarfs_get_inode(sb, NULL, S_IFDIR | 0755, 0, true);
 	if (!inode)
 		return -ENOMEM;
@@ -252,7 +255,8 @@ static struct file_system_type efivarfs_type = {
 
 static __init int efivarfs_init(void)
 {
-	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES))
+	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE |
+				       EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME))
 		return -ENODEV;
 
 	if (!efivars_kobject())
Signature · 1 line
2.17.1