Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4267FC7EE32 for ; Wed, 1 Mar 2023 16:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbjCAQd4 (ORCPT ); Wed, 1 Mar 2023 11:33:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbjCAQdb (ORCPT ); Wed, 1 Mar 2023 11:33:31 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D8F04BE81; Wed, 1 Mar 2023 08:32:38 -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 ams.source.kernel.org (Postfix) with ESMTPS id EF451B810D8; Wed, 1 Mar 2023 16:31:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94ED4C433EF; Wed, 1 Mar 2023 16:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677688298; bh=mnMAYSsjWi1Hs/zRjWoStNLegmaNMvUg17qvnW6xzrI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Sg1AWJanvPO7CJn77DvWu9IVfcHyCTxqaeXdgY3BszZ3/TuF7uDMlkSgaoiWQkj+P GQWHSVythlXVajgWxhohPX6pDkPZ8AW/5jeeJtRJrRhYbBEH7b4Qg+2lV+sNWjeVIf yG2kq/jpR1eAkHTa2AdJYnQWEXAy8lT4D4hS8CsefXWivhAR42y8QBqQw1+QSKZiKs OWzLHDemLorTEQE597TwQ9qdSVWnxLKz0qLJTuP+rlaFMwnKO2kAMVmX9bJLLTjjZg qhO8uRwhVvvgmy25iL6eFuY59sLF41ulU16oysC1Ob84RGIy0M5Jlfp1R3eaXbTEb2 f6TeXCruOSm8A== Received: by mail-lf1-f54.google.com with SMTP id r27so18381643lfe.10; Wed, 01 Mar 2023 08:31:38 -0800 (PST) X-Gm-Message-State: AO0yUKWu07m0UrVfgKlFUrzOVQsSbJ2lZvMi/CdZLuWDCh7JlF6+V/R1 8D5iSnmPPhwKC/yY68BdfYQFNWUB+D501hvBjoc= X-Google-Smtp-Source: AK7set9x/+TrvCUaV5YX0JqqeXk7N6EiVKgZr9nIwsnzUDvNXTafVn/ihTG4W3D/fgU9gLzbXY7C6NB3SZWolFQe00k= X-Received: by 2002:a19:760f:0:b0:4db:f0a:d574 with SMTP id c15-20020a19760f000000b004db0f0ad574mr2019756lff.7.1677688296590; Wed, 01 Mar 2023 08:31:36 -0800 (PST) MIME-Version: 1.0 References: <20230301162948.1302994-1-sashal@kernel.org> <20230301162948.1302994-2-sashal@kernel.org> In-Reply-To: <20230301162948.1302994-2-sashal@kernel.org> From: Ard Biesheuvel Date: Wed, 1 Mar 2023 17:31:25 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH AUTOSEL 5.15 2/6] efi: efivars: prevent double registration To: Sasha Levin Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Johan Hovold , linux-efi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 1 Mar 2023 at 17:29, Sasha Levin wrote: > > From: Johan Hovold > > [ Upstream commit 0217a40d7ba6e71d7f3422fbe89b436e8ee7ece7 ] > > Add the missing sanity check to efivars_register() so that it is no > longer possible to override an already registered set of efivar ops > (without first deregistering them). > > This can help debug initialisation ordering issues where drivers have so > far unknowingly been relying on overriding the generic ops. > > Signed-off-by: Johan Hovold > Signed-off-by: Ard Biesheuvel > Signed-off-by: Sasha Levin NAK this is not a bugfix. > --- > drivers/firmware/efi/vars.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c > index cae590bd08f27..871dee9343bfb 100644 > --- a/drivers/firmware/efi/vars.c > +++ b/drivers/firmware/efi/vars.c > @@ -1164,19 +1164,28 @@ int efivars_register(struct efivars *efivars, > const struct efivar_operations *ops, > struct kobject *kobject) > { > + int rv; > + > if (down_interruptible(&efivars_lock)) > return -EINTR; > > + if (__efivars) { > + pr_warn("efivars already registered\n"); > + rv = -EBUSY; > + goto out; > + } > + > efivars->ops = ops; > efivars->kobject = kobject; > > __efivars = efivars; > > pr_info("Registered efivars operations\n"); > - > + rv = 0; > +out: > up(&efivars_lock); > > - return 0; > + return rv; > } > EXPORT_SYMBOL_GPL(efivars_register); > > -- > 2.39.2 >