Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16666C4363A for ; Thu, 29 Oct 2020 17:55:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADE0A2076E for ; Thu, 29 Oct 2020 17:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725876AbgJ2RzB (ORCPT ); Thu, 29 Oct 2020 13:55:01 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:37849 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725777AbgJ2RzA (ORCPT ); Thu, 29 Oct 2020 13:55:00 -0400 Received: from 2.general.dannf.us.vpn ([10.172.65.1] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kYC8Y-0003Pf-HJ; Thu, 29 Oct 2020 17:54:58 +0000 From: dann frazier To: stable@vger.kernel.org Cc: Michael Schaller , Ard Biesheuvel , Matthew Garrett , Jeremy Kerr , linux-efi@vger.kernel.org Subject: [PATCH 4.4-5.9] efivarfs: Replace invalid slashes with exclamation marks in dentries. Date: Thu, 29 Oct 2020 11:54:42 -0600 Message-Id: <20201029175442.564282-1-dann.frazier@canonical.com> X-Mailer: git-send-email 2.29.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org From: Michael Schaller commit 336af6a4686d885a067ecea8c3c3dd129ba4fc75 upstream 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 Link: https://lore.kernel.org/r/20200925074502.150448-1-misch@google.com Signed-off-by: Ard Biesheuvel --- This addresses an issue that breaks Ubuntu installs on platforms that have variable names as described above. One of our installers needs to sort the BootOrder to keep BootCurrent at the front, but this fails when the variable BootCurrent points at appears to not exist due to this issue. Ref: https://bugs.launchpad.net/bugs/1899993 fs/efivarfs/super.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c index 28bb5689333a..15880a68faad 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) -- 2.29.1