Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp774932rwb; Mon, 26 Sep 2022 05:50:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VoA3sDelssgrk2nwZlwRUkYtIzDrSpab927xAjRs3SkRzCTKxa+F0kvOSQ4meDh8dgA5Y X-Received: by 2002:a63:1450:0:b0:439:3806:9b91 with SMTP id 16-20020a631450000000b0043938069b91mr19714315pgu.407.1664196605252; Mon, 26 Sep 2022 05:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664196605; cv=none; d=google.com; s=arc-20160816; b=pO2ogwvJX5YIwg2nUJcyBt+smvPoKVpFqdxljOmATLP5SfreIMpmduFiaf7y0b7WHW 7+VrWoSy+2uEk7LfOHA12C9+EBGMef3nmLp1/jkBWbdwQgstbfbGGvK7AsmAybKMATne 1oBF1krCnTSQE1jsJRe9QnCriMdoL4Tp5tZX4HnUq+zGzV9XQcrqGJ8Wro8WRURdvAga dBzgpxNJhKzfE713FLCyLTMgEJ2Cit3pXbgbZbE28t4/UJ9hoMdpezOcH9JALym8Zvfs La2OMxlrqJ6utob3+AGVJLEbPnQl7joz5mi9SSQZU08Ym0SIz5oDGbvQZYmPZnuubMu7 Kd9g== 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=1ki74ca1HKRX9O4RlIC/hiV+dGI5xk+QUuijeRm2tMg=; b=wCAPks0WSPfTCd2QzGlO+fH87UB8KzPMQD99ukhjWh4gVvAcYci5jj+HXSzmULc++T 2zPugej3n+6q+hILasCwc7hLgd6Crp15pxlzvlzH/KpBDdC1+SuvGBcgwUvbx23mdiFL hDwomqZVhIcWApp5bvGjkYag9kJ+GWgVq5pHSrB/13j4RlF9fENzHuHGOwin7IKgw25d rMlwh79Kex12KlgD2CBQGOIXTvTOU1KPaHqGmxpTFVqoxRmK8uVvyJoLCun23oatZBrP zo0GwZjbueNiHOgQxKWmcubSYH+Jzo8owpnF/K3a73AI0bhCEm6q5hhPH2GSv92cf/W9 XTlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lq4aNg5p; 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 s134-20020a632c8c000000b00438d54cf8c5si18722116pgs.759.2022.09.26.05.49.53; Mon, 26 Sep 2022 05:50:05 -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=Lq4aNg5p; 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 S237625AbiIZLND (ORCPT + 99 others); Mon, 26 Sep 2022 07:13:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237442AbiIZLLx (ORCPT ); Mon, 26 Sep 2022 07:11:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6425051A; Mon, 26 Sep 2022 03:35:42 -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 90A5EB802C7; Mon, 26 Sep 2022 10:35:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4623C433D6; Mon, 26 Sep 2022 10:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188540; bh=Qts+mTwxPMEZO9kijhoy/64pFEzmYfB6q0q5Kwgo2VU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lq4aNg5pOTY4/gOKg5VsiCvgzXo21toqPOLeWH8741kY11JHnQGE+uzn/Iep1rTYE Z2UVXgxcxv7n/68XeALxIIOy1rRSN87QJcWH2heC4HILn1I+qtAoAHWz0G0EcgtcbR kYmuKc6y1VxQstXS+YpSazqO+A5E/iQ5XLrJDZDs= 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.15 041/148] efi: libstub: check Shim mode using MokSBStateRT Date: Mon, 26 Sep 2022 12:11:15 +0200 Message-Id: <20220926100757.566743144@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100756.074519146@linuxfoundation.org> References: <20220926100756.074519146@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 @@ -14,7 +14,7 @@ /* 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"; static efi_status_t get_var(efi_char16_t *name, efi_guid_t *vendor, u32 *attr, unsigned long *data_size, void *data) @@ -43,8 +43,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, @@ -53,7 +53,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: