From patchwork Thu Jun 3 02:17:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 453211 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp1091858jao; Wed, 2 Jun 2021 19:18:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHjWJ1ufkLIFH6qLqbrT0Cxx3H4bsl6b3MHtRGov37QHPltDR7FJMOIh0sjxMzArg3bzoO X-Received: by 2002:aa7:c7cc:: with SMTP id o12mr41938912eds.291.1622686689504; Wed, 02 Jun 2021 19:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622686689; cv=none; d=google.com; s=arc-20160816; b=SiEt/vlf3qEXkiZx4qNsXd97RyaH4Vw9SCU9SiSkJHwGDW1wjSVpHvzpCzBJeXsRp5 4Wkfn8Itc6UxBA3+rnabxr+PbXMKBi0z7qVi3KL/MwGQ/ZZRFtzMvmdMuWeAIAg/WdWi 6jAbzLVJkJxCn8OR983l2xolrD6kQ3PT8mGLcmCpIQ67rB6zx+0LsnE7A+lvhYpRp7MI vemsGLmhUj7TzVrMAU9xRsxjCc+EYpW/pI/IyCsaHQtHi/6ycyCbnNqJiuWXUpQ+Ty51 s3iBiRZ3pXqYXqH8fcVBNio9+7TaB6KvOGDrU4jERRM0/9E/6gwRRSPLvXFpR1PJN0jV /AtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:message-id:date:subject:cc:to:from :dkim-signature; bh=k+ALdPQaSQs38Qx4jNcs76yJLYC/lks840M8CKNJboo=; b=IJ56w3WlLCwpzHMiqt2QltDu1rK/3BkaMMFKaVPxCAxU1F0qkhNT5LVAssBkb1TWLR oPApxMDlUIHqExxUQemlXr6N/IXhMu7570PrRO8l7zXsezb7hJYfOETPrvh9XkbdlRUU 6gnvmjJfom3ntvYqHtfsaYc9nT7k5TR6LlgV+XSerzK3uO0IBi0m+ZusFRmBbSCNXVhn eD0JLtIQuM4ve+37rdKHSMf3rWAF4A62KJsOJgnaef6SULJG0bOvj7HBKlUfvrK6f097 7Z1qRWL4tHICRY4RH/1zBf1y4UDnOINUNInZ9eIa6QNCOD0PmwXFH71M3/9OPg6lnGHy SztA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pEOt/1iN"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id t21si1081701edd.145.2021.06.02.19.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 19:18:09 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pEOt/1iN"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3FA2B82AC3; Thu, 3 Jun 2021 04:18:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pEOt/1iN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 332DE82AF6; Thu, 3 Jun 2021 04:18:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 95C5B82052 for ; Thu, 3 Jun 2021 04:18:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pj1-x1029.google.com with SMTP id k22-20020a17090aef16b0290163512accedso2591097pjz.0 for ; Wed, 02 Jun 2021 19:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:user-agent:mime-version :content-transfer-encoding; bh=k+ALdPQaSQs38Qx4jNcs76yJLYC/lks840M8CKNJboo=; b=pEOt/1iN5ZUjs6MHRrtJWgUArUkpopM9ES88jrCMCIsPEltzLgqIauE7tkaC9sbd3/ PED/qMqpMzntxrtZDsHavRSiwggnHVvmScdz0qeHZorYEcoZuQK2E5ZZx9mn7liNLZvN YBgqvweb3rhBvcymOIKoJ4f99mJh+ib0sbV4nDm/hVjORqrHtmKzOjrN8hDlOkh0HAft Kbjcx1Edr3QOKDdILPHokjszCBJPpgCmtpuc7g1yb4xr+flURyWcZJtE5IwvqQv8WNMT F0PJh3E4YCfLf8r1RtfIaumSgaoTgBQrVbNibV7onDddwPbF48DLNtqebEExstWWLRT0 in3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :mime-version:content-transfer-encoding; bh=k+ALdPQaSQs38Qx4jNcs76yJLYC/lks840M8CKNJboo=; b=Oc7Ycje1Ngm1xG8HKCbXana2ElzTrXfWf1tvBf3OO47fLIuxla6jkRiilhIU+8apFu uZUy0+Lb9xIJoMRSLIHvzQ6y5QK6b+1QGjBIE6HhsFqJK9gq9EjdXTjocOjFfDD9LPgN cdUEgn6gcqgLsUKUDaszbDLzHRXtJyPpJTqoR8gEuhAxNHMFgH+HizCy8XLUER/4IGbQ WmeRFewAozITKLGohZ3Bs2W56J0X8PBuSeE2jgLwb1SKyr4y4MYSJtS0jx9HUl3TalQa /dsX3+pLhbxV1v4e9mU2juakSU/sX1nsqBXEOFn8LlvZ0CxmWhWyQ7ii9mF0BquNhzL5 1gHg== X-Gm-Message-State: AOAM532C7RLU4JcYKTJqEUp3m7Frnbst0wQ0O6m5YUsOPwEIEJhoL/nA JzAKnrY6v9F7MvEwkF3oAtH9qw== X-Received: by 2002:a17:90a:5990:: with SMTP id l16mr8803286pji.175.1622686679788; Wed, 02 Jun 2021 19:17:59 -0700 (PDT) Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp. [210.141.244.193]) by smtp.gmail.com with ESMTPSA id c11sm560751pjr.32.2021.06.02.19.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Jun 2021 19:17:59 -0700 (PDT) From: Masami Hiramatsu To: Heinrich Schuchardt Cc: Kazuhiko Sakamoto , Alexander Graf , Masami Hiramatsu , Jesper Schmitz Mouridsen , Simon Glass , u-boot@lists.denx.de Subject: [PATCH] efi: Restrict the simple file system protocol to support only FAT Date: Thu, 3 Jun 2021 11:17:56 +0900 Message-Id: <162268667641.382839.15360535926598237804.stgit@localhost> X-Mailer: git-send-email 2.25.1 User-Agent: StGit/0.19 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean Because UEFI specification v2.9, 13.3 File System Format said "The file system supported by the Extensible Firmware Interface is based on the FAT file system.", the simple file system protocol might be better to support only FAT filesystem. There must be no problem from UEFI application to access only FAT because ESP must be formatted by FAT32 and the removable media is FAT12 or FAT16, according to the UEFI spec. Reported-by: Kazuhiko Sakamoto Signed-off-by: Masami Hiramatsu --- lib/efi_loader/efi_disk.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c index 307d5d759b..f69ae6587f 100644 --- a/lib/efi_loader/efi_disk.c +++ b/lib/efi_loader/efi_disk.c @@ -318,19 +318,25 @@ efi_fs_from_path(struct efi_device_path *full_path) } /** - * efi_fs_exists() - check if a partition bears a file system + * efi_supported_fs_exists() - check if a partition bears a supported file system * * @desc: block device descriptor * @part: partition number - * Return: 1 if a file system exists on the partition + * Return: 1 if a supported file system exists on the partition * 0 otherwise */ -static int efi_fs_exists(struct blk_desc *desc, int part) +static int efi_supported_fs_exists(struct blk_desc *desc, int part) { if (fs_set_blk_dev_with_part(desc, part)) return 0; - if (fs_get_type() == FS_TYPE_ANY) + /* + * Because UEFI specification v2.9, 13.3 File System Format said + * "The file system supported by the Extensible Firmware Interface + * is based on the FAT file system.", the simple file system protocol + * should support only FAT filesystem. + */ + if (fs_get_type() != FS_TYPE_FAT) return 0; fs_close(); @@ -428,10 +434,10 @@ static efi_status_t efi_disk_add_dev( /* * On partitions or whole disks without partitions install the - * simple file system protocol if a file system is available. + * simple file system protocol if a supported file system exists. */ if ((part || desc->part_type == PART_TYPE_UNKNOWN) && - efi_fs_exists(desc, part)) { + efi_supported_fs_exists(desc, part)) { diskobj->volume = efi_simple_file_system(desc, part, diskobj->dp); ret = efi_add_protocol(&diskobj->header,