Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp429639rwr; Wed, 3 May 2023 00:15:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ74oEaGP9NdI+tFSXCqpuui5+gLp79b2YSySqBXKCW2PtHuGbIAeV4Vtdpl+wy6ezKTbWEa X-Received: by 2002:a05:6a21:78aa:b0:f2:b6d6:e3fa with SMTP id bf42-20020a056a2178aa00b000f2b6d6e3famr21003491pzc.38.1683098118030; Wed, 03 May 2023 00:15:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683098118; cv=none; d=google.com; s=arc-20160816; b=N1nyLKWoWyLgflRobdvpKnTfvTM2f2bYbDFtTWhV9BCKJZfVX8/WK56WH7L2BZmszE Q/LMycKUWTfmLApJgVySYmxkkcH33LgVKq8lDf1qqWHXuU4tB0+vE01anvezQQygKbYs a9EIt75q6W6PYQRzVQRB1Z+iaPHlah3GuaBmWyH149pKI/bjOyiD+IjjFcR7kkF1OZWd uT16GyP2ba6J2gkysauRKN1AmT8lCum915xn6GFr3ai/mdYh4sUzRozXXIExgcGjbuv9 avTZfPln5oiiWgKQKCQ++SKY5p31CiHADQsRgJdNbfIHwH9HfbqGBF0UolbMSgM0WI9i Hc6A== 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=ZlSrOLdBRNFKeLr7Ip+8w0eprD3EHpIspAhBFP9tXz8=; b=U4XfFwP7nlGktkEySm7fC7F4i+TwU4L/UOv3K1IeCJtr2dKLF8wbif6fgBvovnKHoj NwNxGMdbD7RW981tTJZwUnDPtyqwwlj/nwWybIsUcRjorRjuDWZbJCe+k7C+VTjPbVGD wfSl8qJQ19Gr1a9L5dj9CxHoJ3yLEyyeG12FZ/dL1tWEkqJuHbBjJx6ipJlPEJXK5zkD jZEEWTzp5D4sSmt9Wpgf0hhphYnMjFzXL/vNnDn05vktbzGHDvvYysl0BkrjIYezWc8r pcz6YPr9O6IQC2qywEq932wW3XLIniWGUSxM7f8/uycSe4JpTQ9Tg9uqsp8pu8UbwsxL tGwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=aAOHEL2R; 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 s14-20020a17090aad8e00b0024df2dbc7afsi7830565pjq.52.2023.05.03.00.14.56; Wed, 03 May 2023 00:15:18 -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=aAOHEL2R; 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 S229691AbjECHKp (ORCPT + 99 others); Wed, 3 May 2023 03:10:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbjECHKe (ORCPT ); Wed, 3 May 2023 03:10:34 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF2C4223; Wed, 3 May 2023 00:10:29 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3436AsGR004505; Wed, 3 May 2023 00:10:17 -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=ZlSrOLdBRNFKeLr7Ip+8w0eprD3EHpIspAhBFP9tXz8=; b=aAOHEL2RA4pToiPZJEbz48+w4sePaoB8HNfrvK2p+ABqkIORQ2CKkaT9PHP2T0apZk0a hQD5G99S+0iaOy5+TMa+myfvfGnTo4hARGXBdjJfr/uqwJp3ilQyp7N/P4QPnA1guCHn BoMMotlCysJhpdc3xplRIrvHTzP2ovfqqla58LUmZJhKYfXgFToFvWgFlfljzd1IgUVP TiyrX/vEHDl+7fvZMmKXUHDhAVUaPj0wNwiUYO+qsNZL72/wAEsvzfl84SdfWfiQ3eMI +cnZLY0FW4LpJGoY72NVTTyKe/gKfEZFjAlkMAeg+krcX20Fe0l5SJSoaEyhO6pzpCes gQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3q92rp3m7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 03 May 2023 00:10:17 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 3 May 2023 00:10:15 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 3 May 2023 00:10:15 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id 4379A3F7082; Wed, 3 May 2023 00:10:11 -0700 (PDT) From: Sai Krishna To: , , , , , , , , , , , , , CC: Sai Krishna Subject: [net PATCH v5 05/11] octeontx2-af: Add validation for lmac type Date: Wed, 3 May 2023 12:39:38 +0530 Message-ID: <20230503070944.960190-6-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230503070944.960190-1-saikrishnag@marvell.com> References: <20230503070944.960190-1-saikrishnag@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: mugEdnywIu1dptctzCkIXq5IiRZSHBAL X-Proofpoint-GUID: mugEdnywIu1dptctzCkIXq5IiRZSHBAL 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-05-03_04,2023-04-27_01,2023-02-09_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 Reviewed-by: Simon Horman --- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c index 724df6398bbe..bd77152bb8d7 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/cgx.c @@ -1231,6 +1231,14 @@ 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); + strncpy(linfo->lmac_type, "Unknown", LMACTYPE_STR_LEN - 1); + return; + } + lmac_string = cgx_lmactype_string[linfo->lmac_type_id]; strncpy(linfo->lmac_type, lmac_string, LMACTYPE_STR_LEN - 1); } -- 2.25.1