Re: [PATCH] efivarfs: fix off-by-one in efivar_validate() variable name matching
From: Ard Biesheuvel
Date: Tue Nov 24 2026 - 05:29:11 EST
(cc Peter)
On Fri, 20 Nov 2026, at 09:15, Zhang Chujun wrote:
> From: zhangchujun <zhangchujun@xxxxxxxxxxxxxxxxxxxx>
>
> 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.
>
> Fixes: 630ba0cc7a6d ("efi: Fix out-of-bounds read in variable_matches()")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: zhangchujun <zhangchujun@xxxxxxxxxxxxxxxxxxxx>
>
> diff --git a/fs/efivarfs/vars.c b/fs/efivarfs/vars.c
> index 6833c3d24b54..9f18bf48615c 100644
> --- a/fs/efivarfs/vars.c
> +++ b/fs/efivarfs/vars.c
> @@ -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);
Queued as a fix, thanks.