Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp928031rwl; Wed, 29 Mar 2023 10:10:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ZzmHDLEpMUwE7zUPXppqLFmzDN2YXwJwOZBk/IdQS23iTPmV3x8bY0QZyiBkZxBQSTsOJ1 X-Received: by 2002:a17:906:13cd:b0:931:2306:f363 with SMTP id g13-20020a17090613cd00b009312306f363mr21561966ejc.21.1680109841135; Wed, 29 Mar 2023 10:10:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680109841; cv=none; d=google.com; s=arc-20160816; b=fmeAfSdG2xfep7l9M+Ul3R6jLYTvxqzGm0DcB/qFZho+Wrnf+jZgqZUteEAHWX3ZqF JuRnvgpm4j4WYJ5md37W8ksDR4otFDgWlpFqjfCCo12DB6pFPKEe+A+Z4zzNSoEQH81I epjDT7z755FuhNRFtwR4ykVCUWY2gY8wqwaZZi40KTcmZa0RuCW5mL6PmgNNe0UFftt8 ADnCXDvjUtZNr5N3HECiVYKAotGVq8wYhnjs0ED+lW0GAbx1CVt3d+5+e0bBsV45MEH/ xf3n6QBpa1COAMZgsU2siFgCjHsTzI1Y9gsWktw6YwKBd96RxU+G/W8mqKKNCGJNJVCY 8IIg== 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=SevBo/8NLy8omUrK7Ko8zJUiwLHjqRUoBBbbxngTk/s=; b=KfQddxIzOq7mJmSY3mDsA6S/HhY06RmtXFVFpR7Ix2ykq9hXDd6I0TezZHQyukzl8o 0MWdGq4nhx8A3vVw6PT7+I52QXHc5X0y1x3jT9KxySbe9rWqkXzlkjSVSKwed6SCl7R6 ZX1eJR7tvrs3VY/nfJgocvHwO1j+IldFCzCShabJu/0H02qfoX5ajREnZbS7ffTG4Sjz R4nCH4y0ZHBWhNVI0QamV0ISbgEmNPbECEVp+9KL7JWA2WHCEHlfIt0yg1oJ47HouEWH 2WK1flLvfiL+7O7NUoRx4FyiqYmXJBZHwsUbMv6zcd54A9L8LmXn0sY3nRQPIPIIN0Hq 3sWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=PTfCeFhA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a1709064ec700b008cc8a6fea26si33065596ejv.561.2023.03.29.10.10.16; Wed, 29 Mar 2023 10:10:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=PTfCeFhA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231424AbjC2RH4 (ORCPT + 99 others); Wed, 29 Mar 2023 13:07:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231264AbjC2RHT (ORCPT ); Wed, 29 Mar 2023 13:07:19 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F9EE6595; Wed, 29 Mar 2023 10:07:02 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32TDTRlT008941; Wed, 29 Mar 2023 10:06:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=SevBo/8NLy8omUrK7Ko8zJUiwLHjqRUoBBbbxngTk/s=; b=PTfCeFhAsE/D/YZ6NVD72EYBSRwFvnwAntN5DZoTosiJqWfVV3ueF+dlc3J/Mo8/Z/0G HBcdngMLyDVly6qqHzfY48o2VbeHMHAQiNjhXn6aMYDkcBXhtOAaAcgzN2rbvbwxVQHZ zww+cE5FJNkMH0pLX91o6YkAmHtCuwCzy8WwjUeSzVQM7Puif/Hf9pA/1jUMtGY41n2J Rrrb+Lm6chl+42VgXmUhEp/KykXe1NGBJFFj/136lLi9u7oInOG3gb6Txr2mUMEZRlXP N+bwz8ot/nDCpCAX5ZdWMN4eR2iCjmWymmVHG+G9V9AXvnv3vxJmlxjsFG0FYO5LbOjB +Q== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pmdqhkqth-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 10:06:56 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 29 Mar 2023 10:06:54 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 29 Mar 2023 10:06:54 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id 2CBD83F704E; Wed, 29 Mar 2023 10:06:50 -0700 (PDT) From: Sai Krishna To: , , , , , , , CC: Hariprasad Kelam , Sai Krishna Subject: [net PATCH 3/7] octeontx2-af: Add validation for lmac type Date: Wed, 29 Mar 2023 22:36:15 +0530 Message-ID: <20230329170619.183064-4-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230329170619.183064-1-saikrishnag@marvell.com> References: <20230329170619.183064-1-saikrishnag@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: ncOhxfqaLWDNXtRqsc6MJAYwPmDd8WWQ X-Proofpoint-GUID: ncOhxfqaLWDNXtRqsc6MJAYwPmDd8WWQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_10,2023-03-28_02,2023-02-09_01 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hariprasad Kelam Upon physical link change, firmware reports to the kernel about the change along with the details like speed, lmac_type_id, etc. Kernel derives lmac_type based on lmac_type_id received from firmware. In a few scenarios, firmware returns an invalid lmac_type_id, which is resulting in below kernel panic. This patch adds the missing validation of the lmac_type_id field. Internal error: Oops: 96000005 [#1] PREEMPT SMP [ 35.321595] Modules linked in: [ 35.328982] CPU: 0 PID: 31 Comm: kworker/0:1 Not tainted 5.4.210-g2e3169d8e1bc-dirty #17 [ 35.337014] Hardware name: Marvell CN103XX board (DT) [ 35.344297] Workqueue: events work_for_cpu_fn [ 35.352730] pstate: 40400089 (nZcv daIf +PAN -UAO) [ 35.360267] pc : strncpy+0x10/0x30 [ 35.366595] lr : cgx_link_change_handler+0x90/0x180 Fixes: 61071a871ea6 ("octeontx2-af: Forward CGX link notifications to PFs") Signed-off-by: Hariprasad Kelam Signed-off-by: Sunil Kovvuri Goutham Signed-off-by: Sai Krishna --- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c index 724df6398bbe..180aa84cf1c3 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -1231,6 +1231,13 @@ static inline void link_status_user_format(u64 lstat, linfo->an = FIELD_GET(RESP_LINKSTAT_AN, lstat); linfo->fec = FIELD_GET(RESP_LINKSTAT_FEC, lstat); linfo->lmac_type_id = FIELD_GET(RESP_LINKSTAT_LMAC_TYPE, lstat); + + if (linfo->lmac_type_id >= LMAC_MODE_MAX) { + dev_err(&cgx->pdev->dev, "Unknown lmac_type_id %d reported by firmware on cgx port%d:%d", + linfo->lmac_type_id, cgx->cgx_id, lmac_id); + return; + } + lmac_string = cgx_lmactype_string[linfo->lmac_type_id]; strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1); } -- 2.25.1