Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1699831pxb; Thu, 16 Sep 2021 13:19:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfNGeVX+Qd8exNOxH7Dz/es1pmG6/XcBjDeT1zheCNvgb2zYMcl/bvJw8PpV0jnCM7q+W4 X-Received: by 2002:a17:906:1601:: with SMTP id m1mr8291074ejd.485.1631823581454; Thu, 16 Sep 2021 13:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823581; cv=none; d=google.com; s=arc-20160816; b=sFC0LDqNIhWO7nltgVUwzvyiaQMGXMLuXkGfVo/+gqWxVjbsFOx5s+DIzaMHwedQkh Mrw4yt3Ojz92GQen9daAGgbZDPp05IXwfD9WHqLB1TQzQIg/Q9hYy0qHi6SY1CWt3PlQ Dbf+8fz0O/6AwasUobpCHOVvleXLcypsw+GGDS63ePWhMs5GT1APFKZ3iDqeo/GHVTsA g5cPs7RY4Nrx6gn4HaKfo0hEe2col2z3csTAPfgk7fkCmN0tya5l7iy2YNwDllgPqSCt HqJgKC+On40soKMqBn7mxNglobdEEQOaCKhK2EcuBOhB8/26bSFiZ3vrQGPqy51k0zdL U+xw== 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=mfrTBEHVr6zsWrz3FIRjXrInXLCPabrR/6R98YZ2KDc=; b=sM2hDqYDgySJiJ5fkYiSd5827WeUpROUFyzXqgzyeWhLYZ59hraGRjia7YiceccYld Iy8QM0NMppG0SUSSe3sbN6K9So9XgcsNS4u9l65qowp7zbH4ylZeHiXM2R5ggp2xI2Sm OKJeNmS7+LT1cKScJvZw2lx2atKfuFLholKYO6feTyZigUDCMv56HOKFb1gUYmj0BYwn +2i9StfXiPJSqttZ/QQxL4GLD5m//67iT2TbF6HfTtpC8x1wz86f0J4hjNunT7QkbhF8 T2ZwpROiMB6MGjCM2wwiNEW8kMr19p6ANCL1DPbbpDaJ4Fe/SvD7IcViUjIiMk3lG2Ue dXOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ceQpw2py; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jl23si4156404ejc.753.2021.09.16.13.19.17; Thu, 16 Sep 2021 13:19:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ceQpw2py; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241429AbhIPQTe (ORCPT + 99 others); Thu, 16 Sep 2021 12:19:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:48410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237333AbhIPQKp (ORCPT ); Thu, 16 Sep 2021 12:10:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 71EDF61360; Thu, 16 Sep 2021 16:08:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808517; bh=ojuaTAZhr8Uw6QEtkXAyeaRZbg6Ro4//uWTFWOQSH8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ceQpw2pyjXYHVYFYms8LF5nlk0LRs/TWwdgDkPwOq/TmZMPRODAAQxY0AfBMiQMFa ZyljfBsfnkBXdTeCZlZDQvxNbSa5PJ9sC3yM5aYfieq2crLJphsqGBEm2qYAhbVsXr 6BEnYOslJG+znazJaJ/lTh3yYZt7PXiv+hTF5c1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Assmann , Konrad Jankowski , Tony Nguyen , Sasha Levin Subject: [PATCH 5.10 121/306] iavf: do not override the adapter state in the watchdog task Date: Thu, 16 Sep 2021 17:57:46 +0200 Message-Id: <20210916155758.192620419@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stefan Assmann [ Upstream commit 22c8fd71d3a5e6fe584ccc2c1e8760e5baefd5aa ] The iavf watchdog task overrides adapter->state to __IAVF_RESETTING when it detects a pending reset. Then schedules iavf_reset_task() which takes care of the reset. The reset task is capable of handling the reset without changing adapter->state. In fact we lose the state information when the watchdog task prematurely changes the adapter state. This may lead to a crash if instead of the reset task the iavf_remove() function gets called before the reset task. In that case (if we were in state __IAVF_RUNNING previously) the iavf_remove() function triggers iavf_close() which fails to close the device because of the incorrect state information. This may result in a crash due to pending interrupts. kernel BUG at drivers/pci/msi.c:357! [...] Call Trace: [] pci_disable_msix+0x3d/0x50 [] iavf_reset_interrupt_capability+0x23/0x40 [iavf] [] iavf_remove+0x10a/0x350 [iavf] [] pci_device_remove+0x39/0xc0 [] __device_release_driver+0x7f/0xf0 [] device_release_driver+0x23/0x30 [] pci_stop_bus_device+0x84/0xa0 [] pci_stop_and_remove_bus_device+0x12/0x20 [] pci_iov_remove_virtfn+0xaf/0x160 [] sriov_disable+0x3c/0xf0 [] pci_disable_sriov+0x23/0x30 [] i40e_free_vfs+0x265/0x2d0 [i40e] [] i40e_pci_sriov_configure+0x144/0x1f0 [i40e] [] sriov_numvfs_store+0x177/0x1d0 Code: 00 00 e8 3c 25 e3 ff 49 c7 86 88 08 00 00 00 00 00 00 5b 41 5c 41 5d 41 5e 41 5f 5d c3 48 8b 7b 28 e8 0d 44 RIP [] free_msi_irqs+0x188/0x190 The solution is to not touch the adapter->state in iavf_watchdog_task() and let the reset task handle the state transition. Signed-off-by: Stefan Assmann Tested-by: Konrad Jankowski Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/iavf/iavf_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c index 7023aa147043..da401d5694bf 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -1951,7 +1951,6 @@ static void iavf_watchdog_task(struct work_struct *work) /* check for hw reset */ reg_val = rd32(hw, IAVF_VF_ARQLEN1) & IAVF_VF_ARQLEN1_ARQENABLE_MASK; if (!reg_val) { - adapter->state = __IAVF_RESETTING; adapter->flags |= IAVF_FLAG_RESET_PENDING; adapter->aq_required = 0; adapter->current_op = VIRTCHNL_OP_UNKNOWN; -- 2.30.2