From dcd2a33d3c8a9ce845eb4e9e8abac0a39efe0b80 Mon Sep 17 00:00:00 2001 From: David Marchand Date: Mon, 7 Jan 2019 09:57:10 +0100 Subject: [PATCH] mbuf: add sanity checks on segment metadata 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 Signed-off-by: David Marchand Acked-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 9790b4fb1b..3bbd3f5d28 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -200,6 +200,10 @@ 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 (m->data_off + m->data_len > m->buf_len) + rte_panic("data length too big in mbuf segment\n"); nb_segs -= 1; pkt_len -= m->data_len; } while ((m = m->next) != NULL); -- 2.20.1