diff mbox series

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

Message ID 1591922905-81259-1-git-send-email-longli@linuxonhyperv.com (mailing list archive)
State Accepted, archived
Headers show
Series bus/vmbus: calcuate the correct start address for mapping ring buffer | expand

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Long Li June 12, 2020, 12:48 a.m. UTC
From: Long Li <longli@microsoft.com>

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.

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/bus/vmbus/linux/vmbus_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Hemminger June 12, 2020, 4:06 p.m. UTC | #1
On Thu, 11 Jun 2020 17:48:25 -0700
longli@linuxonhyperv.com wrote:

> From: Long Li <longli@microsoft.com>
> 
> 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.
> 
> Signed-off-by: Long Li <longli@microsoft.com>


Fixes: 3f9277031a2e ("bus/vmbus: fix check for mmap failure")
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Thomas Monjalon June 24, 2020, 11:05 p.m. UTC | #2
12/06/2020 18:06, Stephen Hemminger:
> On Thu, 11 Jun 2020 17:48:25 -0700
> longli@linuxonhyperv.com wrote:
> 
> > From: Long Li <longli@microsoft.com>
> > 
> > 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.
> > 
> > Signed-off-by: Long Li <longli@microsoft.com>
> 
> 
> Fixes: 3f9277031a2e ("bus/vmbus: fix check for mmap failure")
> Acked-by: Stephen Hemminger <stephen@networkplumber.org>

+Cc: stable@dpdk.org

Applied, thanks
diff mbox series

Patch

diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c
index 5451bfd15..5dc0c47de 100644
--- a/drivers/bus/vmbus/linux/vmbus_uio.c
+++ b/drivers/bus/vmbus/linux/vmbus_uio.c
@@ -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;
 }