Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp444175pxb; Thu, 9 Sep 2021 04:44:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzA8Q5gLJilVNiXDTybWMS4ZxchKUu5xgIQuA60j6p+f3RFb8uppN+d7gQ0zWFfGG3UAgBv X-Received: by 2002:a92:d1d0:: with SMTP id u16mr2050865ilg.56.1631187872478; Thu, 09 Sep 2021 04:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631187872; cv=none; d=google.com; s=arc-20160816; b=x3EbxGoQ9CGJ7/P72SURote/TOWQ8q81AH3O7m+UWMA1Qyy16/oW+K6hrmiQvXr0y+ TC1dBoSpckYdN7+WBM2jE3fen0USgysBIHBVbVwZXrsXmupCy9jF7moS2/sfXx8End1S F1CUde6aBya59t/cEPC7U/Nv6Sseh1HGA8plo3SYimauEzqnS0dONJuX1xhtN9dm8ERH cEaKj/2xdXiYT3fwrZt+m0kda9ET8dQ8Tr/vXoWpH+LiWddRJtpcbKKUdj9+XAdPiXov slRGZ/t0LSYx4WSjJTl8iwsfdrxemu5Jkst+fiVR57tnFXDrvJ+RXccWVhgtVk5oTNYs 24Dw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oZvDIAoQCz7V92biRajqlUdfKxtKQWXgRBMtczuit6s=; b=YjifC6GIGnQJp9Nn2UKZdBY4lWDi72S4fvBVD3icFy/0gbyTrG4AMhDgAn9YB5Yg5x OZaqUlMjHsomgUabWcy6WN8ECak8FsUo0seEsBAILYtqmOROTETDWdMBjGXDRee/MY3Z UuqMsiOundkm6int0rasuuVQMI3e2KNNCH4kmQR9CHK4amMSH+TSp47K6HhaJjulC6pP remUCliuL7uR7gdYauln3XhqrxdN38UBpXVOM12sJJXJObX4mGU8RSSB1I66rl0SB07a IhUMPU7pNZYy6cL466FClv0JpY/UkpZ2gJYcVvyKtr+xCTC8sQR129V5EQj0zSAqRIx9 xALg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=J91FU7iB; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o13si1630847iow.110.2021.09.09.04.44.20; Thu, 09 Sep 2021 04:44:32 -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=@kernel.org header.s=k20201202 header.b=J91FU7iB; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239146AbhIILoF (ORCPT + 99 others); Thu, 9 Sep 2021 07:44:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:46380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236567AbhIILmt (ORCPT ); Thu, 9 Sep 2021 07:42:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B8D57611C4; Thu, 9 Sep 2021 11:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187699; bh=p7uRIQ6xAKswJhj7snL0VgWGtQnH/OK2ukEsfDj4EoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J91FU7iBve6ZO5Rv2J+zruV2ekR6iOf3wW/RWobSNhX0oIrw+ou21ZrCLYFL0upNO tm8FBqTCg0UZ1alTEufvuAzYKp9pF7f5qlz9tYrmevEfmn7TTkAsJLnqjwAIDKtEue d9kn5Vo9skjf77itdggaLNj/BdlT6Sfs97PJ4CcwFOfKlx7q8nEGqhggd3ODfu59X+ JTRMivSbW3KAeT+gWP028kvBr+cPvjTfhvJWol2hTjYf1ANgxwWYnL65rHj03KoEUd HtTZnb0trwqtqHRrJ7Z7Qg5nQkDaOm4gBPWDbwVfZ7SmqOS9nZHv45W0Tm8OSr1s/G O+17UQVT8WZ5w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stefan Assmann , Konrad Jankowski , Tony Nguyen , Sasha Levin , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 025/252] iavf: do not override the adapter state in the watchdog task Date: Thu, 9 Sep 2021 07:37:19 -0400 Message-Id: <20210909114106.141462-25-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 606a01ce4073..0d0f16617dde 100644 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c @@ -1984,7 +1984,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