Skip to contentSkip to conversation

bus/vmbus: calcuate the correct start address for mapping ring buffer

PATCH Applied [email protected] 3 participants 3 messages Jun 12, 2020 – Jun 24, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus/vmbus: calcuate the correct start address for mapping ring buffer

From: Long Li <[email protected]>

vmbus_map_addr is used as the next start virutal address for mapping ring buffer. However it's updated based on ring_buf, which is a pointer to an address on the stack. The next ring buffer may be mapped to an unexpected address.

Fix this by calculating vmbus_map_addr based on returned virtual address.

---
 drivers/bus/vmbus/linux/vmbus_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/vmbus/linux/vmbus_uio.c +1 -1
index 5451bfd15..5dc0c47de 100644
@@ -242,7 +242,7 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev,
 	*ring_size = file_size / 2;
 	*ring_buf = mapaddr;
 
-	vmbus_map_addr = RTE_PTR_ADD(ring_buf, file_size);
+	vmbus_map_addr = RTE_PTR_ADD(mapaddr, file_size);
 	return 0;
 }
 
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Thu, 11 Jun 2020 17:48:25 -0700 [email protected] wrote:

From: Long Li <[email protected]>

vmbus_map_addr is used as the next start virutal address for mapping ring buffer. However it's updated based on ring_buf, which is a pointer to an address on the stack. The next ring buffer may be mapped to an unexpected address.

Fix this by calculating vmbus_map_addr based on returned virtual address.

Fixes 3f9277031a2e ("bus/vmbus: fix check for mmap failure")
#2 lore raw

12/06/2020 18:06, Stephen Hemminger:

Quoted 10 lines
Quoted 7 lines · On Thu, 11 Jun 2020 17:48:25 -0700 [email protected] wrote:

From: Long Li <[email protected]>

vmbus_map_addr is used as the next start virutal address for mapping ring buffer. However it's updated based on ring_buf, which is a pointer to an address on the stack. The next ring buffer may be mapped to an unexpected address.

Quoted 7 lines
Quoted 3 lines

Fix this by calculating vmbus_map_addr based on returned virtual address.

Fixes 3f9277031a2e ("bus/vmbus: fix check for mmap failure")

+Cc: [email protected]

Applied, thanks