Add missing attributes to EFI variable attribute print out from sysfs
PATCH 1/1 Add missing attributes to EFI variable attribute print out from sysfs
Some of the EFI variable attributes are missing from print out from /sys/firmware/efi/vars/*/attributes. This patch adds those in.
--- drivers/firmware/efivars.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/firmware/efivars.c +10 -0
@@ -441,6 +441,16 @@ efivar_attr_read(struct efivar_entry *entry, char *buf) str +=sprintf (str,"EFI_VARIABLE_BOOTSERVICE_ACCESS\n" );if (var->Attributes &0x4 ) str +=sprintf (str,"EFI_VARIABLE_RUNTIME_ACCESS\n" ); +if (var->Attributes &0x8 ) + str +=sprintf (str,"EFI_VARIABLE_HARDWARE_ERROR_RECORD\n" ); +if (var->Attributes &0x10 ) + str +=sprintf (str, +"EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\n" ); +if (var->Attributes &0x20 ) + str +=sprintf (str, +"EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS\n" ); +if (var->Attributes &0x40 ) + str +=sprintf (str,"EFI_VARIABLE_APPEND_WRITE\n" );return str - buf; }
Signature · 5 lines
1.7.9.5 ================== Khalid Aziz [email protected]
Quoted 5 lines · Khalid Aziz
Some of the EFI variable attributes are missing from print out from
/sys/firmware/efi/vars/*/attributes. This patch adds those in.Signed-off-by Khalid Aziz <[email protected]>
Seems good to me.
Signature · 2 lines
Kees Cook Chrome OS Security
drivers/firmware/efivars.c efivar_attr_read(struct efivar_entry *entry, char *buf) · line 443
Quoted 2 lines · Khalid Aziz
drivers/firmware/efivars.c +0
-0if (var->Attributes &0x4 ) str +=sprintf (str,"EFI_VARIABLE_RUNTIME_ACCESS\n" );
I know you're just following the pattern of the existing code, but could you change these to be more like
if (var->Attributes & EFI_VARIABLE_RUNTIME_ACCESS)
while you're at it? I think that'd be a worthwhile cleanup.
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 10 lines · Matthew Garrett
Quoted 2 lines · Khalid Aziz
if (var->Attributes & 0x4) str += sprintf(str, "EFI_VARIABLE_RUNTIME_ACCESS\n");I know you're just following the pattern of the existing code, but could you change these to be more like
if (
var->Attributes&EFI_VARIABLE_RUNTIME_ACCESS)while you're at it? I think that'd be a worthwhile cleanup.
That is a good suggestion. I will make the changes and send out updated version.
Signature · 2 lines
Khalid Aziz [email protected]
Quoted 7 lines · Matthew Garrett
I know you're just following the pattern of the existing code, but could you change these to be more like
if (
var->Attributes&EFI_VARIABLE_RUNTIME_ACCESS)while you're at it? I think that'd be a worthwhile cleanup.
I just sent out an updated patch with this change. The constant names for EFI variable attribute are pretty darn long and cause line wrap fairly quickly. I would like to rename those constants from EFI_VARIABLE_* to EFI_VAR_* and possibly shorten the overall name as well:
EFI_VARIABLE_NON_VOLATILE -> EFI_VAR_NVEFI_VARIABLE_BOOTSERVICE_ACCESS -> EFI_VAR_BOOTEFI_VARIABLE_RUNTIME_ACCESS -> EFI_VAR_RUNTIMEEFI_VARIABLE_HARDWARE_ERROR_RECORD -> EFI_VAR_HW_ERROREFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS -> EFI_VAR_AUTH_WRITEEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS -> EFI_VAR_TIMED_AUTH_WRITEEFI_VARIABLE_APPEND_WRITE -> EFI_VAR_APPEND
Sounds reasonable?
Signature · 2 lines
Khalid Aziz [email protected]
Quoted 9 lines · Khalid Aziz
EFI_VARIABLE_NON_VOLATILE->EFI_VAR_NVEFI_VARIABLE_BOOTSERVICE_ACCESS->EFI_VAR_BOOTEFI_VARIABLE_RUNTIME_ACCESS->EFI_VAR_RUNTIMEEFI_VARIABLE_HARDWARE_ERROR_RECORD->EFI_VAR_HW_ERROREFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS->EFI_VAR_AUTH_WRITEEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS->EFI_VAR_TIMED_AUTH_WRITEEFI_VARIABLE_APPEND_WRITE->EFI_VAR_APPENDSounds reasonable?
Sounds great, but sadly they're exposed to userspace so changing them would be a problem. Adding aliases would be ugly but workable?
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 9 lines · Matthew Garrett
Quoted 8 lines · Khalid Aziz
EFI_VARIABLE_NON_VOLATILE->EFI_VAR_NVEFI_VARIABLE_BOOTSERVICE_ACCESS->EFI_VAR_BOOTEFI_VARIABLE_RUNTIME_ACCESS->EFI_VAR_RUNTIMEEFI_VARIABLE_HARDWARE_ERROR_RECORD->EFI_VAR_HW_ERROREFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS->EFI_VAR_AUTH_WRITEEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS->EFI_VAR_TIMED_AUTH_WRITEEFI_VARIABLE_APPEND_WRITE->EFI_VAR_APPEND
Quoted 4 lines
Quoted 1 line
Sounds reasonable?
Sounds great, but sadly they're exposed to userspace so changing them would be a problem. Adding aliases would be ugly but workable?
Ugly but practical. I agree with creating alias. I can work up a patch that creates the aliases in efi.h, and replaces all uses in kernel with shorter names. This does not change ABI or API, so existing userspace programs will continue to work.
Signature · 2 lines
Khalid Aziz [email protected]
A message that is not in the archive (sent off-list or not yet received): CAGTjWtA0LmQ-90zjYf0nho_LEra8nx32M1R7E6o=3S68UjfEHw@mail.gmail.com
Quoted 1 line · Mike Waychison
You can probably save the wrap by copying out
var->Attributesinto a local.
Yes, you are right. It will work in this case. I am considering the general case of very long name for a constant causing issues with line wrap in more complex code, or just plain being a pain to type such a long name (one of these constants is ~50 characters).
--
Khalid Aziz
[email protected]