efivarfs: Request at most 512 bytes for variable names
authorTim Schumacher <timschumi@gmx.de>
Fri, 26 Jan 2024 16:25:23 +0000 (17:25 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Sun, 25 Feb 2024 08:42:24 +0000 (09:42 +0100)
commitf45812cc23fb74bef62d4eb8a69fe7218f4b9f2a
tree3ec560098f37a726a5d4c9642a21a0378c06154b
parentfccfa646ef3628097d59f7d9c1a3e84d4b6bb45e
efivarfs: Request at most 512 bytes for variable names

Work around a quirk in a few old (2011-ish) UEFI implementations, where
a call to `GetNextVariableName` with a buffer size larger than 512 bytes
will always return EFI_INVALID_PARAMETER.

There is some lore around EFI variable names being up to 1024 bytes in
size, but this has no basis in the UEFI specification, and the upper
bounds are typically platform specific, and apply to the entire variable
(name plus payload).

Given that Linux does not permit creating files with names longer than
NAME_MAX (255) bytes, 512 bytes (== 256 UTF-16 characters) is a
reasonable limit.

Cc: <stable@vger.kernel.org> # 6.1+
Signed-off-by: Tim Schumacher <timschumi@gmx.de>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
fs/efivarfs/vars.c