mirror of
https://passt.top/passt
synced 2025-05-22 17:25:35 +02:00
vu_common: Tighten vu_packet_check_range()
This function verifies that the given packet is within the mmap()ed memory region of the vhost-user device. We can do better, however. The packet should be not only within the mmap()ed range, but specifically in the subsection of that range set aside for shared buffers, which starts at dev_region->mmap_offset within there. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
32f6212551
commit
4592719a74
1 changed files with 3 additions and 3 deletions
|
@ -37,10 +37,10 @@ int vu_packet_check_range(void *buf, const char *ptr, size_t len)
|
|||
|
||||
for (dev_region = buf; dev_region->mmap_addr; dev_region++) {
|
||||
/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
|
||||
char *m = (char *)(uintptr_t)dev_region->mmap_addr;
|
||||
char *m = (char *)(uintptr_t)dev_region->mmap_addr +
|
||||
dev_region->mmap_offset;
|
||||
|
||||
if (m <= ptr &&
|
||||
ptr + len <= m + dev_region->mmap_offset + dev_region->size)
|
||||
if (m <= ptr && ptr + len <= m + dev_region->size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue