Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp49878lfv; Tue, 12 Apr 2022 16:51:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2/Pv9vRWR9vSx2bBhx4zkqyY6tG0RroI4Tyv2ahCLgb6XXGEHR9bt93oFfzfimya/HVTp X-Received: by 2002:a17:90b:3a82:b0:1cb:9ba8:56a5 with SMTP id om2-20020a17090b3a8200b001cb9ba856a5mr7741306pjb.16.1649807506875; Tue, 12 Apr 2022 16:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649807506; cv=none; d=google.com; s=arc-20160816; b=MWIUMV7//vwL9DS19Vq/XX8/3YhXzluXJ1biVbwQ+3l3+cl8QuyL3A91BhIyoo/nwf 3+igGy3muatLSc45ogmTAea/lqtWswVSyEPWpBfPJ1V+LQfgN4rzaLO2vLcH/WQcbJIv fvMdIA6SYwrXhYTovzd4aAi3ckHStGITet5RDctM7W9C2E+t8RtvjQceaNuCrJv/bxpX uWus+KgrrHl2S0/RrC32oMT00Mfdb3Y+rNn5rSGvTtipiTM4FUULghM0l0rRGJZ1/w3L fLnRjVMmWjm74OFzi6d4oX/MSglo0bPga4N7r7Or3bwJF2RI3du1XHacJBoWImi18ohJ jnfA== 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=0Bl7WlhTWNPgD0bFo+Lu9vmYn2OzetVaYQR+NfZRCdU=; b=aHhf85FMYLmPiLEeqwHRyf/5R7H6S16iFbGAeYLmx+8nmyP9ZBIxLH/60njWIyrS+2 pfXb8/XA5yTbS2PLR0KbFh/MzHtQhHNSxHOMMZPWsUrPqSNBr2S93lKGJvmJ73KBDYFQ otVflzR1tKfkg4zHRnKGyHKzr9aKHVW0kL5JVrtXH5Vb5lLMLF1VLIW4i5wvqfbHjHFv 3gQ1LsM2cH1L2iHSxw8CiXXHHLIeys2Dw5RZym6p7Vq3z7ovA7G2hTCdtrhBxDRI/XVT TMk5dj94wwOJJbrC8z/Vziv/hIf85BW+51SCQLM9ENeYrFAKcEIOUfjc6opmTuEcwgMw 6gag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rILycL4y; 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 r75-20020a632b4e000000b00398df5b29a7si3331615pgr.878.2022.04.12.16.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:51:46 -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=rILycL4y; 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 0708A1E7443; Tue, 12 Apr 2022 14:45:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350903AbiDLGsR (ORCPT + 99 others); Tue, 12 Apr 2022 02:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351128AbiDLGoE (ORCPT ); Tue, 12 Apr 2022 02:44:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 147E5396A2; Mon, 11 Apr 2022 23:37:28 -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 743DD618FF; Tue, 12 Apr 2022 06:37:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86B0DC385A1; Tue, 12 Apr 2022 06:37:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649745447; bh=11xosoxBbwNZ3oww6FL7EDRNJy+45l+sLxuj6BTSsRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rILycL4yoO5mDcrBkKsTsRx6ac0LUjIQQi66qMehxuRHRpH5mmOuH0UPWhmxc19k0 JzImq9mkgtZfULgRD5D5C0xmex6Wgcz0uHX+O+Xqhulm/Uk3XtXdpytXnUPWbaDLXp /TBhd+M7V8BeyVYPH7x6n99L0L3wyM+/IpSWei30= 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.10 099/171] Drivers: hv: vmbus: Fix potential crash on module unload Date: Tue, 12 Apr 2022 08:29:50 +0200 Message-Id: <20220412062930.748485360@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062927.870347203@linuxfoundation.org> References: <20220412062927.870347203@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 362da2a83b47..b9ac357e465d 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2673,10 +2673,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