From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 186491B17B for ; Tue, 9 Oct 2018 11:11:38 +0200 (CEST) Received: from rsa59-2-82-233-193-189.fbx.proxad.net ([82.233.193.189] helo=droids-corp.org) by mail.droids-corp.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g9o4O-0003iH-4m; Tue, 09 Oct 2018 11:12:49 +0200 Received: by droids-corp.org (sSMTP sendmail emulation); Tue, 09 Oct 2018 11:11:35 +0200 Date: Tue, 9 Oct 2018 11:11:35 +0200 From: Olivier Matz To: David Marchand Cc: Yongseok Koh , "dev@dpdk.org" , "wenzhuo.lu@intel.com" , "jingjing.wu@intel.com" , "bernard.iremonger@intel.com" Message-ID: <20181009091135.omavbr56dchdaauz@platinum> References: <20180910054547.18494-1-david.marchand@6wind.com> <20180910054547.18494-2-david.marchand@6wind.com> <66B1F5CF-996B-4454-B4A6-25C799649860@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH 1/3] mbuf: add sanity checks on segment metadata 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: Tue, 09 Oct 2018 09:11:38 -0000 Hi David, On Thu, Sep 13, 2018 at 08:55:40AM +0200, David Marchand wrote: > Hello Yongseok, > > On Tue, Sep 11, 2018 at 8:16 PM, Yongseok Koh wrote: > > > >> On Sep 9, 2018, at 10:45 PM, David Marchand wrote: > >> > >> Add some basic checks on the segments offset and length metadata: > >> always funny to have a < 0 tailroom cast to uint16_t ;-). > >> > >> Signed-off-by: David Marchand > >> --- > >> lib/librte_mbuf/rte_mbuf.c | 5 +++++ > >> 1 file changed, 5 insertions(+) > >> > >> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c > >> index e714c5a59..137a320ed 100644 > >> --- a/lib/librte_mbuf/rte_mbuf.c > >> +++ b/lib/librte_mbuf/rte_mbuf.c > >> @@ -200,6 +200,11 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) > >> pkt_len = m->pkt_len; > >> > >> do { > >> + if (m->data_off > m->buf_len) > >> + rte_panic("data offset too big in mbuf segment\n"); > >> + if ((uint32_t)m->data_off + (uint32_t)m->data_len > > >> + (uint32_t)m->buf_len) > > > > Casting to uint32_t is needed? All of the three fields are uint16_t and it would > > anyway happen because of the integer promotion rule. Right? > > Indeed, this is unnecessary. > Will send a v2 without this. You can add my ack in your v2 with this change. Thanks, Olivier