efivarfs: fix off-by-one in efivar_validate() variable name matching
Subsystems (2)
PATCH 1/1 efivarfs: fix off-by-one in efivar_validate() variable name matching
From: zhangchujun <[email protected]>
efivar_validate() passes utf8_size + 1 to variable_matches(), including the terminating NUL in the name length. However, variable_matches() expects the number of non-NUL characters.
As a result, exact-name entries in variable_validate[] fail to match, causing some variables to use the wrong validator or bypass their intended validation.
fs/efivarfs/vars.c +1 -1
@@ -274,7 +274,7 @@ efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data,if (efi_guidcmp (vendor, variable_validate[i].vendor))continue ; -if (variable_matches (utf8_name, utf8_size+1 , name, &match)) { +if (variable_matches (utf8_name, utf8_size, name, &match)) {if (variable_validate[i].validate ==NULL )break ;kfree (utf8_name);
Signature · 1 line
2.50.1.windows.1
(cc Peter)
Quoted 27 lines · Zhang Chujun
From: zhangchujun <[email protected]>
efivar_validate()passesutf8_size+ 1 tovariable_matches(), including the terminating NUL in the name length. However,variable_matches()expects the number of non-NUL characters.As a result, exact-name entries in variable_validate[] fail to match, causing some variables to use the wrong validator or bypass their intended validation.
Fixes 630ba0cc7a6d ("efi: Fix out-of-bounds read in variable_matches()")Signed-off-by zhangchujun <[email protected]>fs/efivarfs/vars.c +1
-1@@ -274,7 +274,7 @@ efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data, if (efi_guidcmp(vendor, variable_validate[i].vendor)) continue; -if (variable_matches (utf8_name, utf8_size+1 , name, &match)) { +if (variable_matches (utf8_name, utf8_size, name, &match)) {if (variable_validate[i].validate ==NULL )break ;
Quoted 1 line
kfree(utf8_name);
Queued as a fix, thanks.