From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: [RFC 1/2] mbuf: add a sanity check on segment metadata Date: Mon, 13 Aug 2018 18:03:45 +0200 Message-ID: <1534176226-21911-1-git-send-email-david.marchand@6wind.com> Cc: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko , Olivier Matz To: dev@dpdk.org Return-path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 9959A10A3 for ; Mon, 13 Aug 2018 18:04:25 +0200 (CEST) Received: by mail-wm0-f65.google.com with SMTP id i134-v6so806409wmf.0 for ; Mon, 13 Aug 2018 09:04:25 -0700 (PDT) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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"); nb_segs -= 1; pkt_len -= m->data_len; } while ((m = m->next) != NULL); -- 2.7.4