Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1827370pxb; Fri, 18 Feb 2022 16:52:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqeR5swMSl211R2dooRU/nl0oFUKxM4WFo+FoYf4Bywikqd+DQj0HtDd5j4q0XAjbhibN2 X-Received: by 2002:a50:d088:0:b0:410:d12b:84e1 with SMTP id v8-20020a50d088000000b00410d12b84e1mr11047013edd.106.1645231974791; Fri, 18 Feb 2022 16:52:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645231974; cv=none; d=google.com; s=arc-20160816; b=Ml+Te5tTEzMB3zwtmWERWp5eHZjZ55wwpo4LFfqcEopuz5xaa3+jnoYbvNHp4WvJ7M 5yC9td0tcccdCNyfyeeWTcXwOg+b2SfR37DJsO88RfPT6QIPNLD+diRciJPogfo4o+fh Iu1KU14qReA2nclqHUtg+ZeuOG3Oh/x8zGdvOP8HVMAJrvwfPHqamAtPv7GxCikbUxKv K0yjg4DqmiAS9CF7+RfjgBbgb/6QhtES8w7F6UKrLktByEwtm+OV5AV3+G5w6Ciqk1/U nvzKBtsI00njwkffGcyg73KDq6gSQZPmwETYp2oYcNYqa9GVSqHekyjLlB6OdTB533nG cYMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=BfeJHpwWZN4j7Qew7H89EJDxUEjB/7YOK9JYO50YPvU=; b=UwtEyfLy01ouMYxS3Zyp+N7yf1HRFWz6pMKl7cjERFVUMet9h1s8HWHCNJkWClnojz HrfwJuONUmCq1kH2XqbkYSHi+vHX8638GuwIrlRRODs35QA+kTfuh2IvFgNZawZX5xGQ ROwAwFpUIOD3Rbom8KXwPQ6l0+mCThDp1l3h6BczAJ8olgoaq1mWJzbuZ2temtnLErRe 5mQ2gQ6MrqxWXIhz9sI+7qccIeG7Plu/Vt0E8B1NQiAUrqEHBu74NvrYAKv3AL2rxADv 5S3+lS1m4k4whIJ9WUO28TY2c4TotCbxi5IVkVBYBxnyAiIG4ChH+a5NZIznTJ4pGk/i jiJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qeWNMdsp; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e14si4672700eje.387.2022.02.18.16.52.31; Fri, 18 Feb 2022 16:52:54 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=qeWNMdsp; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236542AbiBRTMe (ORCPT + 99 others); Fri, 18 Feb 2022 14:12:34 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:53978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232499AbiBRTMd (ORCPT ); Fri, 18 Feb 2022 14:12:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20E204BFE4; Fri, 18 Feb 2022 11:12:16 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id AAD8C61A5C; Fri, 18 Feb 2022 19:12:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A450C340EF; Fri, 18 Feb 2022 19:12:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645211535; bh=0e4veZFcnn6yrRxE8i8DKuPwxKv+TS/DeK6cNKOXQ54=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=qeWNMdspHVNInULfaQuInCBT8d3TksMptTgCh7LpndB8SfHule0W3eou5k7pnWItm kyi/sch6LZgNEx5NoxbGNDhpg7HVOFJBQvvbfC+JaI1CYroZIo3yBiDAjef1t+gSN8 C2F2uR1Qm7ZivunyMbjdbl94yrer5ywR9dxC65CkMuqnluV5I4TlKUtewqNEBwXKHj 7n/HxeSsfPOvlnDysqaQElvrA8WvGCO+ng867YbTGQG7XoSmY7eoKABOkwbqd/Wi/C /yfPTfqhjSLZs1NpZyEVP4CTrpFD7GjZLbTYBkT3AWEeB7xQLMUt48R4SKZ1VkMlUf Ju916tD+LhMSg== Received: by mail-wr1-f44.google.com with SMTP id k1so16132029wrd.8; Fri, 18 Feb 2022 11:12:15 -0800 (PST) X-Gm-Message-State: AOAM533joUi99m6tHOwqyOjALj46j60P31MJHPAHcRJXN4axWxmrGOFG wzLK3VkYfZ8qaivQYkLmjZmJskpoZTgpc+GjHNc= X-Received: by 2002:a5d:6884:0:b0:1e4:ed7b:fd71 with SMTP id h4-20020a5d6884000000b001e4ed7bfd71mr7205218wru.550.1645211533454; Fri, 18 Feb 2022 11:12:13 -0800 (PST) MIME-Version: 1.0 References: <20220218180559.1432559-1-jannh@google.com> In-Reply-To: <20220218180559.1432559-1-jannh@google.com> From: Ard Biesheuvel Date: Fri, 18 Feb 2022 20:12:02 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] efivars: Respect "block" flag in efivar_entry_set_safe() To: Jann Horn Cc: linux-efi , Linux Kernel Mailing List , Kees Cook Content-Type: text/plain; charset="UTF-8" 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,T_SCC_BODY_TEXT_LINE 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 On Fri, 18 Feb 2022 at 19:06, Jann Horn wrote: > > When the "block" flag is false, the old code would sometimes still call > check_var_size(), which wrongly tells ->query_variable_store() that it can > block. > > As far as I can tell, this can't really materialize as a bug at the moment, > because ->query_variable_store only does something on X86 with generic EFI, > and in that configuration we always take the efivar_entry_set_nonblocking() > path. So I'm not marking this for stable backporting. > > Fixes: ca0e30dcaa53 ("efi: Add nonblocking option to efi_query_variable_store()") > Signed-off-by: Jann Horn Thanks Jann. I'll queue this up. > --- > > drivers/firmware/efi/vars.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c > index abdc8a6a3963..cae590bd08f2 100644 > --- a/drivers/firmware/efi/vars.c > +++ b/drivers/firmware/efi/vars.c > @@ -742,6 +742,7 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes, > { > const struct efivar_operations *ops; > efi_status_t status; > + unsigned long varsize; > > if (!__efivars) > return -EINVAL; > @@ -764,15 +765,17 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes, > return efivar_entry_set_nonblocking(name, vendor, attributes, > size, data); > > + varsize = size + ucs2_strsize(name, 1024); > if (!block) { > if (down_trylock(&efivars_lock)) > return -EBUSY; > + status = check_var_size_nonblocking(attributes, varsize); > } else { > if (down_interruptible(&efivars_lock)) > return -EINTR; > + status = check_var_size(attributes, varsize); > } > > - status = check_var_size(attributes, size + ucs2_strsize(name, 1024)); > if (status != EFI_SUCCESS) { > up(&efivars_lock); > return -ENOSPC; > > base-commit: 83e396641110663d3c7bb25b9bc0c6a750359ecf > -- > 2.35.1.473.g83b2b277ed-goog >