From patchwork Thu Nov 7 13:28: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: 13866491 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 958E220F5A5; Thu, 7 Nov 2024 13:29: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=1730986154; cv=none; b=BvMpMTbOl63ThBkDR4vVFoEVVxSRG0SgSYxEoZqQUcTs7xJVaxUakEZM022AOgoiPu1L0amjQc++r1fPUSBXfsTOQnrR1FRVccY9WueI/FNv2Kmzw74aGPRYFm9FkH9px4ADu0xz9We7eR1XdAoLYTxt0dberXdlWTRKwTYNj6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986154; c=relaxed/simple; bh=/IrWnmOwo9gIA0TRD6u7nsOjh113GsC4TAyK4EThEIA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=THv243kaawpEsHgMFjC0do8H3JT19kqBfPAmFnHfegBTb1KXMpWaFTgSbxDNJn1JQTAyKetc2334By2OdlOOv2h0ngDmn50heoEIFa9IEOIy4mFudO8/AdZKjBQOw0l68sg3ie+0UkEAO6wnXJiIn26N3cSrG2joW16xUnx3hic= 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=YW5i7ypk; 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="YW5i7ypk" 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 4A7B6b54010781; Thu, 7 Nov 2024 05:28:59 -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=p jE+HKIwCXE95MzNqYyE5e7AkrFb9SDdDSuMm2NswYc=; b=YW5i7ypk+3sy2RqOw vrQQHJO4wM9F1jLy/qg110kZwSGTJBwTh3ToOEc4n4JxhvQz4f+3/By/b8brEknW NyaHtX2xnYtWPjnwbv3hGg8dcmzvpQMAVDCSFe7Gq2hwonS2x0nlLRYJBAD7Hzxy WfPKgZ5RhZNuDsnG+F3nQZN0MYXJ9a8Rd/PDtKdfGdAvoFwg/V42IdRmG+gleXJU prp6plFX0ZcLBsw8C9lY44ySXBg067PzOktxNW71r/RQOaQJX1xQhYcfaYIaUWFh hrY5JbwrBHGzgteoJKsrRPkNTvZLWOhCG7d0AiTX8aJSUC4PEXWauM+e6qSkF4tO 9J/VQ== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42rvcw0961-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 05:28:59 -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 05:28: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 05:28:57 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 131FD3F708C; Thu, 7 Nov 2024 05:28:57 -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 v2 1/7] octeon_ep: Add checks to fix double free crashes. Date: Thu, 7 Nov 2024 05:28:40 -0800 Message-ID: <20241107132846.1118835-2-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241107132846.1118835-1-srasheed@marvell.com> References: <20241107132846.1118835-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: vXNR5pH4jkOuF_O4_aIGicqHD6ubBqwn X-Proofpoint-GUID: vXNR5pH4jkOuF_O4_aIGicqHD6ubBqwn 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 Signed-off-by: Vimlesh Kumar Signed-off-by: Shinas Rasheed --- V2: - 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 Thu Nov 7 13:28: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: 13866493 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 B7D1B210188; Thu, 7 Nov 2024 13:29:13 +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=1730986155; cv=none; b=ndkhPGnwp0B4/ODzouj5wO9obgcKPs/LkLPX5Kxr1F+eKMrGbEzr1U8x67BLnboKjJ/r2yPiAadxJ/jjNF6MjvxUnMyHTlVjGRAqMkwBTXfHYoi4rmeYuhcgt6+fYLKECuE/xE22vpS5z5dm41Ee/kfL8crqmlOsExU+QKbvapY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986155; c=relaxed/simple; bh=hJX6GzCpMnmX/W7JampOKcb4yLv6v6EW/dkBQcKFFYs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CXDy+hmmZy7u17W/KSI33jM23lnpeqQIqwCBokQ4+lBKrnPqOZAW4+HewhPHeLCC9TVA7oF8fCCqa8KFrFXDq/d4UI+fhbMRcvLgGQKdIjAQhYtLSnB5P2HV6QTWZYSk4SfGfCTi75hLR+y5q6+ji6ostIGnX76wVZEj2ZVqeaI= 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=MbkcARmi; 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="MbkcARmi" 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 4A7Ca6GY018136; Thu, 7 Nov 2024 05:29:00 -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=2 2AQ4pR6UT3V7C9SFR/ewGKApDb6QA8+Dr0xc0vsNoI=; b=MbkcARmix1GzBgQ2l E5mtdocAL+S1yuV7x6t3azU4RI/nk3DLgXtW94rXw/OT4fknMi52ozGhWMapf6HD bNeHiQeDNi6jgSw7mrPiWGboHJEAS6QpjKVEqNDBRKkPkRFbBEtVnYFL4uhAtDE5 l99ltg/p6ufppRH0bk1AWX/09DfRZKHg04WsVigZWfd3QWEdlkn6bDMDluAIo+g4 iUQw9sHhBmPHTBbewl/TYblvOQdztIozXvshUGpjT/3QOjyA7JNpseYKsG9d+FYi +G+xz9cHwG1JdY9iFcSBVpH/E/N6PmFSbHAJp2JDogieLyj7Ipip4n5C9N98a01l AIf2Q== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42rwpng3he-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 05:29:00 -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 05:28:59 -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 05:28:59 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id AF9313F708C; Thu, 7 Nov 2024 05:28:58 -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 v2 2/7] octeon_ep: Fix null dereferences to IQ/OQ pointers Date: Thu, 7 Nov 2024 05:28:41 -0800 Message-ID: <20241107132846.1118835-3-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241107132846.1118835-1-srasheed@marvell.com> References: <20241107132846.1118835-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: nMu1jQ5AZUbksn7PYme6mLctttF22mTG X-Proofpoint-ORIG-GUID: nMu1jQ5AZUbksn7PYme6mLctttF22mTG 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. Signed-off-by: Shinas Rasheed --- V2: - 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 Thu Nov 7 13:28: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: 13866494 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 06209210192; Thu, 7 Nov 2024 13:29:14 +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=1730986156; cv=none; b=YSxP3AAUOCtWl+pHkux/bljLao9MfwPAif8Whtf5RfYsEo2FIR7zvy/mkIBO0WTzmcbau1UXkyKBrm4YbrQPtEPmfSBdB3d6jUkbfFzPxNacS3j2P0PLgDzYOL7h651QdHFoXWWSw9ljhrnYPyDoXZgJMUYjDLO3fRWgfFPoCNY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986156; c=relaxed/simple; bh=Nz3q1Dl8Is3GNYuyJDBOCxA1yTbOIEHWdf6ImgBve1w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LljNoa+qrk1LLYriXUScVh+i767PDRvT/kMTXhA1wAqf7wbhwMtDAEtLJFpmEDBcCA4Axy6BuvOowXNfw82aNNmNTv3PiyuVj9WQbvo/Qu5Hux0FXVF+dnb6V0CEb76IPrySwqbFkO4KWGarGONUOPKMoP4hCMJOtVVeoosy89k= 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=aTl04cuF; 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="aTl04cuF" 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 4A7B6m9w011029; Thu, 7 Nov 2024 05:29:02 -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=H /RsZBgYNLD0iYFFbnisnco/VJ0cm/QFqaOsb8n33ac=; b=aTl04cuFEkQxkF8U2 2hnWU6TKZmMUCzLJpJXVMIcwXswCao+fUSd1mw3Rz2VDhiOVSByED3x7RqAJnflV ux418GJvBW/bQr+pXkY5bALoLbvCQWibHQSWMEyd9jgRa3YT7HRGGTOEt3Qq5oa9 HN95YTKu8tQMP+bzU5gO7dlEsR+wV+GwurB/GM8Lz4Hh6y1WqY+4Z6eN1E7aCFPw i7YR43F0+Tjf37l/lz8W3IXR6dcKc7rhCfYCcwyTNirGJ3/QtXEbvSfN5gULjwvl X+S9My5W0MyFBzBzJfczvcOJuidy0iH++1qUSTeJzoHt089umNxOUyIAU2S6OEJz zkO+A== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42rvcw0966-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 05:29:01 -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 05:29:00 -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 05:29:00 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 569DE3F708C; Thu, 7 Nov 2024 05:29:00 -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 v2 3/7] octeon_ep: add protective null checks in napi callbacks for cn9k cards Date: Thu, 7 Nov 2024 05:28:42 -0800 Message-ID: <20241107132846.1118835-4-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241107132846.1118835-1-srasheed@marvell.com> References: <20241107132846.1118835-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: yEXo3sa1CwZPXtw3JBf12vxXs54d5bAL X-Proofpoint-GUID: yEXo3sa1CwZPXtw3JBf12vxXs54d5bAL 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. Signed-off-by: Shinas Rasheed --- V2: - 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 Thu Nov 7 13:28: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: 13866495 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 5EA47212EE9; Thu, 7 Nov 2024 13:29:17 +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=1730986158; cv=none; b=Lmc3IZph07MolNfEVf0KHhJdZ2GwDlk5UDoP9/Ykk8/0NK41oI5qdr53MvF7dGa6jhgezhTueNRpoDP2TkylNMHGVrh9vVdu5ATjI1roBcx6cBxvVMaOHbiC5KehmGvZC0SeF/8QCKE4mBkQh87hXq7JXj1R2I3Wi0eVZmQpwVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986158; c=relaxed/simple; bh=YnnZEG4iqErUeeinyFBCzZGHYcULm1bNkGNeQask9QQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nQrGE+I2ZpK0E8kN3Q6WoFMHa9yby566fa7tcl1ED9pbKYIbe+zJy5VfpJMz9MwBViskmkRIa/Rhd1GEs5U1rFuS0WRuVn26CUsQlgps6otUmMTVX5gN4pUvhbtRN0RZW65qXRWCytSo8QaP5TQHf+e6i2RzHArIFo3rb2Q60O4= 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=IsXGrVgU; 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="IsXGrVgU" 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 4A7Ca41g018109; Thu, 7 Nov 2024 05:29:03 -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=4 ibQwkNXpH7ZgvIsTUGJIvdNeUAyRmx4ORvMZVfZ734=; b=IsXGrVgUK0fDiQ6LR ZhliDgtvdM3+YHOkVsWWBH7Hu854ZKtzwlR7Hmzjo+PBHx3hK/Ing4ZvLR5iNTJ6 7/eiRsm8+kOgiWzGoZrX31rQdOqQ7EV1CT0G/lSAPMH5tb8Vo587WfZEysgTBZIw FO8Tg/7xqRCxWR6DXUvFNb4orhj3gIO7NqICJWeMGqjGF5YbezdDnQGOQVq0VaGJ 6zf9ymr79lyCU8DgbAQCFaPFoOGNC5AnnU9kaA64Ba/4V6PJtU8zRaenSj+djJNv dYV1OK0wRm0NBgX08fgrFCGSnQRbQCGYej1Xc3qvquwdPEJ04JeYumut9LFAiPxd 7MLbw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42rwpng3hs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 05:29:03 -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 05:29:02 -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 05:29:02 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id E31523F708C; Thu, 7 Nov 2024 05:29:01 -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 v2 4/7] octeon_ep: add protective null checks in napi callbacks for cnxk cards Date: Thu, 7 Nov 2024 05:28:43 -0800 Message-ID: <20241107132846.1118835-5-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241107132846.1118835-1-srasheed@marvell.com> References: <20241107132846.1118835-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: pXpXKMRYR67F_T_4Y9OIMvAL4Kh8csOW X-Proofpoint-ORIG-GUID: pXpXKMRYR67F_T_4Y9OIMvAL4Kh8csOW 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. Signed-off-by: Shinas Rasheed --- V2: - 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 Thu Nov 7 13:28:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13866498 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 93ECB213ECC; Thu, 7 Nov 2024 13:29:20 +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=1730986162; cv=none; b=HmBQJJXRlr/VXnkqUhUMXDiWKE1tILfGx9RPcAqwqq46lEbQvJxfbYKXpsnxsJt0dKICkq6nkOXaWuY32+G41tLPAdxfQe1IyAV/OgStDPbfgtda9MPEIANAwaafw2+CldGHTDn0R0xzwIfC1gKdinoKg/eu0XOFG+JrOYfFFQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986162; c=relaxed/simple; bh=oYMTDUpQKwAiuegxgWjVOkp+luvlh3tBlqqQhPmIv1k=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UYNbTiqmvc4MirGnZoq9OQdwiY1JHSvu/EGE5Sq4l0MSMUOiIS0WqD59t8+aXTL+PdznSrxAspYySTlUPxzBl/2XLe5ML8eJnH7Y5l2EuiZM5gK775JHS5m/YbG4pDOe94hd1HRpxNsgJhxzPFXWdfSd5zOZfmY7cawOAcY6KVA= 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=TvDsO0Mk; 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="TvDsO0Mk" 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 4A7Ca4a2018104; Thu, 7 Nov 2024 05:29:05 -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=i mSw1KER3ojqKjXN9Rv3WdQo2LFZamVC5UDTRcqdJSs=; b=TvDsO0MkIrYR25y4G dHrfKpyrb5RZvDF9pULOkpVbi3Chn0HmWieMGHrdUGmGUxrAP3uo0mA6ueEBWxNK IeAB47MDOfuN4WWYhb5kdsYpu/zl5f35aHibIQoJbunAFW0Z6y7WF7rmCL+o/c+d u9LU0YPJagoRMApbCKHbfj/7N2y9dhoedw2SgckK0zvktQ7T/8+AT2v1yx24BkVC p/TDg8suEi+t9P9zzB6eoT4ZZH1vafUou66OlP+Iu/wZRlQpXXnjiZdK1cD4eG2a MXNAI6q906GB8p3Vo1+7gOcX4qhYBLtplfMUclJ1KoBFIELIu7xcL0mhvPW/c9vI jskdQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 42rwpng3hu-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 05:29:04 -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 05:29:04 -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 05:29:04 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 6F4263F708C; Thu, 7 Nov 2024 05:29:03 -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 v2 5/7] octeon_ep_vf: Fix null dereferences to IQ/OQ pointers Date: Thu, 7 Nov 2024 05:28:44 -0800 Message-ID: <20241107132846.1118835-6-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241107132846.1118835-1-srasheed@marvell.com> References: <20241107132846.1118835-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: EvKLcglebSe3BXe5zh0_bAfKslgJn85u X-Proofpoint-ORIG-GUID: EvKLcglebSe3BXe5zh0_bAfKslgJn85u 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. Signed-off-by: Shinas Rasheed --- V2: - 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 Thu Nov 7 13:28:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13866496 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 73EE221315C; Thu, 7 Nov 2024 13:29:19 +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=1730986161; cv=none; b=iKhwCL8lgsrBCb15LvTkuoCjQ+w4kuZQA4X01JmBwjixHN138hgHtMyzu0OXkdWZYnLaI/G3ERf1l+hXtq/M5h+PFfGytFdcycEeRSJPs070TZomUMYtbEVJhWb4XI6by+5o1lRgOL7UaS8he9ooknDePgZ2+bJfEH5U8nJVBRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986161; c=relaxed/simple; bh=gEXNZK8tjMvX7CHlupLMzdGKQIiDVQ2/WoObNxWhKKE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q8TIWM+ifHcZr8c81Bf3lzTGX2ulDH1XWsO57cfYrgBgmz7GjD97QoOXO9Ytd8h6OIunST+S4yCXLAN/2onECEyDm81CrMSIO7youfm2+Pto55aGryRxYhrf83SLWxUuJ/qv76NdJxkagC5twhcwy1ue1/jsZ2lM6jQp/5bm5Qs= 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=GoIynWSD; 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="GoIynWSD" 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 4A7B7P6S012398; Thu, 7 Nov 2024 05:29:07 -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=A EvaILl35UUDiYvFEYmOSSbJIfTyuAoaQslrCVG6AZs=; b=GoIynWSDNisqeaiLw kacEyox7cUwx8XVo524f3HjyopKH6t/V2vvhclV2NOJ+USnvvM/kXph7W9o6wjTF PmQRtWwMIgE9zEBb1/2lGcegVqOZSooYnMlo9J9QJhrqbN5WCeGIb94m+CE3y/1s Vjb4ea3dcBEV7W65pdsNrs2J2V5/jgOGD8dT/IbfOd8+WCztr0aIY8TPyUrfBEYM L9fzQMrgHOLZ9tzluHbaDODyrnz3bSORjkqcFwXA4PVLuaL3qjDjP1QIvPbIXUwn //WnDRAOIyHuXNiDr2WwDCqAobEjlAEDAb38brfvZvntryqopa9tg6u0eDk3aCQ5 BsgeQ== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42rvcw096a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 05:29:07 -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 05:29:05 -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 05:29:05 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 0132A3F708C; Thu, 7 Nov 2024 05:29:04 -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 v2 6/7] octeon_ep_vf: add protective null checks in napi callbacks for cn9k cards Date: Thu, 7 Nov 2024 05:28:45 -0800 Message-ID: <20241107132846.1118835-7-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241107132846.1118835-1-srasheed@marvell.com> References: <20241107132846.1118835-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: 1FVwNhN7IngaKerpmRZQ2QoaIz0tsNdb X-Proofpoint-GUID: 1FVwNhN7IngaKerpmRZQ2QoaIz0tsNdb 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. Signed-off-by: Shinas Rasheed --- V2: - 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 Thu Nov 7 13:28:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 13866497 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 BC2DF2139B0; Thu, 7 Nov 2024 13:29:19 +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=1730986161; cv=none; b=R+NmT2an8Lt/f3OOnSXBLYm7w4uLL+IHGfRm2UI7SXQ1qvYdPBK8z0Ai3LYwX0xZC3mPYakUWyafTqYpe4lt32wdsJYpR3JLAq8e54Z6z+TG7o4KMyZ3+YsF9QmeI8ZF/kIhLpVsh31wMNItI/BPUpz4tLZ7L04AtSrG+hCcN7c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730986161; c=relaxed/simple; bh=UteYyRqBVzx41RyXLNG7R8RzkZ55eV9MbHRlmgYYDNE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IfpzYVB5oRyzbyZbbaQvZIYGgRjXEejJ7ayQvHlQZS067ry5gxsY86iNyasHbKIZ5r6lFEHOO4BmBcthzniuybdX08A5dwuIgdC/1hfQRYeKFeuAmIMyEsuoQYy4W7oTQ+40jfzmXSLMqh8aeHbsPi7gJ7v5qtS7bCK7mwOH6+0= 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=bw+7nugT; 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="bw+7nugT" 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 4A7B7P6T012398; Thu, 7 Nov 2024 05:29:07 -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=A 2SJ3lNwk8rdWi5O5a5QPSu0QRkK5EV7/gAESWkOe8A=; b=bw+7nugTtVZ5exyBI M3hkB8fbHeryL6/0eAXs+nARnrkr3UdYUlH7d2v5XKzyMVrM/qciLHeOc2PHFzKP FpcCi0ZMNUutfnl8cGOsbw4lAwajv1oSwAHrA7Ox/4qbQLuj/6sePKYCeCWS1ucj i9jTjaXpwRDza2IXbS1ijId9tPAVHk0ukK97lmHc589c37iK6l20H+LWElCmISUq QESdrEgafWwnU9ZF1IfqJFuqSmjv2C3p3nmYhkuFXOCsq8rBLMMELELsPdnEIHF3 1+xJQ1cAlVW04fB1Aj/l7stTBwCK2iLwiQJ8NXuEsZKfMDSYZDKH0DzgS8/tpFfV y/CcA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 42rvcw096a-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 07 Nov 2024 05:29:07 -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 05:29:06 -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 05:29:06 -0800 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 8928A3F708C; Thu, 7 Nov 2024 05:29:06 -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 v2 7/7] octeon_ep_vf: add protective null checks in napi callbacks for cnxk cards Date: Thu, 7 Nov 2024 05:28:46 -0800 Message-ID: <20241107132846.1118835-8-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241107132846.1118835-1-srasheed@marvell.com> References: <20241107132846.1118835-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: eokCgqP0r7EuTpftq0Dbm8HBogVUr_Tc X-Proofpoint-GUID: eokCgqP0r7EuTpftq0Dbm8HBogVUr_Tc 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. Signed-off-by: Shinas Rasheed --- V2: - 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; }