[SRU][N][PATCH 1/1] vfio/platform: check the bounds of read/write syscalls
Cengiz Can
cengiz.can at canonical.com
Tue Sep 8 19:42:58 UTC 2026
From: Alex Williamson <alex.williamson at redhat.com>
count and offset are passed from user space and not checked, only
offset is capped to 40 bits, which can be used to read/write out of
bounds of the device.
Fixes: 6e3f26456009 (“vfio/platform: read and write support for the device fd”)
Cc: stable at vger.kernel.org
Reported-by: Mostafa Saleh <smostafa at google.com>
Reviewed-by: Eric Auger <eric.auger at redhat.com>
Reviewed-by: Mostafa Saleh <smostafa at google.com>
Tested-by: Mostafa Saleh <smostafa at google.com>
Signed-off-by: Alex Williamson <alex.williamson at redhat.com>
(cherry picked from commit ce9ff21ea89d191e477a02ad7eabf4f996b80a69)
CVE-2025-21687
Assisted-by: kybele:claude-opus-4.8
Signed-off-by: Cengiz Can <cengiz.can at canonical.com>
---
drivers/vfio/platform/vfio_platform_common.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/vfio/platform/vfio_platform_common.c b/drivers/vfio/platform/vfio_platform_common.c
index e53757d1d095..3bf1043cd795 100644
--- a/drivers/vfio/platform/vfio_platform_common.c
+++ b/drivers/vfio/platform/vfio_platform_common.c
@@ -388,6 +388,11 @@ static ssize_t vfio_platform_read_mmio(struct vfio_platform_region *reg,
{
unsigned int done = 0;
+ if (off >= reg->size)
+ return -EINVAL;
+
+ count = min_t(size_t, count, reg->size - off);
+
if (!reg->ioaddr) {
reg->ioaddr =
ioremap(reg->addr, reg->size);
@@ -467,6 +472,11 @@ static ssize_t vfio_platform_write_mmio(struct vfio_platform_region *reg,
{
unsigned int done = 0;
+ if (off >= reg->size)
+ return -EINVAL;
+
+ count = min_t(size_t, count, reg->size - off);
+
if (!reg->ioaddr) {
reg->ioaddr =
ioremap(reg->addr, reg->size);
--
2.53.0
More information about the kernel-team
mailing list