From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50074.outbound.protection.outlook.com [40.107.5.74]) by dpdk.org (Postfix) with ESMTP id 33A5F532C for ; Mon, 8 Apr 2019 13:22:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z8WqDsrBVZR1mQKbL9YIiIYULSjrcbti5KS9fqXvoxE=; b=EJA+hCuEIjwUIxyVoQFnfHyu+UK9/F0evmFSEtgZFkLVyyz+M9dyYiWYuo0+bBCX56fBsmPyVpHdi39jQ6OCpbcnPfX6it9oWWH5flTrLTSbUVH37BHUKeC+XdW3j2mUspRP6vYtJNWXXFELQU9acSsSR6H4qViF8/Tq0pwZ/yY= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6670.eurprd04.prod.outlook.com (20.179.235.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.16; Mon, 8 Apr 2019 11:22:49 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1771.016; Mon, 8 Apr 2019 11:22:49 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH 13/13] net/enetc: fix crash at high speed traffic Thread-Index: AQHU7f1lJadiaNqwv0+akGI9uRYTmg== Date: Mon, 8 Apr 2019 11:22:49 +0000 Message-ID: <1554745507-15089-14-git-send-email-g.singh@nxp.com> References: <1554745507-15089-1-git-send-email-g.singh@nxp.com> In-Reply-To: <1554745507-15089-1-git-send-email-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 1.9.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.1.67] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 20015249-ebc4-4661-ed40-08d6bc1487fd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6670; x-ms-traffictypediagnostic: VE1PR04MB6670: x-microsoft-antispam-prvs: x-forefront-prvs: 0001227049 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(136003)(376002)(39860400002)(396003)(199004)(189003)(86362001)(3846002)(6116002)(102836004)(8676002)(2616005)(186003)(68736007)(105586002)(81166006)(81156014)(72206003)(4744005)(97736004)(5660300002)(6436002)(305945005)(6486002)(14454004)(6512007)(66066001)(7736002)(106356001)(26005)(50226002)(316002)(110136005)(476003)(486006)(25786009)(2501003)(11346002)(71190400001)(256004)(52116002)(53936002)(446003)(2906002)(6506007)(99286004)(478600001)(386003)(71200400001)(8936002)(76176011)(14444005)(4326008)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6670; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: LNoWREjn6K3FRjVR/muhNGHirpDjj+h9TuXdKG7japgPeiugJEyEwXTLIhyE0AbafNjfzj1n/tXA0PzWuwlFcTuIW95L1gdLuw05bMGWMIxCBd09bAr1uldx1LFxKL68O4h3TWIwjFOdhvOaP0Oby8jd5kxWbDO+7ypIUqi0dxdSsKcv2LIS1hZGEtkFaAL4jX7QmZy9B+QTYw+g+/s2m+HMzEKY3o2bMCSRe/DwZML4N3CJ6hnlvck9bT0wWRv7BJXOBXCtloCBINl4ootpT6QbvorECT6T2Pwb/QjX5NTOy1ByRHgnFNLmZCA9xSpeop42g8FbMh8szyXYP0Nfv9RVHEfKiNYOj61nlkSM8HLlqrYcyMZODSpp+Y13YDVL0C/pwUdc290ssQLJP+gG7CeaBwm6T7r6D163/nbxxZQ= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20015249-ebc4-4661-ed40-08d6bc1487fd X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2019 11:22:49.1350 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6670 Subject: [dpdk-dev] [PATCH 13/13] net/enetc: fix crash at high speed traffic X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Apr 2019 11:22:50 -0000 On xmit side, there should be a check whether BD ring has free BDs available before transmit a packet to avoid data corruption and buffer leak issue. Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx") Cc: g.singh@nxp.com Signed-off-by: Gagandeep Singh --- drivers/net/enetc/enetc_rxtx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.= c index ed39665..baf5d27 100644 --- a/drivers/net/enetc/enetc_rxtx.c +++ b/drivers/net/enetc/enetc_rxtx.c @@ -49,11 +49,16 @@ uint16_t nb_pkts) { struct enetc_swbd *tx_swbd; - int i, start; + int i, start, bds_to_use; struct enetc_tx_bd *txbd; struct enetc_bdr *tx_ring =3D (struct enetc_bdr *)tx_queue; =20 i =3D tx_ring->next_to_use; + + bds_to_use =3D enetc_bd_unused(tx_ring); + if (bds_to_use < nb_pkts) + nb_pkts =3D bds_to_use; + start =3D 0; while (nb_pkts--) { enetc_clean_tx_ring(tx_ring); --=20 1.9.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 9EFDEA0096 for ; Mon, 8 Apr 2019 13:24:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CBD715F2C; Mon, 8 Apr 2019 13:23:16 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50074.outbound.protection.outlook.com [40.107.5.74]) by dpdk.org (Postfix) with ESMTP id 33A5F532C for ; Mon, 8 Apr 2019 13:22:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z8WqDsrBVZR1mQKbL9YIiIYULSjrcbti5KS9fqXvoxE=; b=EJA+hCuEIjwUIxyVoQFnfHyu+UK9/F0evmFSEtgZFkLVyyz+M9dyYiWYuo0+bBCX56fBsmPyVpHdi39jQ6OCpbcnPfX6it9oWWH5flTrLTSbUVH37BHUKeC+XdW3j2mUspRP6vYtJNWXXFELQU9acSsSR6H4qViF8/Tq0pwZ/yY= Received: from VE1PR04MB6365.eurprd04.prod.outlook.com (10.255.118.78) by VE1PR04MB6670.eurprd04.prod.outlook.com (20.179.235.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1771.16; Mon, 8 Apr 2019 11:22:49 +0000 Received: from VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0]) by VE1PR04MB6365.eurprd04.prod.outlook.com ([fe80::f5ad:f178:4c55:13e0%3]) with mapi id 15.20.1771.016; Mon, 8 Apr 2019 11:22:49 +0000 From: Gagandeep Singh To: "dev@dpdk.org" , "ferruh.yigit@intel.com" CC: Gagandeep Singh Thread-Topic: [PATCH 13/13] net/enetc: fix crash at high speed traffic Thread-Index: AQHU7f1lJadiaNqwv0+akGI9uRYTmg== Date: Mon, 8 Apr 2019 11:22:49 +0000 Message-ID: <1554745507-15089-14-git-send-email-g.singh@nxp.com> References: <1554745507-15089-1-git-send-email-g.singh@nxp.com> In-Reply-To: <1554745507-15089-1-git-send-email-g.singh@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR0101CA0003.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:18::13) To VE1PR04MB6365.eurprd04.prod.outlook.com (2603:10a6:803:12a::14) x-mailer: git-send-email 1.9.1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=G.Singh@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [92.120.1.67] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 20015249-ebc4-4661-ed40-08d6bc1487fd x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600139)(711020)(4605104)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VE1PR04MB6670; x-ms-traffictypediagnostic: VE1PR04MB6670: x-microsoft-antispam-prvs: x-forefront-prvs: 0001227049 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(366004)(136003)(376002)(39860400002)(396003)(199004)(189003)(86362001)(3846002)(6116002)(102836004)(8676002)(2616005)(186003)(68736007)(105586002)(81166006)(81156014)(72206003)(4744005)(97736004)(5660300002)(6436002)(305945005)(6486002)(14454004)(6512007)(66066001)(7736002)(106356001)(26005)(50226002)(316002)(110136005)(476003)(486006)(25786009)(2501003)(11346002)(71190400001)(256004)(52116002)(53936002)(446003)(2906002)(6506007)(99286004)(478600001)(386003)(71200400001)(8936002)(76176011)(14444005)(4326008)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR04MB6670; H:VE1PR04MB6365.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: LNoWREjn6K3FRjVR/muhNGHirpDjj+h9TuXdKG7japgPeiugJEyEwXTLIhyE0AbafNjfzj1n/tXA0PzWuwlFcTuIW95L1gdLuw05bMGWMIxCBd09bAr1uldx1LFxKL68O4h3TWIwjFOdhvOaP0Oby8jd5kxWbDO+7ypIUqi0dxdSsKcv2LIS1hZGEtkFaAL4jX7QmZy9B+QTYw+g+/s2m+HMzEKY3o2bMCSRe/DwZML4N3CJ6hnlvck9bT0wWRv7BJXOBXCtloCBINl4ootpT6QbvorECT6T2Pwb/QjX5NTOy1ByRHgnFNLmZCA9xSpeop42g8FbMh8szyXYP0Nfv9RVHEfKiNYOj61nlkSM8HLlqrYcyMZODSpp+Y13YDVL0C/pwUdc290ssQLJP+gG7CeaBwm6T7r6D163/nbxxZQ= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20015249-ebc4-4661-ed40-08d6bc1487fd X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Apr 2019 11:22:49.1350 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6670 Subject: [dpdk-dev] [PATCH 13/13] net/enetc: fix crash at high speed traffic X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190408112249.UpZcfwmcopCEchumWKKMYfFj8cyiy_4pg2-0D6-H64o@z> On xmit side, there should be a check whether BD ring has free BDs available before transmit a packet to avoid data corruption and buffer leak issue. Fixes: 469c6111a799 ("net/enetc: enable Rx and Tx") Cc: g.singh@nxp.com Signed-off-by: Gagandeep Singh --- drivers/net/enetc/enetc_rxtx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/enetc/enetc_rxtx.c b/drivers/net/enetc/enetc_rxtx.= c index ed39665..baf5d27 100644 --- a/drivers/net/enetc/enetc_rxtx.c +++ b/drivers/net/enetc/enetc_rxtx.c @@ -49,11 +49,16 @@ uint16_t nb_pkts) { struct enetc_swbd *tx_swbd; - int i, start; + int i, start, bds_to_use; struct enetc_tx_bd *txbd; struct enetc_bdr *tx_ring =3D (struct enetc_bdr *)tx_queue; =20 i =3D tx_ring->next_to_use; + + bds_to_use =3D enetc_bd_unused(tx_ring); + if (bds_to_use < nb_pkts) + nb_pkts =3D bds_to_use; + start =3D 0; while (nb_pkts--) { enetc_clean_tx_ring(tx_ring); --=20 1.9.1