Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp825300rwb; Mon, 26 Sep 2022 06:23:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6euLlUN/6waD0ZZZ9b38EiyKnJYAAGbghwPmocQf/lOMdO68q+e0umiPDIilIbQ6EiEUIz X-Received: by 2002:aa7:cd57:0:b0:456:d566:3f3e with SMTP id v23-20020aa7cd57000000b00456d5663f3emr15675262edw.311.1664198607826; Mon, 26 Sep 2022 06:23:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198607; cv=none; d=google.com; s=arc-20160816; b=KYR9C7W+SI8m41fNQYEQKsO34SRGuBnQo6YYv6DIJIV6bpeTtpa59apq5S1K1drB8X P+aa1iJhJ4NaM1XhEk6sHlPMJwtLo+a52DU0fve27HE54SYmtBNvMRP3Sce4iNirBsrZ 4UKkatE4XY0uDGyIdl6biffDUg3j25uFStpTIDZwxMkl+PfjiKcYIR2/aAGFQ+n4+c/R lOuq7ZNPdTdSpA+jVlL79FRTQfGWdTU9tpVEdXeqVG4bTR5jMq9aezS7heR/YeCVwWdu MhQ0Bnr3x2A1sOTTOIObN9kcxro/fOOjSnupne5OKxDb6VUg/6XJxuqb07BHLeT9Us0p bs1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jCrkpbQ1i0N6nAhZ6u8rpKC8m4t/nCNJXuJXshlT5JQ=; b=KHhBZFiCj53NYcsYgO77SMM/sZJ8FtEGiitIPu9S6FtsVw8AZfhxofsMKO/lxFW+8I SqKFdQMgCMcmYh2ADOBiUsXqMhwGPQkOuG2I22cmiQOI8ylWoUUeAPYaCau49USlzbI4 Jf1Ut3BGZMYFcQU6+tWH0XWLEno/Xje62p4suY7QbDzlcTM9FwgiBEsP/9RTevi3flQK DxoUXicMxq/BAKgGAh9diJnGwXDOP/SVOyuUMk2lZN2CkvXrKzJCStHD0HSIWkT+fboS stHTYL/hfmPhzDvpvSiTotB0sqAGI3e+VmnL1Eau9YFYzJ7dgS9+wsNb2hkSaI1N8LT2 NwpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kiXMl7ih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc3-20020a1709078a0300b00781599eb7e4si580071ejc.753.2022.09.26.06.23.02; Mon, 26 Sep 2022 06:23:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kiXMl7ih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233469AbiIZKoy (ORCPT + 99 others); Mon, 26 Sep 2022 06:44:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236284AbiIZKmc (ORCPT ); Mon, 26 Sep 2022 06:42:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 496274D4E1; Mon, 26 Sep 2022 03:24:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EBD6AB80926; Mon, 26 Sep 2022 10:23:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59D28C43149; Mon, 26 Sep 2022 10:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187804; bh=hHUaDJrxc6E0aVhxiuBcXlPxNUtmBzy1sqbl3JBWaKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kiXMl7ihjiKplaf9jiCV38tym7DSwdAdbbZecDsIeGvfi7XDGFw69/dHlgDs4mNUp eSC3PzYNN+alTJsI0bVk3VSWnZ6QmXivPudtriS6FO5FES9e6VLDmidqC7SVCloT8N QIFp8FQIjzpo7KinGtzQ4vQD5C0DW5Pv0IZJnPZc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Ilias Apalodimas , Peter Jones Subject: [PATCH 5.4 064/120] efi: libstub: check Shim mode using MokSBStateRT Date: Mon, 26 Sep 2022 12:11:37 +0200 Message-Id: <20220926100753.312509950@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100750.519221159@linuxfoundation.org> References: <20220926100750.519221159@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel commit 5f56a74cc0a6d9b9f8ba89cea29cd7c4774cb2b1 upstream. We currently check the MokSBState variable to decide whether we should treat UEFI secure boot as being disabled, even if the firmware thinks otherwise. This is used by shim to indicate that it is not checking signatures on boot images. In the kernel, we use this to relax lockdown policies. However, in cases where shim is not even being used, we don't want this variable to interfere with lockdown, given that the variable may be non-volatile and therefore persist across a reboot. This means setting it once will persistently disable lockdown checks on a given system. So switch to the mirrored version of this variable, called MokSBStateRT, which is supposed to be volatile, and this is something we can check. Cc: # v4.19+ Signed-off-by: Ard Biesheuvel Reviewed-by: Ilias Apalodimas Reviewed-by: Peter Jones Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/libstub/secureboot.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/firmware/efi/libstub/secureboot.c +++ b/drivers/firmware/efi/libstub/secureboot.c @@ -19,7 +19,7 @@ static const efi_char16_t efi_SetupMode_ /* SHIM variables */ static const efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID; -static const efi_char16_t shim_MokSBState_name[] = L"MokSBState"; +static const efi_char16_t shim_MokSBState_name[] = L"MokSBStateRT"; #define get_efi_var(name, vendor, ...) \ efi_call_runtime(get_variable, \ @@ -58,8 +58,8 @@ enum efi_secureboot_mode efi_get_secureb /* * See if a user has put the shim into insecure mode. If so, and if the - * variable doesn't have the runtime attribute set, we might as well - * honor that. + * variable doesn't have the non-volatile attribute set, we might as + * well honor that. */ size = sizeof(moksbstate); status = get_efi_var(shim_MokSBState_name, &shim_guid, @@ -68,7 +68,7 @@ enum efi_secureboot_mode efi_get_secureb /* If it fails, we don't care why. Default to secure */ if (status != EFI_SUCCESS) goto secure_boot_enabled; - if (!(attr & EFI_VARIABLE_RUNTIME_ACCESS) && moksbstate == 1) + if (!(attr & EFI_VARIABLE_NON_VOLATILE) && moksbstate == 1) return efi_secureboot_mode_disabled; secure_boot_enabled: