Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp32503pxb; Tue, 12 Apr 2022 16:01:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn0p31kpM4qyBQ7YZKF2i0qCsrlvIA5exjSThsPPQ94jxOIPFxM+J59ypkQIUA7TOzzD44 X-Received: by 2002:a63:d456:0:b0:399:4c5a:2682 with SMTP id i22-20020a63d456000000b003994c5a2682mr31893778pgj.573.1649804464556; Tue, 12 Apr 2022 16:01:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649804464; cv=none; d=google.com; s=arc-20160816; b=BglkoGvg8Pxrp9CmAgpG4q2WmI0D25r3CeJ0G8sL/tr60+GdhQ6dCFB41xPlE3WtTj ogorzg3TG17GQlzc4zKNe6FGt5lsyBRodBXL/dWiXTus8Fs/uLzI5CiOgDbTKkBHcJJM s0EIXjDQkfE/9oqwI0JpcPo/yy9FhYdK3mkgNbPZed/TKtpjok+uD/az+yK+twH5gwgG 8tEc4xMebCPMri2VPAbECAxAzBXQXFWCnajaAmtZeYc8asKwOZR+rsfQy2zkwdIiwB/s D+6mVnNSbfMz10cIuRHaluG24o6Nefu43PoDumTwadS/7HO0Mkp/3Mbx6yp8KW2AczH3 4dqQ== 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=9e1xb0EPoHabwwpt9vhlbN/ayU2q95JXJA3TPG/jueg=; b=AJZ7R1CsYNQ8gvGe/KIsk9FV8/HW9uvfTwi2jZGFRx88eC+SGV8GIhBZdNbsMluUel hhtddsk5SVvVLqu7/K1e/Tr+X6HGYDqmbncEsc2KUH5edwoDtc1Uh8p0fAqZTrTiohER Go0pv1fBuqZOSxGZUa/gfF7ST9j2KQkiPMukGoa4JOjbACP4uQxskK1m/dpBiWaFgDRH dmo9cctRiLDHoRi63QQdd+4ZgzsvkDB0yJTuJOQg5KBqSxRjtvWQ8e8gdwZwGD4peytB cB+3e2TgPDaM1mOI42bn3/abfgyQ3gZAjBmYYrZKifnwyNkm3RsBynS6lfC+/Qc4YExd kduw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sHuWzAhJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n9-20020a634d49000000b00381f044e11fsi3922052pgl.550.2022.04.12.16.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:01:04 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sHuWzAhJ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 25E9612A8E6; Tue, 12 Apr 2022 14:42:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351728AbiDLHSH (ORCPT + 99 others); Tue, 12 Apr 2022 03:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352140AbiDLHEz (ORCPT ); Tue, 12 Apr 2022 03:04:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5040D46B37; Mon, 11 Apr 2022 23:47:44 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 2A3F76103A; Tue, 12 Apr 2022 06:47:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3704BC385A6; Tue, 12 Apr 2022 06:47:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649746063; bh=GPMcE/Z5TPn8lD0AfTRMCJGO/tcYseOLuUzJh3fgWPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sHuWzAhJvtVUejlAeCWhcVp4oEMkeSWMA+u6qK5KNN0yH1ou9Ns4CDCKG5y6RBzah v27VNCYqjskC7zfddBSHtZ/WGB0grJnp+ZrmtzovyjOMyT8cPk/Cp6Hsjjb2tnKtkm Q+kYG7feYsfZiS4m29g00uD2xvIcHPHdC4arZD9o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Guilherme G. Piccoli" , Michael Kelley , Wei Liu , Sasha Levin Subject: [PATCH 5.15 148/277] Drivers: hv: vmbus: Fix potential crash on module unload Date: Tue, 12 Apr 2022 08:29:11 +0200 Message-Id: <20220412062946.319702271@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062942.022903016@linuxfoundation.org> References: <20220412062942.022903016@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Guilherme G. Piccoli [ Upstream commit 792f232d57ff28bbd5f9c4abe0466b23d5879dc8 ] The vmbus driver relies on the panic notifier infrastructure to perform some operations when a panic event is detected. Since vmbus can be built as module, it is required that the driver handles both registering and unregistering such panic notifier callback. After commit 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callback") though, the panic notifier registration is done unconditionally in the module initialization routine whereas the unregistering procedure is conditionally guarded and executes only if HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE capability is set. This patch fixes that by unconditionally unregistering the panic notifier in the module's exit routine as well. Fixes: 74347a99e73a ("x86/Hyper-V: Unload vmbus channel in hv panic callback") Signed-off-by: Guilherme G. Piccoli Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/20220315203535.682306-1-gpiccoli@igalia.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- drivers/hv/vmbus_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 44bd0b6ff505..a939ca1a8d54 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2776,10 +2776,15 @@ static void __exit vmbus_exit(void) if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) { kmsg_dump_unregister(&hv_kmsg_dumper); unregister_die_notifier(&hyperv_die_block); - atomic_notifier_chain_unregister(&panic_notifier_list, - &hyperv_panic_block); } + /* + * The panic notifier is always registered, hence we should + * also unconditionally unregister it here as well. + */ + atomic_notifier_chain_unregister(&panic_notifier_list, + &hyperv_panic_block); + free_page((unsigned long)hv_panic_page); unregister_sysctl_table(hv_ctl_table_hdr); hv_ctl_table_hdr = NULL; -- 2.35.1