From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2E8E7A04C0; Tue, 29 Sep 2020 05:01:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7C7CD1BF91; Tue, 29 Sep 2020 05:01:47 +0200 (CEST) Received: from huawei.com (szxga02-in.huawei.com [45.249.212.188]) by dpdk.org (Postfix) with ESMTP id 8A6DA1252 for ; Tue, 29 Sep 2020 05:01:46 +0200 (CEST) Received: from DGGEMM404-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 4FD6A327C42BBE2D965A; Tue, 29 Sep 2020 11:01:44 +0800 (CST) Received: from DGGEMM423-HUB.china.huawei.com (10.1.198.40) by DGGEMM404-HUB.china.huawei.com (10.3.20.212) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 29 Sep 2020 11:01:43 +0800 Received: from DGGEMM533-MBX.china.huawei.com ([169.254.5.102]) by dggemm423-hub.china.huawei.com ([10.1.198.40]) with mapi id 14.03.0487.000; Tue, 29 Sep 2020 11:01:36 +0800 From: wangyunjian To: Chas Williams <3chas3@gmail.com>, "dev@dpdk.org" CC: "olivier.matz@6wind.com" , xudingke Thread-Topic: [dpdk-dev] [PATCH] net: check that seg is valid before dereference Thread-Index: AQHWlaymRV/Zu4jmv0e/AOKXmpKRXql+7Xug Date: Tue, 29 Sep 2020 03:01:36 +0000 Message-ID: <34EFBCA9F01B0748BEB6B629CE643AE60DA7D32B@DGGEMM533-MBX.china.huawei.com> References: <20200928153219.285343-1-3chas3@gmail.com> In-Reply-To: <20200928153219.285343-1-3chas3@gmail.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.185.168] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH] net: check that seg is valid before dereference 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" > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Chas Williams > Sent: Monday, September 28, 2020 11:32 PM > To: dev@dpdk.org > Cc: olivier.matz@6wind.com; Chas Williams <3chas3@gmail.com> > Subject: [dpdk-dev] [PATCH] net: check that seg is valid before dereferen= ce >=20 > If the overall pkt_len and segment lengths are out of agreement, it is po= ssible > for the seg to be NULL after the loop. Add assert to check this condition= in > debug builds. >=20 > Fixes: c442fed81bb9 ("net: add function to calculate checksum in mbuf") >=20 > Signed-off-by: Chas Williams <3chas3@gmail.com> > --- > lib/librte_net/rte_ip.h | 1 + > 1 file changed, 1 insertion(+) >=20 > diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index > fcd1eb342..6b3e4cdda 100644 > --- a/lib/librte_net/rte_ip.h > +++ b/lib/librte_net/rte_ip.h > @@ -225,6 +225,7 @@ rte_raw_cksum_mbuf(const struct rte_mbuf *m, > uint32_t off, uint32_t len, > break; > off -=3D seglen; > } > + RTE_ASSERT(seg !=3D NULL); Is it better to return an error code? > seglen -=3D off; > buf =3D rte_pktmbuf_mtod_offset(seg, const char *, off); > if (seglen >=3D len) { > -- > 2.26.2