]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
efivarfs: Fix error on non-existent file
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Sun, 8 Dec 2024 18:34:13 +0000 (13:34 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Dec 2024 13:02:07 +0000 (14:02 +0100)
commitdedea26a149f7fa0612b87c2c3193e56bc12511d
tree9a548a01df711cce0e9a2d67f56065f3ed89b21e
parent065b3e27e45d77e088386dc07575357f8f60cc63
efivarfs: Fix error on non-existent file

commit 2ab0837cb91b7de507daa145d17b3b6b2efb3abf upstream.

When looking up a non-existent file, efivarfs returns -EINVAL if the
file does not conform to the NAME-GUID format and -ENOENT if it does.
This is caused by efivars_d_hash() returning -EINVAL if the name is not
formatted correctly.  This error is returned before simple_lookup()
returns a negative dentry, and is the error value that the user sees.

Fix by removing this check.  If the file does not exist, simple_lookup()
will return a negative dentry leading to -ENOENT and efivarfs_create()
already has a validity check before it creates an entry (and will
correctly return -EINVAL)

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: <stable@vger.kernel.org>
[ardb: make efivarfs_valid_name() static]
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/efivarfs/inode.c
fs/efivarfs/internal.h
fs/efivarfs/super.c