DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC 1/2] mbuf: add a sanity check on segment metadata
@ 2018-08-13 16:03 David Marchand
  2018-08-13 16:03 ` [dpdk-dev] [RFC 2/2] ethdev: check received mbufs sanity David Marchand
  2018-08-23  7:39 ` [dpdk-dev] [RFC 1/2] mbuf: add a sanity check on segment metadata Olivier Matz
  0 siblings, 2 replies; 5+ messages in thread
From: David Marchand @ 2018-08-13 16:03 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko, Olivier Matz

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 <david.marchand@6wind.com>
---
 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-24 10:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-13 16:03 [dpdk-dev] [RFC 1/2] mbuf: add a sanity check on segment metadata David Marchand
2018-08-13 16:03 ` [dpdk-dev] [RFC 2/2] ethdev: check received mbufs sanity David Marchand
2018-08-24 10:17   ` David Marchand
2018-08-23  7:39 ` [dpdk-dev] [RFC 1/2] mbuf: add a sanity check on segment metadata Olivier Matz
2018-08-23  7:45   ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).