[tip: efi/urgent] efivarfs: Replace invalid slashes with exclamation marks in dentries.

From: tip-bot2 for Michael Schaller
Date: Wed Sep 30 2020 - 01:27:55 EST


The following commit has been merged into the efi/urgent branch of tip:

Commit-ID: 336af6a4686d885a067ecea8c3c3dd129ba4fc75
Gitweb: https://git.kernel.org/tip/336af6a4686d885a067ecea8c3c3dd129ba4fc75
Author: Michael Schaller <misch@xxxxxxxxxx>
AuthorDate: Fri, 25 Sep 2020 09:45:02 +02:00
Committer: Ard Biesheuvel <ardb@xxxxxxxxxx>
CommitterDate: Fri, 25 Sep 2020 23:29:04 +02:00

efivarfs: Replace invalid slashes with exclamation marks in dentries.

Without this patch efivarfs_alloc_dentry creates dentries with slashes in
their name if the respective EFI variable has slashes in its name. This in
turn causes EIO on getdents64, which prevents a complete directory listing
of /sys/firmware/efi/efivars/.

This patch replaces the invalid shlashes with exclamation marks like
kobject_set_name_vargs does for /sys/firmware/efi/vars/ to have consistently
named dentries under /sys/firmware/efi/vars/ and /sys/firmware/efi/efivars/.

Signed-off-by: Michael Schaller <misch@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20200925074502.150448-1-misch@xxxxxxxxxx
Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
---
fs/efivarfs/super.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 28bb568..15880a6 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -141,6 +141,9 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,

name[len + EFI_VARIABLE_GUID_LEN+1] = '\0';

+ /* replace invalid slashes like kobject_set_name_vargs does for /sys/firmware/efi/vars. */
+ strreplace(name, '/', '!');
+
inode = efivarfs_get_inode(sb, d_inode(root), S_IFREG | 0644, 0,
is_removable);
if (!inode)