]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Mar 2024 14:48:41 +0000 (14:48 +0000)
commit71da10e633a96593cf59af3f322a9c49a22cb71e
tree877bd9a53d9e5f2278c1a9b1a64001419cb5c5de
parentf1fb745ee0a6fe43f1d84ec369c7e6af2310fda9
efivarfs: Request at most 512 bytes for variable names

commit f45812cc23fb74bef62d4eb8a69fe7218f4b9f2a upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/efivarfs/vars.c