Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp681264rwj; Fri, 23 Dec 2022 06:51:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXvC+u+3OrwQmYiJFKqFSK0+pJ6CSzMpU6AAAV4fq4ti9tmZTBrtSoy5zmd24/Rxs4wQN/lO X-Received: by 2002:a17:906:5850:b0:843:c2fd:324f with SMTP id h16-20020a170906585000b00843c2fd324fmr5342313ejs.75.1671807080655; Fri, 23 Dec 2022 06:51:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671807080; cv=none; d=google.com; s=arc-20160816; b=VFZYpv6l+W51a5TlmNiSj6ijLl8kXQiVGWHvfq8ebsJaodyBYuKfJJSXjiNecaXg1E yOmDOQeZdAcw73dDOUqjoMJ7gkj99nz2UbFd/4Ud5cGGI9euArY6m6kY6pXOcaNPOm7t 6Qhw1+eo3D+1ntVLrXo4E8QixrONMBWeJV2sc9GWW2yNPFxWAXqwiY4niDFadriY4Bqy xjQbMldQeL5ebH7tsUAyaTez9Q2Kz3caDrzlNTy/oRmffj744d4/u0hREVPvFMUIsAYp MoOi2RatyQTqiCYq7H/6Gki1jB4zAJMptMF3iy+ZNAiVlCP/LmJTNOlLDeZ9W9xyZVsH f17Q== 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=a0jgK7d4C6/dIKjBWnKOuj/Wt0FyTYm4PBIEB6Cb8eg=; b=yzs9TgKXRNontzlHjgyh+sIjfdO2QweER/lIV5UHfsg3rA1IIJ7kbUbWcZuh7QyE6O JX/xwAv7wRddMdyvZ4VZLCVE48j1U85cgleahH9bQB7YlZdDcXaoBKs/o8fPvXRV6cLB eEAga8bLrRdZmVBALBKSSl7XxxK/e1fYLgA5C+YiVcBDf9xG+s6CTrIOt5oOUSowEqH3 495wAE1vUpAeo5pP4ldJtCBVWxs+0UC9RzsnE9P5ELeO3zUaJud8i1te0uV7xnfmJ+Lq gQwOKWD/9+izxYsjtmtgMNlbIH7BTuOGX4J6PLLRgP9yPbkCFz4ucJKnyyjwds3y0Ija 139w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JSfWpy9M; 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 qk34-20020a1709077fa200b008366ae33ecesi2823888ejc.171.2022.12.23.06.50.59; Fri, 23 Dec 2022 06:51:20 -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=JSfWpy9M; 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 S236252AbiLWOhz (ORCPT + 66 others); Fri, 23 Dec 2022 09:37:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230239AbiLWOhx (ORCPT ); Fri, 23 Dec 2022 09:37:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4CE237FA8; Fri, 23 Dec 2022 06:37:52 -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 66D12611DB; Fri, 23 Dec 2022 14:37:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB422C433F2; Fri, 23 Dec 2022 14:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671806271; bh=X3m6JwJmkeHyk0BNor7qqjk1g6puhJN41xsYyHkX7lE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JSfWpy9MdKCbP509p6W/5f5fDmk4LYq303A8u0NFc1DG3N18ETt9SGIBlbGtYwINd kTNNeuNoI2A6LZrRi1iAdOT5YzPKX9XSDL58MdAV7L85YLwjTB2V60rbPF/QyvgUaN c/OxBRbgUUzO/1xG7h4mEOvGlC9riOpi2AtroTy+uLvJurGf/JN123cIZkIgVOKe6B QqdnqRetx7Z6Amv0SpDh3sMfGpq71lzG1mgs1ZulQsU4ji4rZX/ShvRx6838pQYLcJ OZe3WoYPiRIN9lY45VDfk4Ao5/VtI0EnEr26xVlxv1hsyLxNh/SPRvIxzCrasz4tFf HgsttMM3VKOBA== Received: by mail-lj1-f182.google.com with SMTP id e13so2657143ljn.0; Fri, 23 Dec 2022 06:37:51 -0800 (PST) X-Gm-Message-State: AFqh2koMIgiyMa3A+hznBDiq7oEzF80B/2RdvS/Kf4wMSLvo3qt2kvin W5/51mri5sk/pZDMSt9aSgIRx5HRbo2CfQykzns= X-Received: by 2002:a2e:910b:0:b0:279:bbff:a928 with SMTP id m11-20020a2e910b000000b00279bbffa928mr420239ljg.415.1671806269834; Fri, 23 Dec 2022 06:37:49 -0800 (PST) MIME-Version: 1.0 References: <20221219091004.562-1-johan+linaro@kernel.org> In-Reply-To: <20221219091004.562-1-johan+linaro@kernel.org> From: Ard Biesheuvel Date: Fri, 23 Dec 2022 15:37:38 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] efi: fix NULL-deref in init error path To: Johan Hovold Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Li Heng Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 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 On Mon, 19 Dec 2022 at 10:10, Johan Hovold wrote: > > In case runtime services are not supported or have been disabled the > runtime services workqueue will never have been allocated. > > Do not try to destroy the workqueue unconditionally in the unlikely > event that EFI initialisation fails to avoid dereferencing a NULL > pointer. > > Fixes: 98086df8b70c ("efi: add missed destroy_workqueue when efisubsys_init fails") > Cc: stable@vger.kernel.org > Cc: Li Heng > Signed-off-by: Johan Hovold Thanks for the fix - I will queue it up after -rc1 > --- > drivers/firmware/efi/efi.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > index 09716eebe8ac..a2b0cbc8741c 100644 > --- a/drivers/firmware/efi/efi.c > +++ b/drivers/firmware/efi/efi.c > @@ -394,8 +394,8 @@ static int __init efisubsys_init(void) > efi_kobj = kobject_create_and_add("efi", firmware_kobj); > if (!efi_kobj) { > pr_err("efi: Firmware registration failed.\n"); > - destroy_workqueue(efi_rts_wq); > - return -ENOMEM; > + error = -ENOMEM; > + goto err_destroy_wq; > } > > if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE | > @@ -443,7 +443,10 @@ static int __init efisubsys_init(void) > err_put: > kobject_put(efi_kobj); > efi_kobj = NULL; > - destroy_workqueue(efi_rts_wq); > +err_destroy_wq: > + if (efi_rts_wq) > + destroy_workqueue(efi_rts_wq); > + > return error; > } > > -- > 2.37.4 >