Skip to contentSkip to conversation

librte_eal: FreeBSD contigmem prevent possible buffer overrun during module unload.

PATCH Applied Alan Carew 3 participants 3 messages Oct 14, 2014 – Oct 20, 2014 2 messages not in the archive

lore
Share & tools
lore

Alan Carew

author
#0 lore raw

PATCH 1/1 librte_eal: FreeBSD contigmem prevent possible buffer overrun during module unload.

The maximum mount contiguous memory regions for FreeBSD is limited by RTE_CONTIGMEM_MAX_NUM_BUFS, a pointer to each region is stored in static void * contigmem_buffers[RTE_CONTIGMEM_MAX_NUM_BUFS]

A user can specify a greater amount via hw.contigmem.num_buffers, while the allocation logic will prevent this allocation from occuring the logic in contigmem_unload() will attempt to free hw.contigmem.num_buffers and an overrun occurs.

This patch limits the freeing to a maximum of RTE_CONTIGMEM_MAX_NUM_BUFS.

---
 lib/librte_eal/bsdapp/contigmem/contigmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/bsdapp/contigmem/contigmem.c +1 -1
index b71474a..b1a23fa 100644
@@ -178,7 +178,7 @@ contigmem_unload()
 	if (contigmem_eh_tag != NULL)
 		EVENTHANDLER_DEREGISTER(process_exit, contigmem_eh_tag);
 
-	for (i = 0; i < contigmem_num_buffers; i++)
+	for (i = 0; i < RTE_CONTIGMEM_MAX_NUM_BUFS; i++)
 		if (contigmem_buffers[i] != NULL)
 			contigfree(contigmem_buffers[i], contigmem_buffer_size,
 					M_CONTIGMEM);
Signature · 1 line
1.9.3
#2 lore raw
In reply to a message not in the archive
Quoted 19 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Alan Carew
Sent: Tuesday, October 14, 2014 1:19 PM
To: [email protected]
Subject: [dpdk-dev] [PATCH] librte_eal: FreeBSD contigmem prevent possible buffer overrun during module unload.

The maximum mount contiguous memory regions for FreeBSD is limited by RTE_CONTIGMEM_MAX_NUM_BUFS, a pointer to each region is stored in static void * contigmem_buffers[RTE_CONTIGMEM_MAX_NUM_BUFS]

A user can specify a greater amount via hw.contigmem.num_buffers, while the allocation logic will prevent this allocation from occuring the logic in contigmem_unload() will attempt to free hw.contigmem.num_buffers and an
overrun occurs.

Quoted 4 lines

This patch limits the freeing to a maximum of
RTE_CONTIGMEM_MAX_NUM_BUFS.

#4 lore raw
In reply to a message not in the archive
Quoted 9 lines
Quoted 9 lines

The maximum mount contiguous memory regions for FreeBSD is limited by RTE_CONTIGMEM_MAX_NUM_BUFS, a pointer to each region is stored in static void * contigmem_buffers[RTE_CONTIGMEM_MAX_NUM_BUFS]

A user can specify a greater amount via hw.contigmem.num_buffers, while the allocation logic will prevent this allocation from occuring the logic in contigmem_unload() will attempt to free hw.contigmem.num_buffers and an overrun occurs.

Quoted 6 lines
Quoted 4 lines

This patch limits the freeing to a maximum of
RTE_CONTIGMEM_MAX_NUM_BUFS.

Applied

Thanks

Signature · 1 line
Thomas