From patchwork Fri Nov 8 07:45:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13867692 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBF1C19413C; Fri, 8 Nov 2024 07:46:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051963; cv=none; b=asSp5UxBdbU5eVcxjWrnwXJXxtSAlNzZ0JTeIDQS1JakCLTMMYU56s/V8Pv1jJ2aaiHwxBZu16dJgsPMbzHJs4J+EcePsq1oSDR9uAl4mEwd0JfDRfm/vuqx6BoL06Zqnt1gZGQTQn/gye388wYtE5o9OWjSTP8ryjZOWGXiY94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051963; c=relaxed/simple; bh=Zs8gFtkTw+B6KPpY+wmbVRHM3m/7uJgOKkx3TO7v+7M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=elClHV2XvpstNcMoNnjIhfzWkkGOIa8MDThhD8Yn7OyCBCDi6ivsJOjT+A9jGvAZnWpDD23Ra79kQOFbQ9ECb1f1qOwuYfOCmAfsl3I3yWQvooa1FYXNvnWIfIf7Vsho2Q1J04DynVjPChLPrj8Uk29hnvPUqV6w0KbKI1O8c04= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=LZE1XEwz; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="LZE1XEwz" Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A7Mbhrb022685; Thu, 7 Nov 2024 23:45:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=E srYLFOETu+JgthTNSS2RvNaO0lAW/qGZVqi8P6UMPc=; b=LZE1XEwzlnspAYNqa EA+f5Uy5Fa9+PkMYWSJD5Enq3Wm2s/laRg0K2/VPHv6dMIPYNvX1t9Ifs9oAcysS RYqd34okq/4sGLZjNyPGh2IPlI2Cyqmw1eTrwO1O14IjxRUYSWq2LTwogsmMad/2 0qJtZf4nmn3YIdD+NnhPUnh4LZIuTkBJvw/OFXS17Gxon2yri/idLAPxZRbNW5ON fBqdteI17j8kA/ovIN1KX1PqS4xaETUmBYUJM1WtgCH3wSgdjH6/IfuUMZplS+rh ExTUb2VR9ozjpj+cth+q4nl5dp9rLYKOBMmrAkYH2rh9pRXY6IUyV1IqDqw+l0GX 7Rxiw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42s6gu90ax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 23:45:48 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Nov 2024 23:45:47 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 7 Nov 2024 23:45:47 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 252673F7082; Thu, 7 Nov 2024 23:45:47 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , Shinas Rasheed , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Abhijit Ayarekar , "Satananda Burla" Subject: [PATCH net v3 1/7] octeon_ep: Add checks to fix double free crashes. Date: Thu, 7 Nov 2024 23:45:37 -0800 Message-ID: <20241108074543.1123036-2-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241108074543.1123036-1-srasheed@marvell.com> References: <20241108074543.1123036-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 0f8NN1etRcISq0lXzhN26H_MM1F4OhT9 X-Proofpoint-GUID: 0f8NN1etRcISq0lXzhN26H_MM1F4OhT9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org From: Vimlesh Kumar Add required checks to avoid double free. Crashes were observed due to the same on reset scenarios Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support") Signed-off-by: Vimlesh Kumar Signed-off-by: Shinas Rasheed --- V3: - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-2-srasheed@marvell.com/ - No changes V1: https://lore.kernel.org/all/20241101103416.1064930-2-srasheed@marvell.com/ .../ethernet/marvell/octeon_ep/octep_main.c | 39 +++++++++++-------- .../net/ethernet/marvell/octeon_ep/octep_tx.c | 2 + 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 549436efc204..ff72b796bd25 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -154,9 +154,11 @@ static int octep_enable_msix_range(struct octep_device *oct) */ static void octep_disable_msix(struct octep_device *oct) { - pci_disable_msix(oct->pdev); - kfree(oct->msix_entries); - oct->msix_entries = NULL; + if (oct->msix_entries) { + pci_disable_msix(oct->pdev); + kfree(oct->msix_entries); + oct->msix_entries = NULL; + } dev_info(&oct->pdev->dev, "Disabled MSI-X\n"); } @@ -496,16 +498,18 @@ static void octep_free_irqs(struct octep_device *oct) { int i; - /* First few MSI-X interrupts are non queue interrupts; free them */ - for (i = 0; i < CFG_GET_NON_IOQ_MSIX(oct->conf); i++) - free_irq(oct->msix_entries[i].vector, oct); - kfree(oct->non_ioq_irq_names); - - /* Free IRQs for Input/Output (Tx/Rx) queues */ - for (i = CFG_GET_NON_IOQ_MSIX(oct->conf); i < oct->num_irqs; i++) { - irq_set_affinity_hint(oct->msix_entries[i].vector, NULL); - free_irq(oct->msix_entries[i].vector, - oct->ioq_vector[i - CFG_GET_NON_IOQ_MSIX(oct->conf)]); + if (oct->msix_entries) { + /* First few MSI-X interrupts are non queue interrupts; free them */ + for (i = 0; i < CFG_GET_NON_IOQ_MSIX(oct->conf); i++) + free_irq(oct->msix_entries[i].vector, oct); + kfree(oct->non_ioq_irq_names); + + /* Free IRQs for Input/Output (Tx/Rx) queues */ + for (i = CFG_GET_NON_IOQ_MSIX(oct->conf); i < oct->num_irqs; i++) { + irq_set_affinity_hint(oct->msix_entries[i].vector, NULL); + free_irq(oct->msix_entries[i].vector, + oct->ioq_vector[i - CFG_GET_NON_IOQ_MSIX(oct->conf)]); + } } netdev_info(oct->netdev, "IRQs freed\n"); } @@ -635,8 +639,10 @@ static void octep_napi_delete(struct octep_device *oct) for (i = 0; i < oct->num_oqs; i++) { netdev_dbg(oct->netdev, "Deleting NAPI on Q-%d\n", i); - netif_napi_del(&oct->ioq_vector[i]->napi); - oct->oq[i]->napi = NULL; + if (oct->oq[i]->napi) { + netif_napi_del(&oct->ioq_vector[i]->napi); + oct->oq[i]->napi = NULL; + } } } @@ -666,7 +672,8 @@ static void octep_napi_disable(struct octep_device *oct) for (i = 0; i < oct->num_oqs; i++) { netdev_dbg(oct->netdev, "Disabling NAPI on Q-%d\n", i); - napi_disable(&oct->ioq_vector[i]->napi); + if (oct->oq[i]->napi) + napi_disable(&oct->ioq_vector[i]->napi); } } diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c b/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c index 06851b78aa28..157bf489ae19 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c @@ -323,6 +323,8 @@ void octep_free_iqs(struct octep_device *oct) int i; for (i = 0; i < CFG_GET_PORTS_ACTIVE_IO_RINGS(oct->conf); i++) { + if (!oct->iq[i]) + continue; octep_free_iq(oct->iq[i]); dev_dbg(&oct->pdev->dev, "Successfully destroyed IQ(TxQ)-%d.\n", i); From patchwork Fri Nov 8 07:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13867697 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFA731DFE16; Fri, 8 Nov 2024 07:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051972; cv=none; b=jR/g6m0BOYjP+QA2V6g5iJ4kM/sUQbcB2ViMcpXEjkqYweNbypffIyaRaCl24zWibq10wDGQ+XN9I6eV8K6O8mdPUl+/bR2foWmZhQWRiQNZJcgevoRrdwIcjnNAbO+KmLqzsn9oW1tgK+hWpyIJTogiTt/5OMKBtH9ARMZBf/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051972; c=relaxed/simple; bh=tyl6DetRIGomzC9jMz9Z7Qx0KQHSlG7fjBngCq7flTs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IG+WgRJmK/ETQJ4R/mne0xByZC9KAu9NU97YjCV52PR0n2RYmWg4/wMtx5r4ceUUgGtgk4N1eOxP2awRk19LrZeZJncy9SLwGrbGqlTEiD1nz1dGEsfAOzieUgW+P8t32yCaZlvtQrAlHKq5OFO1nILQL79PdWJnmIO1m0hv2qQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=Kwb0tAGs; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Kwb0tAGs" Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A84EBd5027930; Thu, 7 Nov 2024 23:45:50 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=M +6XUeEE3PTM8KsoMjpV/QxUzjZXDSpsAR5nchr3p7o=; b=Kwb0tAGsPK545Ksyo VZLvtcITULoYPLhVnIXUkN3tafimZBmLX/tgAgAVozP9cXl2FgayuVtsyf2jyq52 MJXTxvxnAokNKA/ZIhzwRKCCDouat7t+/Ae7KiY+mMT+6XJyydbu0tzZCz3OL2aO hQrb6In5cHF7JiZAexX8XA6ur5v9uAAF5RRClQPIYPKfhULI6y9sLRlLc6zV10U3 0jzJKMVdMZWFUg+9RrTqufHL5yO+dhqfoM+p3zdQvCB1heoAqFFsJRqNv8trf2na iHXxfcS7tbvtllzn1oDt2zhFkH6bR/1HQ1fWK0QSsVS4xjte5YidFaRSNCdzS/4X 6QMBw== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42sbdq0brn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 23:45:50 -0800 (PST) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Nov 2024 23:45:49 -0800 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 7 Nov 2024 23:45:49 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id CE9103F7082; Thu, 7 Nov 2024 23:45:48 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , Shinas Rasheed , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Satananda Burla , Abhijit Ayarekar Subject: [PATCH net v3 2/7] octeon_ep: Fix null dereferences to IQ/OQ pointers Date: Thu, 7 Nov 2024 23:45:38 -0800 Message-ID: <20241108074543.1123036-3-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241108074543.1123036-1-srasheed@marvell.com> References: <20241108074543.1123036-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dgadC9g8F6AARZX3rYg9FpzoJwTVf4tz X-Proofpoint-GUID: dgadC9g8F6AARZX3rYg9FpzoJwTVf4tz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Patchwork-Delegate: kuba@kernel.org During unload, sometimes race scenarios are seen wherein the get stats callback proceeds to retrieve the IQ/OQ stats, but by then the IQ/OQ might have been already freed. Protect against such conditions by defensively checking if the IQ/OQ pointers are null before dereference. Fixes: 6a610a46bad1 ("octeon_ep: add support for ndo ops") Signed-off-by: Shinas Rasheed --- V3: - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-3-srasheed@marvell.com/ - Split from earlier patch into a separate patch - Added more context V2: https://lore.kernel.org/all/20241101103416.1064930-3-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index ff72b796bd25..dc783c568e2c 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -1016,6 +1016,9 @@ static void octep_get_stats64(struct net_device *netdev, struct octep_iq *iq = oct->iq[q]; struct octep_oq *oq = oct->oq[q]; + if (!iq || !oq) + return; + tx_packets += iq->stats.instr_completed; tx_bytes += iq->stats.bytes_sent; rx_packets += oq->stats.packets; From patchwork Fri Nov 8 07:45:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13867693 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A7BC1D1E81; Fri, 8 Nov 2024 07:46:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051964; cv=none; b=mDGOWySw1MaIcTyimPh4TWZBnnr+PUhrAxZTjWLienIx6bjshKWLx7GOFTH3MFJKStfiUO701g6wdccyUH/ouWgUcqg3Nmig03PIGoax03ovhILmPT0WFB/QmQFwOpto/Kj9+GD/KtsfDWX3/aKzXGJy/5ixbgHEfQ3Xs0Xgl9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051964; c=relaxed/simple; bh=o2rTndZMtXvHxLMu2eyyajTwKd5p3vII/u985KoNbMo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ugnsIzDnWm+7ZBoViSpHdN311iqG+i2/K5l+PAPIln1aJa6GcRXVZKdqyc7Z7/sNYJmNeCGC3uhkJ3d/+ID4aklFSwG6oXQogQfvSjJJAYAPctGXygIuEvEJfOrd6lhOchkD+6OIH1OeOcpiYCGtnolReWYH9j+g8gc2GAW12qo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=ZbSavk8g; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="ZbSavk8g" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A84hDiD012133; Thu, 7 Nov 2024 23:45:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=B mLSqJqdPGKpseIOw6+sDJt4WFJrVy/h9uWiIGijFAo=; b=ZbSavk8gW7Ixoty7U NjRhpdWS9y0sP4TDGzJe8wVrZdWs39sjXuHd8GdpODAzZODAkA0J/ypPOgUYvpvW lFDXmdq21dBhAez07yOkiBkEjfe7wAz88kdite71k1Ajagundkwpew+eiTqAbAQc zjiG7V0038dYfMQDlMN7RvrpwBy5V8YsoVeDNBJs4Bns/kmmQI2MLo8OJ8+t6t2y 9Y7+yUCs4Fpcmvbs8EvoT7/LA2a4q0XIb2Smby19BHZp4T4+vwFMSGPtqYF6yK8W rzcM4wXB2OFxzXU2FGMbY3jzWWy0foTkUMc9VJtSc87PIsMwi1l69/Ci9KrRPi3O PyXjw== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42sbv68a4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 23:45:52 -0800 (PST) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Nov 2024 23:45:51 -0800 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 7 Nov 2024 23:45:51 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 7B0143F7082; Thu, 7 Nov 2024 23:45:50 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , Shinas Rasheed , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Abhijit Ayarekar , "Satananda Burla" Subject: [PATCH net v3 3/7] octeon_ep: add protective null checks in napi callbacks for cn9k cards Date: Thu, 7 Nov 2024 23:45:39 -0800 Message-ID: <20241108074543.1123036-4-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241108074543.1123036-1-srasheed@marvell.com> References: <20241108074543.1123036-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: fr6vHe3gIT5M2TM4CCc3o_Aavb3xU0ji X-Proofpoint-ORIG-GUID: fr6vHe3gIT5M2TM4CCc3o_Aavb3xU0ji X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Patchwork-Delegate: kuba@kernel.org During unload, at times the OQ parsed in the napi callbacks have been observed to be null, causing system crash. Add protective checks to avoid the same, for cn9k cards. Fixes: 1f2c2d0cee02 ("octeon_ep: add hardware configuration APIs") Signed-off-by: Shinas Rasheed --- V3: - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-4-srasheed@marvell.com/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-3-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c b/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c index b5805969404f..b87336b2e4b9 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_cn9k_pf.c @@ -617,7 +617,14 @@ static irqreturn_t octep_rsvd_intr_handler_cn93_pf(void *dev) static irqreturn_t octep_ioq_intr_handler_cn93_pf(void *data) { struct octep_ioq_vector *vector = (struct octep_ioq_vector *)data; - struct octep_oq *oq = vector->oq; + struct octep_oq *oq; + + if (!vector) + return IRQ_HANDLED; + oq = vector->oq; + + if (!oq || !(oq->napi)) + return IRQ_HANDLED; napi_schedule_irqoff(oq->napi); return IRQ_HANDLED; From patchwork Fri Nov 8 07:45:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13867694 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C44211D8A14; Fri, 8 Nov 2024 07:46:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051966; cv=none; b=JOQqIlw9c0jjo0WS8GlVezE49tyT7ht3dvcNd+ylfV5CauE0F66dRaBMAcqUfxpqNWe5oaId5woo3q82o7ZcTUZxlGEB+zMFXkthNLtm713IjAyZ1izJRrqWnRwg9GQI8alkxU/YkKfEKNzikYwVOy9E/jrMZeDDWzgQLGtkPf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051966; c=relaxed/simple; bh=lVgRJkTudVJcmdbS+x21u9mgJKISN8B89B7L8QPYRg0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tUDXAWt2RFKdTmU7bs9e9zumEibHyj6azrf6SSNjSVz6TBxxh5hmaUSNRtReJ4NYEgBG1IMaTYiYYUjGRZv3GWb7gkdjsKpR36N+A4GzRaNVf/LlowQ57mP3w0sSIcaAgCOCu+uMat9aq23nVNqTMvEs94cWqd7lvHsCIBQpi38= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=XzQesEUO; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="XzQesEUO" Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A84hSiT012266; Thu, 7 Nov 2024 23:45:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=S fHYLDmgkFn6leQQOMqPeMPmCv0gBhR1b70rHi/lzto=; b=XzQesEUOEevlXwpkJ qgiL7pYqs8F9MrQJJachEpo7QfckxQr0vj/16mUZbXpPkCgCxYlLQc/KWkXtT3NL XKGZJJa8sZx+wbjxZ5qz/bpGeKtOwrLuMjL7SVtmybqak5Z0r9wTZ7kgMxty+GtI Vtw8tUKPFaZIYsHUKyG7h9rnTu7QgUYcJnXGYuweauQVNLGTg1SYxJ2q23apo/98 sBx4sz798WsXyW/7IRzgFlEixZ1LKi3o85QujxC3Z050hWEPz1quQFauLVz6a3C6 cANJGX0LjnJCxWDsRCaHw6ojZnYk0zEz6QeQCd+MhTMC3XvhjhhOTtnndSBn9OFU MTQNA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42sbv68a4g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 23:45:53 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Nov 2024 23:45:52 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 7 Nov 2024 23:45:52 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 1D3063F7082; Thu, 7 Nov 2024 23:45:52 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , Shinas Rasheed , Veerasenareddy Burru , Andrew Lunn , "David S. Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v3 4/7] octeon_ep: add protective null checks in napi callbacks for cnxk cards Date: Thu, 7 Nov 2024 23:45:40 -0800 Message-ID: <20241108074543.1123036-5-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241108074543.1123036-1-srasheed@marvell.com> References: <20241108074543.1123036-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: y8Ufng22z5mKSe7LkNWXUvD0OTUfL3QB X-Proofpoint-ORIG-GUID: y8Ufng22z5mKSe7LkNWXUvD0OTUfL3QB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-Patchwork-Delegate: kuba@kernel.org During unload, at times the OQ parsed in the napi callbacks have been observed to be null, causing system crash. Add protective checks to avoid the same, for cnxk cards. Fixes: 0807dc76f3bf ("octeon_ep: support Octeon CN10K devices") Signed-off-by: Shinas Rasheed --- V3: - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-5-srasheed@marvell.com/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-3-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c b/drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c index 5de0b5ecbc5f..65a8dc1d492b 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_cnxk_pf.c @@ -638,7 +638,14 @@ static irqreturn_t octep_rsvd_intr_handler_cnxk_pf(void *dev) static irqreturn_t octep_ioq_intr_handler_cnxk_pf(void *data) { struct octep_ioq_vector *vector = (struct octep_ioq_vector *)data; - struct octep_oq *oq = vector->oq; + struct octep_oq *oq; + + if (!vector) + return IRQ_HANDLED; + oq = vector->oq; + + if (!oq || !(oq->napi)) + return IRQ_HANDLED; napi_schedule_irqoff(oq->napi); return IRQ_HANDLED; From patchwork Fri Nov 8 07:45:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13867698 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE81B1D27B9; Fri, 8 Nov 2024 07:46:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.156.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051974; cv=none; b=h+xBZsTW0+yb6Ml8sNrUK4dMNlFTkGEo0ho+Qvjq28QarDHnTPe/WGNjA/BkIOe7ANARG44aknCdGDZomkRF/hR9LnOLOwhFQbmrFJYpcoTW1vQLy2yTlVYaXXr8n9fDXt4Rw7l/EWRbeJUbFHvMx8RlOqngPGQzLav7HwuEixI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051974; c=relaxed/simple; bh=nkxULcvJe6TBcUSBEXf9M0DtZuqy+0Qand37ThuOZv0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZeQ/hhtJbriZvEo8Bc8aa7f2cSBWzEkI6UNsHircWvXzXaTHE37mrswPf0ZyIdQm/zJ7vF6dLf19Bj2kXGCxH6YB3O6668SMF9bchsuL7rki4UZ3k1AfVg7Xy945s9prZktByUFGHSM9/B0Pk9kXKKPo6smmxNDs/DELqHZWy68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=Lr9MuHFN; arc=none smtp.client-ip=67.231.156.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Lr9MuHFN" Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A81ghb2019272; Thu, 7 Nov 2024 23:45:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=Z 46/52708qnB7GFWEYR2f+Qfh9tmbXsvJQ79iUGzw54=; b=Lr9MuHFNo4KKNffdl U5N7TsBqgFyumhrY7FB+N5tvnN9Ri5pCejXI/eikbdfWJ7bTRISNgb2GeqJTGvoJ 8BKO0acvIfNKAkO4uSBDmgrxapNrB/hlm1hWTYqYx+pYOc2fkx52QnGxArrRpkwG ZWBqaZyIsy6xiBiPSVWgdCrVicHC7iGJ1g83tE4u4WFyTmXdu/9qRTujCVcheGJj v+ezMV/cCkWMmevhCS3JknCPFJtuTwJRD99NJwER6Rp7CwrHh5UPursHVqj8cvrE +H2Lw+v3kNEOr+mUXZVeFrhVy+2cC1Afks9XrIsR63xuClXLX3b6IqqhAojwszJf KKbNQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42s97hrkt5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 23:45:55 -0800 (PST) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Nov 2024 23:45:54 -0800 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 7 Nov 2024 23:45:54 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id B892E3F7082; Thu, 7 Nov 2024 23:45:53 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , Shinas Rasheed , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v3 5/7] octeon_ep_vf: Fix null dereferences to IQ/OQ pointers Date: Thu, 7 Nov 2024 23:45:41 -0800 Message-ID: <20241108074543.1123036-6-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241108074543.1123036-1-srasheed@marvell.com> References: <20241108074543.1123036-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ysRrBnL08M9O4BQXBH62S6YY1PrPbWtg X-Proofpoint-GUID: ysRrBnL08M9O4BQXBH62S6YY1PrPbWtg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org During unload, sometimes race scenarios are seen wherein the get stats callback proceeds to retrieve the IQ/OQ stats, but by then the IQ/OQ might have been already freed. Protect against such conditions by defensively checking if the IQ/OQ pointers are null before dereference. Fixes: cb7dd712189f ("octeon_ep_vf: Add driver framework and device initialization") Signed-off-by: Shinas Rasheed --- V3: - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-6-srasheed@marvell.com/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-4-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c index 7e6771c9cdbb..79d9ffd593eb 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_main.c @@ -790,6 +790,9 @@ static void octep_vf_get_stats64(struct net_device *netdev, struct octep_vf_iq *iq = oct->iq[q]; struct octep_vf_oq *oq = oct->oq[q]; + if (!iq || !oq) + return; + tx_packets += iq->stats.instr_completed; tx_bytes += iq->stats.bytes_sent; rx_packets += oq->stats.packets; From patchwork Fri Nov 8 07:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13867695 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1648B1DFD9B; Fri, 8 Nov 2024 07:46:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051970; cv=none; b=gXkuUUInOcjx9GwLEdFvSG0kPoumwNgAt5CfLE7uQOzz/fVmIGROgNPXUbUx0cbPjzadLhOS2PCANE/f8+iec7Rchpe+0+6vg1XWoBjQ2hTv6/qqh0JzESZqpTP0+C4+2JKHaVechIJU8nYmB91qMW+CVB46zeLFY2zZdueo5dM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051970; c=relaxed/simple; bh=dh8bEnNdsPsw8OXFwNjMc3X9dLpYzfqmHCAmniviRik=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qa5ngPx8H5Q4ZoUTYYlOdAphS9RQyyZAlyr+z9fshe2w1nYRjwpJR7MuzoozLncByxGdCB1EKuyEmnZ/A2m0fu7vwpn5mCvVGnVc58WzgMsz1KK8oxSlgHMbRgZ17UUGB6DTZmcbKA4drq3m56LjEmhm1EZ5N+7HdabCOadUN3w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=Er8fY061; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Er8fY061" Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A7Mbvgl022794; Thu, 7 Nov 2024 23:45:56 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=U uDbgKg+IttnOHFMUqrpGYtL8A/0bOttNMW1tBLqDTw=; b=Er8fY061mcc3yCcBL vnS7KMqnq0fHL+EUvqRBIpGy6OoLx23/aLZfzpLTZlhr6LWPrMLa2Mv3hd+YEyyk REFBVaFpcbml5XnjHsJF4VEB9udRlKa0706U8dws7Z3DdWzQlRuCEWfqepnZO9R+ 0iBOdhWvjCI0destMmk2awE81u/GNyxcUenZVvO2O6V1m5izI95HqSgeBTakgDqM dEha4uzEaN75jgYzHTpLFIzqBrnBrAcsmOjrnyBMAEDSRPFOFBPtb4LFjTVhAGQB 1z2optsm/REopm8QAGsE6ny8IMMWiFvhUpV91enmzK03db2I14Gsfm2F1dkL3Ve0 dk90w== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42s6gu90ba-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 23:45:56 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Nov 2024 23:45:55 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 7 Nov 2024 23:45:55 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 4F2693F7082; Thu, 7 Nov 2024 23:45:55 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , Shinas Rasheed , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v3 6/7] octeon_ep_vf: add protective null checks in napi callbacks for cn9k cards Date: Thu, 7 Nov 2024 23:45:42 -0800 Message-ID: <20241108074543.1123036-7-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241108074543.1123036-1-srasheed@marvell.com> References: <20241108074543.1123036-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ZwPHvxoctpAj8F7oB_hUdDYEQSuIEW4m X-Proofpoint-GUID: ZwPHvxoctpAj8F7oB_hUdDYEQSuIEW4m X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org During unload, at times the OQ parsed in the napi callbacks have been observed to be null, causing system crash. Add protective checks to avoid the same, for cn9k cards. Fixes: cb7dd712189f ("octeon_ep_vf: Add driver framework and device initialization") Signed-off-by: Shinas Rasheed --- V3: - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-7-srasheed@marvell.com/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-4-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c index 88937fce75f1..f1b7eda3fa42 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cn9k.c @@ -273,8 +273,14 @@ static irqreturn_t octep_vf_ioq_intr_handler_cn93(void *data) struct octep_vf_oq *oq; u64 reg_val; - oct = vector->octep_vf_dev; + if (!vector) + return IRQ_HANDLED; + oq = vector->oq; + if (!oq) + return IRQ_HANDLED; + + oct = vector->octep_vf_dev; /* Mailbox interrupt arrives along with interrupt of tx/rx ring pair 0 */ if (oq->q_no == 0) { reg_val = octep_vf_read_csr64(oct, CN93_VF_SDP_R_MBOX_PF_VF_INT(0)); From patchwork Fri Nov 8 07:45:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13867696 X-Patchwork-Delegate: kuba@kernel.org Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E26471DFE1D; Fri, 8 Nov 2024 07:46:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051972; cv=none; b=lbSIGWeAzQJIuEbFm83XgKc5Y7DfVMCDExK6HqTSM7XSlYb70BbIGB6GBbzsM+Y5rL+nTNDPCgKh1pvlRyvfoab0kaNYyXu+BoNsnS/GfpjRMOsI6cSyovUIbkFx9An52IaeRdrVDC4vJmv9qN7oQZHC7fmCDP4VmRIwmK1DNPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051972; c=relaxed/simple; bh=UcujsZpogw2k58eXliUjEfbuY/Mi96YOb6arNOas3Wk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LLxYbCG/+XC5CdpVEjvyzFhNZ+14wl+Md9GKg0rIQ3wbhkW68KAUwoU++PNTwcgriTDzk25SSGugYQg35+jxNVay/Ja61wTkIXoCBtL7tjcxPeYFhUTb5Cypy1H6Nuyq4vjZK1nA3xmOt6ppEsTTEH0kCYzKNnZFvG1uQ3ppCrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=X3KCjzzW; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="X3KCjzzW" Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4A7Mbwps022799; Thu, 7 Nov 2024 23:45:58 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=q kQ1jiLZhUMeLIUDhokeQeMRcnt1hZUtcxqwDbIZTNs=; b=X3KCjzzWnzsamPqeL bPF6FzO4XcWPPRKoOLLXSkO3Sm/aK7T74ZVVVsPwMdlvZxdv8hrTA1tqIPiuYkLz 2z18U6RZS6Lkaw5NKA40FR5AywqY0SXfbenaF+cvOnxWW//IJhu5N+R7/q7ioH+X zcirrrImCtM7Bs4Z8yq3Se2M2fWUeqjEhiBpYEi9CeFwJ3MAQLQl/QASlBUt9aQc O/Ud1Nyd/etJFvwnOFrDuEVDycyPqJMBGT8nNt+Z+iabsks9h5ciwTK1JFgoMe7Y sbFWKpGt7qrYxX/PhlgIKDCJ/+vXLMiMdIyw2Ahu0kgbvbQjKTi+nzkfxwfL3h7X xBPhg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42s6gu90bc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 23:45:58 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Nov 2024 23:45:57 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Thu, 7 Nov 2024 23:45:57 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id CC8943F7082; Thu, 7 Nov 2024 23:45:56 -0800 (PST) From: Shinas Rasheed To: , CC: , , , , , , , , , , Shinas Rasheed , Veerasenareddy Burru , Satananda Burla , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net v3 7/7] octeon_ep_vf: add protective null checks in napi callbacks for cnxk cards Date: Thu, 7 Nov 2024 23:45:43 -0800 Message-ID: <20241108074543.1123036-8-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241108074543.1123036-1-srasheed@marvell.com> References: <20241108074543.1123036-1-srasheed@marvell.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Bf-NFOFGZcPZEL6sQckzyCeROYGT3O9z X-Proofpoint-GUID: Bf-NFOFGZcPZEL6sQckzyCeROYGT3O9z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 X-Patchwork-Delegate: kuba@kernel.org During unload, at times the OQ parsed in the napi callbacks have been observed to be null, causing system crash. Add protective checks to avoid the same, for cnxk cards. Fixes: cb7dd712189f ("octeon_ep_vf: Add driver framework and device initialization") Signed-off-by: Shinas Rasheed --- V3: - Added back "Fixes" to the changelist V2: https://lore.kernel.org/all/20241107132846.1118835-8-srasheed@marvell.com/ - Split into a separate patch - Added more context V1: https://lore.kernel.org/all/20241101103416.1064930-4-srasheed@marvell.com/ .../ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c index 1f79dfad42c6..31c0d7c0492a 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_cnxk.c @@ -284,8 +284,14 @@ static irqreturn_t octep_vf_ioq_intr_handler_cnxk(void *data) struct octep_vf_oq *oq; u64 reg_val; - oct = vector->octep_vf_dev; + if (!vector) + return IRQ_HANDLED; + oq = vector->oq; + if (!oq) + return IRQ_HANDLED; + + oct = vector->octep_vf_dev; /* Mailbox interrupt arrives along with interrupt of tx/rx ring pair 0 */ if (oq->q_no == 0) { reg_val = octep_vf_read_csr64(oct, CNXK_VF_SDP_R_MBOX_PF_VF_INT(0)); @@ -294,6 +300,10 @@ static irqreturn_t octep_vf_ioq_intr_handler_cnxk(void *data) octep_vf_write_csr64(oct, CNXK_VF_SDP_R_MBOX_PF_VF_INT(0), reg_val); } } + + if (!(oq->napi)) + return IRQ_HANDLED; + napi_schedule_irqoff(oq->napi); return IRQ_HANDLED; }