From patchwork Thu Apr 29 17:46:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Vincent_Stehl=C3=A9?= X-Patchwork-Id: 429267 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp1829033jao; Thu, 29 Apr 2021 11:12:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDdouIJmFJr+CaYi1xdV7Js3TMnf83k2vcqEG4K3WSwIZb7Azz5wA6+7jQS0EABd3Azgsg X-Received: by 2002:a17:906:3952:: with SMTP id g18mr1285633eje.104.1619719974945; Thu, 29 Apr 2021 11:12:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619719974; cv=none; d=google.com; s=arc-20160816; b=ebPJOZcVhFYMWjbz0AM5nINPphv+pQ0a9IPAloOEumW+X5m4C/vS0nXM3VgpaAQEqb YPcGX6doaYR6d4ZrqTH9EUPOqfzS8qCQxWah5t3kkC21F3hgJBm6GT7Taiy+QRuFwiE2 Vd6xIVvLLSXaNqtGgve4xI7K7uLdTwlyUhXPjtJAqVEvhLfs0aoafsbvaGcwrguH8PMc /LHrn7LWDch3Y9e2Vzg+XDdJDmxAxI/+3N1DnI0tBFF5xjBR1V/DFoKWPJ+ru/vrkKuf lUts5Q/xLp5j4pj5UM1hFgwFUWnSeK5Yr5YuMVGcM/J6Bt/228QKEXMALSksVqOb+/sH j7Eg== 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:message-id:date:subject:cc:to:from; bh=qA4tbdZ0vHFHaI51B9TJ7b+Iq7tETURQGMhzbjIEsY8=; b=oG81ZYJc3db51d134DbcYnlWKemqm47qGZjswmk35QB4tFfha88syKfnZnSRwmtT9H +Ef54NtcosAibBsfv4SKJxNevr34U8T7qnwFz21T/2FIeBApXLLW54st/Uf9Qzv7TjIg VafLvJ/2pVi6mrLMoPE/7KmMrfFjvwdN6QCD4qJfgj5XIESRmm8JGgYKoderUjSxEUD4 FvTd9U7EEzdssG75so4UD4eOsGwlC33f+ZXlCti0JVZjzl7Tbocc+QdFv6Mzb+22DZqI VW67yEOKH6dPT+x2L6g4dOMmoYI8w9d8LiUEfCMh1rU580A/6YxxXPQWOjkUP6+MvsLx LCyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id y6si3878964eda.58.2021.04.29.11.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Apr 2021 11:12:54 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5C43E82CE4; Thu, 29 Apr 2021 20:12:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F39F182CE3; Thu, 29 Apr 2021 20:12:49 +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=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id DF93082CE3 for ; Thu, 29 Apr 2021 20:12:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vincent.stehle@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F105931B; Thu, 29 Apr 2021 11:12:45 -0700 (PDT) Received: from localhost.localdomain (unknown [10.57.1.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1926D3F694; Thu, 29 Apr 2021 11:12:43 -0700 (PDT) From: =?utf-8?q?Vincent_Stehl=C3=A9?= To: u-boot@lists.denx.de Cc: =?utf-8?q?Vincent_Stehl=C3=A9?= , Grant Likely , Heinrich Schuchardt , Alexander Graf Subject: [PATCH] efi_loader: check query_variable_info attributes Date: Thu, 29 Apr 2021 19:46:50 +0200 Message-Id: <20210429174650.8983-1-vincent.stehle@arm.com> X-Mailer: git-send-email 2.30.2 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 QueryVariableInfo() must return EFI_INVALID_PARAMETER when an invalid combination of attribute bits is supplied. This fixes three SCT QueryVariableInfo_Conf failures. Signed-off-by: Vincent Stehlé Reviewed-by: Grant Likely Cc: Heinrich Schuchardt Cc: Alexander Graf Changes since v1: - Remove if/else and return directly --- lib/efi_loader/efi_var_common.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.30.2 diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c index b11ed91a74a..cbf8685fad5 100644 --- a/lib/efi_loader/efi_var_common.c +++ b/lib/efi_loader/efi_var_common.c @@ -160,6 +160,10 @@ efi_status_t EFIAPI efi_query_variable_info( EFI_ENTRY("%x %p %p %p", attributes, maximum_variable_storage_size, remaining_variable_storage_size, maximum_variable_size); + if (!attributes || ((attributes & EFI_VARIABLE_RUNTIME_ACCESS) && + !(attributes & EFI_VARIABLE_BOOTSERVICE_ACCESS))) + return EFI_EXIT(EFI_INVALID_PARAMETER); + ret = efi_query_variable_info_int(attributes, maximum_variable_storage_size, remaining_variable_storage_size,