Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp786262pxb; Tue, 12 Apr 2022 13:25:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZLvJYa+8ShULNR8ZcGwBiXy4HT/TkOcMniDFeIzCOQQscjWFz1q9uJhoScGqK51VLVHiL X-Received: by 2002:a17:90a:6382:b0:1ca:800e:1790 with SMTP id f2-20020a17090a638200b001ca800e1790mr6809415pjj.234.1649795136335; Tue, 12 Apr 2022 13:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649795136; cv=none; d=google.com; s=arc-20160816; b=mKVwytW3GzC/ILZ/u49lE/eYfoDN4MzDwnqRpDzRn1UnVYh458SObZrRC9QE+5DOy2 k/AMw0x6lhXCTQCwh/DHSb7e5zSJfy7Zx1dNP4XTufZ4fcn4LavZ8nL9X8GHScylamM3 lDlUZfVTuJdpD7UD0Ku+TQ9HB44fVL7FWOVtLjlcABPrxWiJ3qcScFznZIASvvLx/R8x f1nWhd4csvUY5EwlS09bMtu2A5ZokME1IZ3/Ej+axCzrmckONpvrmxjLTJWISgUFjRzI oUGGfDEGLa8oyRrmp95DQFJ2ls3tAZiXlgzXNy8zQimH1QSng+xhPCzKY3dib4eT5voH KD7A== 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=Fw0SfHhluv/LkouLT0i7q+sp5TVrh1XM1MHlIAUNH+A8HuoWpdQqz2TWgz6mpAHVru f1aXfHUSLpPKXjlLypMhHkvEo+pLkTYx63rfwIY9eaNTPFpkxClvcTLJ4Abbr/3TneRU rYuVM/QHRpAre5Tad51Bm3BLVZ8y9iXJrcQrirAT4Ry4/pkjbWu+RjhZHfKbyba7zuSL JAbKnLIXOXhhV6FYqEwG9fXPAX9u2WavvLtbPrQGK95xLB+0rFZU8L+MYIr5Sxcce/KG 89abv9HgZt5W7Q7+xFtVJs5rGI3WW/wmGOtBJViuDb2RfP0Kw5cRwnOzv4spL24Gb4v2 rqsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aZO3QMMV; 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 ay1-20020a1709028b8100b0015866d0a301si6417047plb.399.2022.04.12.13.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 13:25:36 -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=aZO3QMMV; 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 195759D0E4; Tue, 12 Apr 2022 13:04:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359068AbiDLIdI (ORCPT + 99 others); Tue, 12 Apr 2022 04:33:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353518AbiDLHZn (ORCPT ); Tue, 12 Apr 2022 03:25:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67346434B7; Tue, 12 Apr 2022 00:00:57 -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 11334B81B4D; Tue, 12 Apr 2022 07:00:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65183C385A1; Tue, 12 Apr 2022 07:00:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649746854; bh=GPMcE/Z5TPn8lD0AfTRMCJGO/tcYseOLuUzJh3fgWPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aZO3QMMV5fVUTS0T6Gz9Q/bsvhrc/JMsRmnkJmzqD52HCvkht2Qe5AD0nhJHtZaS5 5PSP8Ofqhoqroham33+9wOS1/7fbji+FukdRDLRTni7jtWHpZXgVieyeCv5zi5736T BOp5+aYGJifPQBNllWlUaX4V/VmWEhXxxPgo4E3c= 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.16 153/285] Drivers: hv: vmbus: Fix potential crash on module unload Date: Tue, 12 Apr 2022 08:30:10 +0200 Message-Id: <20220412062948.089098173@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062943.670770901@linuxfoundation.org> References: <20220412062943.670770901@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