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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 912B5C433F5 for ; Sun, 12 Sep 2021 19:24:38 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 09D7E60F51 for ; Sun, 12 Sep 2021 19:24:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 09D7E60F51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F3F108392E; Sun, 12 Sep 2021 21:24:35 +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="ql+x08B2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E01883852; Sun, 12 Sep 2021 21:24:32 +0200 (CEST) Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) (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 BEFB58392E for ; Sun, 12 Sep 2021 21:24:28 +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=ilias.apalodimas@linaro.org Received: by mail-yb1-xb2f.google.com with SMTP id r4so15901213ybp.4 for ; Sun, 12 Sep 2021 12:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=C1U1ES484Ocmp1RNr4VB/aF0Md0QXeWxl2hsvXVBUbs=; b=ql+x08B2wWyqeB9AHw1/xQ4vXmoq1QtyBHBjiUrJ8Q9IXnqKvSMZDgMKN2nhHvraHa Jgvp6bRsfJHXGKfFyETJUE11/6/0N+95rifMa7rCEFCLvGyyaOLxCtAo0x7SHr1cNtof BpMe92X/Oft5eSGOPGUIOctOmB0j39J9kEGMmzFZTxZBY867elXgxTZj827GloD/FK4P IdIecCsvrpah66PEn9CzPaZHyH8VYQ+ajnuvERFa0hLKN74gGZjV/lSopXkAyYOy6Ks2 yqwO/P+XFDeYKvW9k5An8rm32wg32NQ9VmyDZw3Wp6U/5sO9zr9f8tjO68UyATc/RKzY kfxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=C1U1ES484Ocmp1RNr4VB/aF0Md0QXeWxl2hsvXVBUbs=; b=XGpF1/ZH0IbnUTwdvY9v9aMMRBu8CXv1inXPFebGaVUeplniI1twRqo00EayjCNF+6 XSQwpT7POuemziBn6AAb+cJaFjyF0V7bINJDpJzyIileUrCcbRKOgR19L6UHBnFogXMj Ef8QXvyiA6E0AOyv9uSWJ3WdjdFlj+vpgUxwGtGVPrRNyMFVBo9P9MaK1pzwe5RFBEtL YV0wSu6gLwHOOTiicZxxcwKqhVOsLYQhb34Gy3RNLG3+zZ7le2/liI1bv8cV7YvSMxXr qqMqvdv/A/18PPtoV0CISd8C5zadCnWyL4W1ibUTC1pQs+q/8Q09USIE2rklIb2URmBr 94eA== X-Gm-Message-State: AOAM533yz0Qj8ucBBzQ6iBzNjxY6O6egGcvj966+F4IZvGh9mRRxp+ib 2psL9XDZrC75KiBPNY4iahs8s9f6u50lFo/dFMM91A== X-Google-Smtp-Source: ABdhPJzlbUhmMgzj2v9icVEH562kxu/SL+EfG7JOqB2kyP9ZD/n/Ahpgnpw0rMccTynhj7ZkDUD9aMi8Y6bDieVVYDM= X-Received: by 2002:a25:2155:: with SMTP id h82mr10706880ybh.177.1631474667471; Sun, 12 Sep 2021 12:24:27 -0700 (PDT) MIME-Version: 1.0 References: <20210911072832.16991-1-xypron.glpk@gmx.de> <20210911072832.16991-4-xypron.glpk@gmx.de> In-Reply-To: From: Ilias Apalodimas Date: Sun, 12 Sep 2021 22:23:51 +0300 Message-ID: Subject: Re: [PATCH 3/4] efi_loader: simplify efi_sigstore_parse_sigdb() To: Heinrich Schuchardt Cc: U-Boot Mailing List , AKASHI Takahiro , Sughosh Ganu , Masahisa Kojima , Alexander Graf Content-Type: text/plain; charset="UTF-8" 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.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Heinrich [...] > >> - if (!u16_strcmp(name, L"PK") || !u16_strcmp(name, L"KEK")) { > >> - vendor = &efi_global_variable_guid; > >> - } else if (!u16_strcmp(name, L"db") || !u16_strcmp(name, L"dbx")) { > >> - vendor = &efi_guid_image_security_database; > >> - } else { > >> + vendor = efi_auth_var_get_guid(name); > >> + if (!vendor) { > >> EFI_PRINT("unknown signature database, %ls\n", name); > >> return NULL; > >> } > > > > efi_auth_var_get_guid() will return &efi_global_variable_guid if the > > GUID for the variable name isn't found. > > Hello Ilias, that is on purpose. In nevedit_efi we need a default GUID. > I want to reuse the same function there in future. > > Best regards Then I guess the check can go away ? > > Heinrich > > > > >> > >> - /* retrieve variable data */ > >> - db_size = 0; > >> - ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, NULL)); > >> - if (ret == EFI_NOT_FOUND) { > >> - EFI_PRINT("variable, %ls, not found\n", name); > >> - sigstore = calloc(sizeof(*sigstore), 1); > >> - return sigstore; > >> - } else if (ret != EFI_BUFFER_TOO_SMALL) { > >> - EFI_PRINT("Getting variable, %ls, failed\n", name); > >> - return NULL; > >> - } > >> - > >> - db = malloc(db_size); > >> + db = efi_get_var(name, vendor, &db_size); > >> if (!db) { > >> - EFI_PRINT("Out of memory\n"); > >> - return NULL; > >> - } > >> - > >> - ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, db)); > >> - if (ret != EFI_SUCCESS) { > >> - EFI_PRINT("Getting variable, %ls, failed\n", name); > >> - free(db); > >> - return NULL; > >> + EFI_PRINT("variable, %ls, not found\n", name); > >> + return calloc(sizeof(struct efi_signature_store), 1); Why? From the patch alone it's not clear why you want to allocate memory here instead of returning NULL. > >> } > >> > >> return efi_build_signature_store(db, db_size); > >> -- > >> 2.30.2 > >> Cheers /Ilias