From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-f68.google.com (mail-yw1-f68.google.com [209.85.161.68]) by dpdk.org (Postfix) with ESMTP id B25534C99 for ; Thu, 23 Aug 2018 09:45:52 +0200 (CEST) Received: by mail-yw1-f68.google.com with SMTP id l189-v6so1623178ywb.10 for ; Thu, 23 Aug 2018 00:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=+SjOcM1bp7lVtispSrQBmL+dBpTgkh786aXKS2nT14s=; b=TckFy83jAXHEWVfMq8AP2qwUMRzhwUETh7TLfdeoZe2S75Sdo8YqYbAAdIqqKoF+Sn pc+Vd1kH1xwMoFOUCcfa6KdEup66yQc3ORwTogaZCP5QtUioVAl5zw5qNCwZZ+RvxCeO COTgp4lM7YY7w+rX3HyfcuYeeYp+g9HDBFjQHTZLDrxragob6XDL2zWBPFNnE0B0IdlL gM6XieRtBdLrlrqxlCRZZvYVOwBUbxmxh9BQoQLWcheiQP6NvQQkZU42mqmOxylHi6H3 5w9vVcpZySHiI7J6kmQQTC8r2NyzAAknEUwrkMd+MZklZMMNg10IGmpLdzxXivrB2oHE MuMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=+SjOcM1bp7lVtispSrQBmL+dBpTgkh786aXKS2nT14s=; b=XlWY49X9P850vLAo+v9XyEPEF8MF3K7AxNvoZ8+GD18kzXI8y+xZuNKouZsViVZcBU F37m9d6VFNuOA2WfkTb+F1geiooYZZYXW0K68BuPLF4VNbG75u/JVEhqlW2W6Z1xGLEI F+QS5ylPW1BVFUxZIoYFLbZPpiptYYYipSsMNm8pA9D9UauCoKY3SxhxxGDz2ApX70SQ nZlAC0RTZhFNUS93fsCk5PDuruVbhVgwWE1LI3jXtZsgqFa2rVMq8xtY2ep1IgA5XUEh vCJceBqZPDAu2TAnZIciKYwoUkHhXT1l495lhUSWsb5//sPPBFkn9OPTs2yoKdmVgM6q RTkw== X-Gm-Message-State: APzg51AqMJWE5jcPAHY8PK9o6yEmvQD5VcRwyrEwOBy6xeZ5wU9cD73Q 8nspk43QpuTcqlJJA0JZ2+rwq1MSX82aC2jOEdKwkw== X-Google-Smtp-Source: ANB0VdaijLp+RZd/KoMOG/YfikP8Zm9EUrgNcuBPP8RA5kx+3w5ueIm9Wmq1zE6eoHqmBDAp8W5dzgF8n+t7eiSL6EA= X-Received: by 2002:a81:374c:: with SMTP id e73-v6mr2044303ywa.278.1535010352040; Thu, 23 Aug 2018 00:45:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:d809:0:0:0:0:0 with HTTP; Thu, 23 Aug 2018 00:45:31 -0700 (PDT) In-Reply-To: <20180823073942.qnyk3jwqecm6wk3v@platinum> References: <1534176226-21911-1-git-send-email-david.marchand@6wind.com> <20180823073942.qnyk3jwqecm6wk3v@platinum> From: David Marchand Date: Thu, 23 Aug 2018 09:45:31 +0200 Message-ID: To: Olivier Matz Cc: dev@dpdk.org, Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [RFC 1/2] mbuf: add a sanity check 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: Thu, 23 Aug 2018 07:45:52 -0000 On Thu, Aug 23, 2018 at 9:39 AM, Olivier Matz wrote: > On Mon, Aug 13, 2018 at 06:03:45PM +0200, David Marchand wrote: >> Add some basic check 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 | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c >> index e714c5a..7eeef12 100644 >> --- a/lib/librte_mbuf/rte_mbuf.c >> +++ b/lib/librte_mbuf/rte_mbuf.c >> @@ -200,6 +200,8 @@ rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) >> pkt_len = m->pkt_len; >> >> do { >> + if (m->data_off + m->data_len > m->buf_len) >> + rte_panic("bad segment metadata\n"); > > What about spliting the test into two? This would help to clarify > the error messages. I also suggest add casts to uint32 to ensure > that there is no overflow. Sure, will do. -- David Marchand