From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E5D4AC433EF for ; Tue, 8 Mar 2022 00:50:22 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 847F3815D1; Tue, 8 Mar 2022 01:50:19 +0100 (CET) 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="pbcOseo2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BA21D817D8; Tue, 8 Mar 2022 01:50:16 +0100 (CET) Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) (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 BA78F811A6 for ; Tue, 8 Mar 2022 01:50:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1030.google.com with SMTP id m11-20020a17090a7f8b00b001beef6143a8so845684pjl.4 for ; Mon, 07 Mar 2022 16:50:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=u40Mh+4ckVMvkuhEeEQt37Y/kmNwbfzVrrAdKDBqito=; b=pbcOseo2IMwJPKj9bC09eE40kgI0g6r8b/UYoCEYI2aj2uteXC+WYR99inzBVyRHYG by36KeB/SGS9U9r8rvMtRzCI0k+2cd/ZiblMJU58erawCTZyUKUyc0u4k7d4R0QZdXNj iLZRsY9cbCytBMqGog36rlg9BoJb26l446SfGFMgpdjKcpcIGtK462lUI1h3m3I/DlGg p9WKo8AEueOsqOnENQ73/GtN4atBGFqknxpPUs6LFSCM30txoJKyAZ8HABKS/yTDDzst sGO5OtGlFPk5cc0TAM6z7hvsrgryJBjxC3LAn/50DP41oshJkEgbVcDmZKq5hXzzujbK orzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=u40Mh+4ckVMvkuhEeEQt37Y/kmNwbfzVrrAdKDBqito=; b=7ISF2wsU6HcauWzYC2W7NEHMwM/VF9/ZZuuaJYpOeWaHxNBYxPO3yMUTS4A4uxrh38 Qszo+nAkWwO0D+I0p0A8Wl0iOxuLt9nlunakyWvLselUhGfW2FUYgNcyEcrsw5OgCcpF ziHK+eW/RgkSp/oGXruyheX9T7cgrVrAHLG2KtOho/P2cCQux+CiRKZAzccgeDDTae7I DxniB9iBQNWWecJ1JDI+UYVxac9w00LyZIZmHmMd4o6T4wN6lOpW9/YUpNUm6Y/4EZz5 XCCCgdh5XhfZqVmj4T3jbnLNuk+FzNAhLqGbERYacyiqMnALOL88Kbv9eO71J+D5OITg hYwQ== X-Gm-Message-State: AOAM5313XQqzJvwIyjxBGYhYl0mQedB1u1FTyAxYP/HAuFOW4BbwU0we cmjakvfvo/DyqUcagpiUrSRTeA== X-Google-Smtp-Source: ABdhPJzQJpTxsZAWplpT9FSSiRXfGwRZ+5z6WvoGNFVIUDwxK40d6RDLfcJfQNhoAVTF+kqqRRBsYw== X-Received: by 2002:a17:90a:da02:b0:1bf:3919:f2a with SMTP id e2-20020a17090ada0200b001bf39190f2amr1821156pjv.208.1646700609959; Mon, 07 Mar 2022 16:50:09 -0800 (PST) Received: from laputa ([2400:4050:c3e1:100:b94a:f47a:3d51:185c]) by smtp.gmail.com with ESMTPSA id o15-20020a17090a168f00b001bf66741097sm546377pja.16.2022.03.07.16.50.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 16:50:09 -0800 (PST) Date: Tue, 8 Mar 2022 09:50:06 +0900 From: AKASHI Takahiro To: Heinrich Schuchardt Cc: u-boot@lists.denx.de, Ilias Apalodimas Subject: Re: [PATCH 1/1] efi_loader: remove efi_disk_is_system_part() Message-ID: <20220308005006.GB60846@laputa> Mail-Followup-To: AKASHI Takahiro , Heinrich Schuchardt , u-boot@lists.denx.de, Ilias Apalodimas References: <20220304235100.43127-1-heinrich.schuchardt@canonical.com> <20220305010305.GA6345@laputa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean On Sat, Mar 05, 2022 at 10:37:15AM +0100, Heinrich Schuchardt wrote: > > > On 3/5/22 02:03, AKASHI Takahiro wrote: > > Heinrich, > > > > On Sat, Mar 05, 2022 at 12:51:00AM +0100, Heinrich Schuchardt wrote: > > > The block IO protocol may be installed on any handle. We should make > > > no assumption about the structure the handle points to. > > > > > > efi_disk_is_system_part() makes an illegal widening cast from a handle > > > to a struct efi_disk_obj. Remove the function. > > > > NAK. > > If this is a problem, please fix the function rather than remove it. > > The first priority is that the code cannot crash. Keeping the current > implementation is not an option. > > As you introduced the problematic code I would appreciate your contribution > to the solution. > > The UEFI specification requires to find the ESP on the device of the active > boot partition. But this is not what efi_disk_is_system_part() ever did. It > only checked if the active boot option pointed to a file on an ESP. > > IsEfiSysPartitionDevicePath() in EDK II indentifies an ESP by either a > protocol using the EFI system partition GUID or a GPT HD() device path node > with the same GUID. I think just using the protocol should be good enough. You seem to already know the solution. Why not fix the problem by yourself? -Takahiro Akashi > Best regards > > Heinrich > > > > > > As side effect capsules might be read from non-ESP partitions. > > > > UEFI specification requires that capsules be loaded from ESP. > > > > -Takahiro Akashi > > > > > > > > Fixes: Fixes: 41fd506842c2 ("efi_loader: disk: add efi_disk_is_system_part()") > > > Signed-off-by: Heinrich Schuchardt > > > --- > > > include/efi_loader.h | 2 -- > > > lib/efi_loader/efi_capsule.c | 4 +++- > > > lib/efi_loader/efi_disk.c | 29 ----------------------------- > > > 3 files changed, 3 insertions(+), 32 deletions(-) > > > > > > diff --git a/include/efi_loader.h b/include/efi_loader.h > > > index e390d323a9..5ac736ebce 100644 > > > --- a/include/efi_loader.h > > > +++ b/include/efi_loader.h > > > @@ -539,8 +539,6 @@ efi_status_t tcg2_measure_pe_image(void *efi, u64 efi_size, > > > int efi_disk_create_partitions(efi_handle_t parent, struct blk_desc *desc, > > > const char *if_typename, int diskid, > > > const char *pdevname); > > > -/* Check if it is EFI system partition */ > > > -bool efi_disk_is_system_part(efi_handle_t handle); > > > /* Called by bootefi to make GOP (graphical) interface available */ > > > efi_status_t efi_gop_register(void); > > > /* Called by bootefi to make the network interface available */ > > > diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c > > > index 613b531b82..2e7474a5d0 100644 > > > --- a/lib/efi_loader/efi_capsule.c > > > +++ b/lib/efi_loader/efi_capsule.c > > > @@ -684,7 +684,9 @@ static bool device_is_present_and_system_part(struct efi_device_path *dp) > > > if (!handle) > > > return false; > > > - return efi_disk_is_system_part(handle); > > > + /* TODO: add system partition check */ > > > + > > > + return true; > > > } > > > /** > > > diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c > > > index 45127d1768..97223537a1 100644 > > > --- a/lib/efi_loader/efi_disk.c > > > +++ b/lib/efi_loader/efi_disk.c > > > @@ -587,32 +587,3 @@ efi_status_t efi_disk_register(void) > > > return EFI_SUCCESS; > > > } > > > - > > > -/** > > > - * efi_disk_is_system_part() - check if handle refers to an EFI system partition > > > - * > > > - * @handle: handle of partition > > > - * > > > - * Return: true if handle refers to an EFI system partition > > > - */ > > > -bool efi_disk_is_system_part(efi_handle_t handle) > > > -{ > > > - struct efi_handler *handler; > > > - struct efi_disk_obj *diskobj; > > > - struct disk_partition info; > > > - efi_status_t ret; > > > - int r; > > > - > > > - /* check if this is a block device */ > > > - ret = efi_search_protocol(handle, &efi_block_io_guid, &handler); > > > - if (ret != EFI_SUCCESS) > > > - return false; > > > - > > > - diskobj = container_of(handle, struct efi_disk_obj, header); > > > - > > > - r = part_get_info(diskobj->desc, diskobj->part, &info); > > > - if (r) > > > - return false; > > > - > > > - return !!(info.bootable & PART_EFI_SYSTEM_PARTITION); > > > -} > > > -- > > > 2.34.1 > > >