From patchwork Tue May 14 04:57:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1099223 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="vfnUfEUU"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45356C4hs3z9sBp for ; Tue, 14 May 2019 14:57:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B3D5AC21C8B; Tue, 14 May 2019 04:57:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 54E23C21C8B; Tue, 14 May 2019 04:57:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id CC126C21C8B; Tue, 14 May 2019 04:57:44 +0000 (UTC) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by lists.denx.de (Postfix) with ESMTPS id 2F15CC21C38 for ; Tue, 14 May 2019 04:57:44 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id c6so8416003pfa.10 for ; Mon, 13 May 2019 21:57:44 -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:mime-version :content-transfer-encoding; bh=ID6tllgAyueL1xztwlE75dq63q6H8NnS73iGaj5na1c=; b=vfnUfEUUxqj9RiNWOfzFScxgAKRCkhECP5LGt8Uf5PhWMZrKfOKRfgkP3GM0ZRVgd+ ga8SROpHBM2HF3Xb8GfZmpHo4FqJ20szEbbZ8XdrBSXOIBO5cwxCW23rvgT0rWNIR5SN noxIW9I+mcZIwYM5jdYY94q8uItI8m+qB9txED2/KnmvwUt+El+0jxeAAxYmJvltki18 uIXJHIbdIEGVg732BJELsnMRwE8MG75LiU7b9EXorkFl3MR8dbQI4/gPgA1SzXF/mD4l HZ8Nafu/8qITlZ7gF0cpsVa+vdibCIbal3AGSCMZ6E5fG2A3osmDqpkfG34mWfysLVYB GMkg== 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:mime-version :content-transfer-encoding; bh=ID6tllgAyueL1xztwlE75dq63q6H8NnS73iGaj5na1c=; b=eSICdokUn7d6OW3lHmzs5IxbuJkRGypQwVO95DvqCjj0GXkb68wqfPV5n+voYgDZh6 f5OPaiL0oUOQRHsJ0JcSvI06fK1zGLmhDVn4d/SyHfTv8r8jhHMFQ2rg7lz6Ybu7Oq1P AQZcQSnnL9UsnYHgX7O9KN44qQydvfTr6bfJJFrrqDziEdYoQixQlVE2PB/Z2OWenSvP nHeMEwutkELdoQ/4jNM/zLw7SVw/sIdVNeb+8z1ts/S5vD0uenU6HKgjZGyk+VCAh+ut 4UizbRRIA43s32xqj9NpwNYJjvUJwxYio0JABXrjNjh2xPvO3mj48TmSDvX4VPP7HV8C Z37Q== X-Gm-Message-State: APjAAAW2vedLbpyD7g8YGV6/vzU/SBimYIWHKSIeBIt8naM/Hnnm7eVa afWzcVPMLU/7vnjlUt3Gshg2YQ== X-Google-Smtp-Source: APXvYqwC5lWU7uDhkcQy0P1FRcklhLggofArt3qQeLcc2iJB8f2j4axbnHzZsGWbqTmkKudqm7cnUQ== X-Received: by 2002:a63:6b06:: with SMTP id g6mr24756225pgc.346.1557809862177; Mon, 13 May 2019 21:57:42 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id q10sm16542516pgh.93.2019.05.13.21.57.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 21:57:41 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de Date: Tue, 14 May 2019 13:57:52 +0900 Message-Id: <20190514045752.10035-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] efi_loader: variable: attributes may not be changed if a variable exists X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" If a variable already exists, efi_set_variable() should not change the variable's attributes. This patch enforces it. Signed-off-by: AKASHI Takahiro Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_variable.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 37728c3c165d..c4f3a5d2743d 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -450,6 +450,15 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, ret = EFI_WRITE_PROTECTED; goto out; } + + /* + * attributes won't be changed + * TODO: take care of APPEND_WRITE once supported + */ + if (attr != attributes) { + ret = EFI_INVALID_PARAMETER; + goto out; + } } val = malloc(2 * data_size + strlen("{ro,run,boot}(blob)") + 1);