mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] efivarfs: fix off-by-one in efivar_validate() variable name matching
@ 2026-11-20  8:15 Zhang Chujun
  2026-11-24 10:28 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Chujun @ 2026-11-20  8:15 UTC (permalink / raw)
  To: Ard Biesheuvel, Jeremy Kerr
  Cc: linux-efi, linux-kernel, Kohei Enju, zhangchujun

From: zhangchujun <zhangchujun@cmss.chinamobile.com>

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@vger.kernel.org
Signed-off-by: zhangchujun <zhangchujun@cmss.chinamobile.com>

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);
-- 
2.50.1.windows.1




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24 10:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20  8:15 [PATCH] efivarfs: fix off-by-one in efivar_validate() variable name matching Zhang Chujun
2026-11-24 10:28 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®