Skip to contentSkip to conversation

pdump: fix possible mbuf leak

PATCH In review Ilya Matveychikov 3 participants 5 messages Nov 9, 2017 – Nov 12, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pdump: fix possible mbuf leak

If pdump_pktmbuf_copy_data() fails it's possible to have segment leak as rte_pktmbuf_free() only handles m_dup chain but not the seg just allocated and yet not chained.

Fixes 278f9454 ("pdump: add new library for packet capture")
---
 lib/librte_pdump/rte_pdump.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_pdump/rte_pdump.c +1 -0
index 729e79a..1ca709d 100644
@@ -153,6 +153,7 @@ pdump_pktmbuf_copy(struct rte_mbuf *m, struct rte_mempool *mp)
 	do {
 		nseg++;
 		if (pdump_pktmbuf_copy_data(seg, m) < 0) {
+			if (seg != m_dup) rte_pktmbuf_free(seg);
 			rte_pktmbuf_free(m_dup);
 			return NULL;
 		}

--
2.7.4

#1 lore raw
Quoted 15 lines · Ilya Matveychikov

If pdump_pktmbuf_copy_data() fails it's possible to have segment leak as rte_pktmbuf_free() only handles m_dup chain but not the seg just allocated and yet not chained.

Fixes 278f9454 ("pdump: add new library for packet capture")
---
 lib/librte_pdump/rte_pdump.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_pdump/rte_pdump.c +0 -0
index 729e79a..1ca709d 100644

lib/librte_pdump/rte_pdump.c pdump_pktmbuf_copy(struct rte_mbuf *m, struct rte_mempool *mp) · line 156

Quoted 4 lines
lib/librte_pdump/rte_pdump.c +1 -0
@@ -153,6 +153,7 @@ pdump_pktmbuf_copy(struct rte_mbuf *m, struct rte_mempool *mp)
 	do {
 		nseg++;
 		if (pdump_pktmbuf_copy_data(seg, m) < 0) {
+			if (seg != m_dup) rte_pktmbuf_free(seg);

You can prefer rte_pktmbuf_free_seg()

Also can you please use two lines?

Quoted 6 lines
lib/librte_pdump/rte_pdump.c +0 -1
 			rte_pktmbuf_free(m_dup);
 			return NULL;
 		}
--

2.7.4

#2 lore raw

PATCH 1/4 pdump: fix possible mbuf leak

In reply to Ilya Matveychikov

If pdump_pktmbuf_copy_data() fails it's possible to have segment leak as rte_pktmbuf_free() only handles m_dup chain but not the seg just allocated and yet not chained.

Fixes 278f9454 ("pdump: add new library for packet capture")
---
 lib/librte_pdump/rte_pdump.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_pdump/rte_pdump.c +1 -0
index 729e79a..1ca709d 100644
@@ -153,6 +153,7 @@ pdump_pktmbuf_copy(struct rte_mbuf *m, struct rte_mempool *mp)
 	do {
 		nseg++;
 		if (pdump_pktmbuf_copy_data(seg, m) < 0) {
+			if (seg != m_dup) rte_pktmbuf_free(seg);
 			rte_pktmbuf_free(m_dup);
 			return NULL;
 		}
Signature · 1 line
2.7.4
#3 lore raw

PATCH 1/1 pdump: fix possible mbuf leak

In reply to Ilya Matveychikov

If pdump_pktmbuf_copy_data() fails it's possible to have segment leak as rte_pktmbuf_free() only handles m_dup chain but not the seg just allocated and yet not chained.

Fixes 278f945402c5 ("pdump: add new library for packet capture")
---
 lib/librte_pdump/rte_pdump.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_pdump/rte_pdump.c +2 -0
index e6182d35c..fec49b525 100644
@@ -153,6 +153,8 @@ pdump_pktmbuf_copy(struct rte_mbuf *m, struct rte_mempool *mp)
 	do {
 		nseg++;
 		if (pdump_pktmbuf_copy_data(seg, m) < 0) {
+			if (seg != m_dup)
+				rte_pktmbuf_free_seg(seg);
 			rte_pktmbuf_free(m_dup);
 			return NULL;
 		}
Signature · 1 line
2.14.2
#4 lore raw

10/11/2017 14:55, Ilya V. Matveychikov:

Quoted 8 lines

If pdump_pktmbuf_copy_data() fails it's possible to have segment leak as rte_pktmbuf_free() only handles m_dup chain but not the seg just allocated and yet not chained.

Fixes 278f945402c5 ("pdump: add new library for packet capture")

Applied, thanks