vfio-user: validate server responses
cover vfio-user: validate server responses
This patch series fixes somes bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (5):
vfio-user: vfio_user_get_region_info: prevent buffer overflow
vfio-user: vfio_user_get_region_info: respect max_xfer_size
vfio-user: vfio_user_get_region_info: reject unreasonably short struct
vfio-user: vfio_user_get_region_info: prevent excessive malloc
vfio-user: vfio_user_device_io_get_region_info: fix capability check
hw/vfio-user/device.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
PATCH 1/5 vfio-user: vfio_user_get_region_info: prevent buffer overflow
If the vfio-user responds with a value large enough such that adding the header size to it overflows, a smaller buffer would be inadvertently allocated, leading to buffer overflow.
--- hw/vfio-user/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/vfio-user/device.c +10 -0
@@ -128,6 +128,16 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too small\n" );return -E2BIG ; } + +/* +* Ensure that size doesn't overflow, otherwise we'll allocate a much +* smaller buffer than we need. +*/ +if (__builtin_add_overflow (info->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + } +if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );return -EINVAL ;
Signature · 1 line
2.34.1
Re: [PATCH 1/5] vfio-user: vfio_user_get_region_info: prevent buffer overflow
Quoted 3 lines · Thanos Makatos
If the vfio-user responds with a value large enough such that adding the header size to it overflows, a smaller buffer would be inadvertently allocated, leading to buffer overflow.
missing Signed-off-by:
Could you please add a reference to the 'culprit' commit and
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/xyz
Quoted 15 lines
--- hw/vfio-user/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)hw/vfio-user/device.c +3
-0@@ -128,6 +128,16 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too small\n" );return -E2BIG ; } + +/* +* Ensure that size doesn't overflow, otherwise we'll allocate a much
hw/vfio-user/device.c static int vfio_user_get_region_info(VFIOUserProxy *proxy, · line 143
Quoted 10 lines
hw/vfio-user/device.c +7
-0+* smaller buffer than we need. +*/ +if (__builtin_add_overflow (info->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + } +if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );return -EINVAL ;
A bit below, we have :
size = info->argsz + sizeof(VFIOUserHdr);
msgp = g_malloc0(size);which becomes redundant now.
What vfio_user_device_io_device_feature() :
int size = sizeof(VFIOUserHdr) + feature->argsz;
VFIOUserProxy *proxy = vbasedev->proxy;
Error *local_err = NULL;
msgp = g_malloc0(size);it seems to be a problem also, isn't it ?
Thanks,
C./
RE: [PATCH 1/5] vfio-user: vfio_user_get_region_info: prevent buffer overflow
Quoted 14 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: 20 July 2026 12:29
To: Thanos Makatos <[email protected]>; qemu- [email protected]
Cc: John Levon <[email protected]>
Subject: Re: [PATCH 1/5] vfio-user:vfio_user_get_region_info: prevent buffer overflow!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 7 lines
Quoted 3 lines · Thanos Makatos
If the vfio-user responds with a value large enough such that adding the header size to it overflows, a smaller buffer would be inadvertently allocated, leading to buffer overflow.
missing Signed-off-by:
Ack.
Quoted 10 lines
Could you please add a reference to the 'culprit' commit and
Resolves: https://urldefense.proofpoint.com/v2/url?u=https-
3A__gitlab.com_qemu-2Dproject_qemu_-2D_work- 5Fitems_xyz&d=DwICaQ&c=s883GpUCOChKOHiocYtGcg&r=XTpYsh5Ps2zJvtw 6ogtti46atk736SI4vgsJiUKIyDE&m=mjg5g2qrda_HNmKBvc7lNsLxZTj6738Bm anqBM- FtRzcrheXJankx7SfTcEe8Ej4&s=9qT96IOs5ZMEA_3NCMcQh84to5GiGRWcrBX _yvCcylk&e=
Ack.
Quoted 30 lines
hw/vfio-user/device.c static int
Quoted 11 lines
--- hw/vfio-user/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)hw/vfio-user/device.c +0
-0@@ -128,6 +128,16 @@ static intvfio_user_get_region_info(VFIOUserProxy *proxy,
Quoted 6 lines
hw/vfio-user/device.c +3
-0error_printf ("vfio_user_get_region_info argsz too small\n" );return -E2BIG ; } + +/* +* Ensure that size doesn't overflow, otherwise we'll allocate a much hw/vfio-user/device.c static int vfio_user_get_region_info(VFIOUserProxy *proxy, · line 143
Quoted 10 lines
hw/vfio-user/device.c +7
-0+* smaller buffer than we need. +*/ +if (__builtin_add_overflow (info->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + } +if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );return -EINVAL ;A bit below, we have :
Quoted 4 lines
size = info->argsz + sizeof(VFIOUserHdr); msgp = g_malloc0(size);which becomes redundant now.
Right.
Quoted 11 lines
What
vfio_user_device_io_device_feature():int size = sizeof(VFIOUserHdr) + feature->argsz; VFIOUserProxy *proxy = vbasedev->proxy; Error *local_err = NULL; msgp = g_malloc0(size);it seems to be a problem also, isn't it ?
In theory yes, though feature->argsz comes from within QEMU, it's not externally provided so in practise it's safe. I'll fix it the same way though (in a follow up commit) as it's good hardening.
Quoted 6 lines
Thanks,
C./
PATCH 2/5 vfio-user: vfio_user_get_region_info: respect max_xfer_size
In reply to Thanos Makatos--- hw/vfio-user/device.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/vfio-user/device.c +4 -0
@@ -137,6 +137,10 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too large\n" );return -E2BIG ; } +if (size > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + }if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );
Signature · 1 line
2.34.1
PATCH 3/5 vfio-user: vfio_user_get_region_info: reject unreasonably short struct
In reply to Thanos MakatosWhile this isn't technically a bug, it's highly unlikely that the server wouldn't be writing an entire struct.
--- hw/vfio-user/device.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/vfio-user/device.c +5 -0
@@ -166,6 +166,11 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy, }trace_vfio_user_get_region_info (msgp->index, msgp->flags, msgp->size); +if (msgp->argsz <sizeof (*info)) { +error_printf ("vfio_user_get_region_info reply argsz too small\n" ); +return -EINVAL ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
Signature · 1 line
2.34.1
PATCH 4/5 vfio-user: vfio_user_get_region_info: prevent excessive malloc
In reply to Thanos MakatosIf the vfio-user server responds with a value larger than max_xfer_size vfio_device_get_region_info() blindly uses it in the next loop in g_realloc. An value larger than max_xfer_size is anyway rejected by the check at the beginning of vfio_user_get_region_info(), however that only happens _after_ the g_realloc, and if that value is excessively large it can cause g_realloc to fail, so check it here.
--- hw/vfio-user/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/vfio-user/device.c +10 -0
@@ -171,6 +171,16 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,return -EINVAL ; } +/* +* The server can respond with a larger argsz in the reply to request a +* larger buffer on the next iteration via vfio_device_get_region_info(). +* Reject values that would trigger an oversized realloc. +*/ +if (msgp->argsz > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info reply argsz too large\n" ); +return -E2BIG ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
Signature · 1 line
2.34.1
Re: [PATCH 4/5] vfio-user: vfio_user_get_region_info: prevent excessive malloc
Quoted 23 lines · Thanos Makatos
If the vfio-user server responds with a value larger than
max_xfer_sizevfio_device_get_region_info()blindly uses it in the next loop ing_realloc. An value larger thanmax_xfer_sizeis anyway rejected by the check at the beginning ofvfio_user_get_region_info(), however that only happens _after_ theg_realloc, and if that value is excessively large it can causeg_reallocto fail, so check it here.Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)hw/vfio-user/device.c +3
-0@@ -171,6 +171,16 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,return -EINVAL ; } +/* +* The server can respond with a larger argsz in the reply to request a +* larger buffer on the next iteration via vfio_device_get_region_info().
hw/vfio-user/device.c static int vfio_user_get_region_info(VFIOUserProxy *proxy, · line 186
Quoted 10 lines
hw/vfio-user/device.c +7
-0+* Reject values that would trigger an oversized realloc. +*/ +if (msgp->argsz > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info reply argsz too large\n" ); +return -E2BIG ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
I wonder if vfio_device_get_region_info() shouldn't also have extra protection. See below.
Thanks,
C.
hw/vfio/device.c +11 -0
@@ -28,6 +28,12 @@#include "migration/blocker.h" #include "monitor/monitor.h" #include "vfio-helpers.h" + +/* +* Upper bound on region info argsz accepted on retry. +*/ +#define VFIO_MAX_REGION_INFO_ARGSZ (64 * 1024)VFIODeviceList vfio_device_list =QLIST_HEAD_INITIALIZER (vfio_device_list);
@@ -236,6 +242,12 @@ retry:if ((*info)->argsz > argsz) { argsz = (*info)->argsz; +if (argsz >VFIO_MAX_REGION_INFO_ARGSZ ) { +error_report ("region %d argsz too large (0x%zx)" , index, argsz); +g_free (*info); + *info =NULL ; +return -E2BIG ; + } *info =g_realloc (*info, argsz);if (fd !=-1 ) {
PATCH 5/5 vfio-user: vfio_user_device_io_get_region_info: fix capability check
In reply to Thanos MakatosThe existing check for PCI capabilities misses the case where info->cap_offset == info->argsz, which results in accessing unallocated memory. Fix the comparison.
--- hw/vfio-user/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio-user/device.c +1 -1
@@ -215,7 +215,7 @@ static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev,/* cap_offset in valid area */ if ((info->flags &VFIO_REGION_INFO_FLAG_CAPS ) && - (info->cap_offset <sizeof (*info) || info->cap_offset > info->argsz)) { + (info->cap_offset <sizeof (*info) || info->cap_offset >= info->argsz)) {return -EINVAL ; }
Signature · 1 line
2.34.1
Re: [PATCH 5/5] vfio-user: vfio_user_device_io_get_region_info: fix capability check
Quoted 3 lines · Thanos Makatos
The existing check for PCI capabilities misses the case where
info->cap_offset==info->argsz, which results in accessing unallocated memory. Fix the comparison.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3865
Quoted 10 lines
Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio-user/device.c +0
-0
hw/vfio-user/device.c static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev, · line 218
Quoted 5 lines
hw/vfio-user/device.c +1
-1@@ -215,7 +215,7 @@ static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev,/* cap_offset in valid area */ if ((info->flags &VFIO_REGION_INFO_FLAG_CAPS ) && - (info->cap_offset <sizeof (*info) || info->cap_offset > info->argsz)) { + (info->cap_offset <sizeof (*info) || info->cap_offset >= info->argsz)) {
May be :
info->cap_offset + sizeof(struct vfio_info_cap_header) > info->argsz
Thisensures at least a full capability header fits.
As you wish,
Thanks,
C.
RE: [PATCH 5/5] vfio-user: vfio_user_device_io_get_region_info: fix capability check
Quoted 43 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: 20 July 2026 16:24
To: Thanos Makatos <[email protected]>; qemu- [email protected]
Cc: John Levon <[email protected]>
Subject: Re: [PATCH 5/5] vfio-user:vfio_user_device_io_get_region_info: fix capability check!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 3 lines · Thanos Makatos
The existing check for PCI capabilities misses the case where
info->cap_offset==info->argsz, which results in accessing unallocated memory. Fix the comparison.Resolves: https://urldefense.proofpoint.com/v2/url?u=https-
3A__gitlab.com_qemu-2Dproject_qemu_-2D_work- 5Fitems_3865&d=DwICaQ&c=s883GpUCOChKOHiocYtGcg&r=XTpYsh5Ps2zJvt w6ogtti46atk736SI4vgsJiUKIyDE&m=ymfe9lTc0vGYW2HEr_DjmRmWQGUdrm1 i0N03AvTE8FhtjUElAMWIYIvdChgpHQno&s=_SqHEky3tGOCSqkWRfkq_- VCQ64kwc-WS6Lblyt-vto&e=hw/vfio-user/device.c static int
Quoted 10 lines
Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio-user/device.c +0
-0@@ -215,7 +215,7 @@ static intvfio_user_device_io_get_region_info(VFIODevice *vbasedev,
hw/vfio-user/device.c static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev, · line 218
Quoted 5 lines
hw/vfio-user/device.c +1
-1/* cap_offset in valid area */ if ((info->flags &VFIO_REGION_INFO_FLAG_CAPS ) && - (info->cap_offset <sizeof (*info) || info->cap_offset > info->argsz)) { + (info->cap_offset <sizeof (*info) || info->cap_offset >= info->argsz)) {
Quoted 5 lines
May be :
info->cap_offset + sizeof(struct vfio_info_cap_header) > info->argszThisensures at least a full capability header fits.
Sure.
Quoted 7 lines
As you wish,
Thanks,
C.
v2 cover vfio-user: validate server responses
In reply to Thanos MakatosThis patch series fixes some bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (6):
vfio-user: vfio_user_get_region_info: prevent buffer overflow
vfio-user: vfio_user_get_region_info: respect max_xfer_size
vfio-user: vfio_user_get_region_info: reject unreasonably short struct
vfio-user: vfio_user_get_region_info: prevent excessive malloc
vfio-user: vfio_user_device_io_get_region_info: fix capability check
vfio-user: vfio_user_device_io_device_feature: prevent buffer overflow
hw/vfio-user/device.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-)
Changes since v1:
- added 'Resolves:' in patches 1 and 5
- added missing SOB from patch 1
- removed reassignment in patch 1
- added a new patch to address the same issue as in patch 1
Signature · 1 line
2.34.1
PATCH v2 1/6 vfio-user: vfio_user_get_region_info: prevent buffer overflow
If the vfio-user responds with a value large enough such that adding the header size to it overflows, a smaller buffer would be inadvertently allocated, leading to buffer overflow.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3867
--- hw/vfio-user/device.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
hw/vfio-user/device.c +10 -1
@@ -128,12 +128,21 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too small\n" );return -E2BIG ; } + +/* +* Ensure that size doesn't overflow, otherwise we'll allocate a much +* smaller buffer than we need. +*/ +if (__builtin_add_overflow (info->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + } +if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );return -EINVAL ; } - size = info->argsz +sizeof (VFIOUserHdr); msgp =g_malloc0 (size); vfio_user_request_msg(&msgp->hdr, VFIO_USER_DEVICE_GET_REGION_INFO,
Signature · 1 line
2.34.1
Re: [PATCH v2 1/6] vfio-user: vfio_user_get_region_info: prevent buffer overflow
Quoted 28 lines · Thanos Makatos
If the vfio-user responds with a value large enough such that adding the header size to it overflows, a smaller buffer would be inadvertently allocated, leading to buffer overflow.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3867
Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)hw/vfio-user/device.c +9
-0@@ -128,12 +128,21 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too small\n" );return -E2BIG ; } + +/* +* Ensure that size doesn't overflow, otherwise we'll allocate a much +* smaller buffer than we need. +*/ +if (__builtin_add_overflow (info->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + }
hw/vfio-user/device.c static int vfio_user_get_region_info(VFIOUserProxy *proxy, · line 148
Quoted 10 lines
hw/vfio-user/device.c +1
-1+if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );return -EINVAL ; } - size = info->argsz +sizeof (VFIOUserHdr); msgp =g_malloc0 (size); vfio_user_request_msg(&msgp->hdr, VFIO_USER_DEVICE_GET_REGION_INFO,
Thanks,
C.
PATCH v2 2/6 vfio-user: vfio_user_get_region_info: respect max_xfer_size
In reply to Thanos Makatos--- hw/vfio-user/device.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/vfio-user/device.c +4 -0
@@ -137,6 +137,10 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too large\n" );return -E2BIG ; } +if (size > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + }if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );
Signature · 1 line
2.34.1
Re: [PATCH v2 2/6] vfio-user: vfio_user_get_region_info: respect max_xfer_size
Quoted 10 lines · Thanos Makatos
Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 4 ++++ 1 file changed, 4 insertions(+)hw/vfio-user/device.c +0
-0
hw/vfio-user/device.c static int vfio_user_get_region_info(VFIOUserProxy *proxy, · line 146
Quoted 10 lines
hw/vfio-user/device.c +4
-0@@ -137,6 +137,10 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too large\n" );return -E2BIG ; } +if (size > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + }if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );
Thanks,
C.
PATCH v2 3/6 vfio-user: vfio_user_get_region_info: reject unreasonably short struct
In reply to Thanos MakatosWhile this isn't technically a bug, it's highly unlikely that the server wouldn't be writing an entire struct.
--- hw/vfio-user/device.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/vfio-user/device.c +5 -0
@@ -165,6 +165,11 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy, }trace_vfio_user_get_region_info (msgp->index, msgp->flags, msgp->size); +if (msgp->argsz <sizeof (*info)) { +error_printf ("vfio_user_get_region_info reply argsz too small\n" ); +return -EINVAL ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
Signature · 1 line
2.34.1
Re: [PATCH v2 3/6] vfio-user: vfio_user_get_region_info: reject unreasonably short struct
Quoted 14 lines · Thanos Makatos
While this isn't technically a bug, it's highly unlikely that the server wouldn't be writing an entire struct.
Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 5 +++++ 1 file changed, 5 insertions(+)hw/vfio-user/device.c +0
-0@@ -165,6 +165,11 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy, }
hw/vfio-user/device.c static int vfio_user_get_region_info(VFIOUserProxy *proxy, · line 175
Quoted 10 lines
hw/vfio-user/device.c +5
-0trace_vfio_user_get_region_info (msgp->index, msgp->flags, msgp->size); +if (msgp->argsz <sizeof (*info)) { +error_printf ("vfio_user_get_region_info reply argsz too small\n" ); +return -EINVAL ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
Thanks,
C.
PATCH v2 4/6 vfio-user: vfio_user_get_region_info: prevent excessive malloc
In reply to Thanos MakatosIf the vfio-user server responds with a value larger than max_xfer_size vfio_device_get_region_info() blindly uses it in the next loop in g_realloc. An value larger than max_xfer_size is anyway rejected by the check at the beginning of vfio_user_get_region_info(), however that only happens _after_ the g_realloc, and if that value is excessively large it can cause g_realloc to fail, so check it here.
--- hw/vfio-user/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/vfio-user/device.c +10 -0
@@ -170,6 +170,16 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,return -EINVAL ; } +/* +* The server can respond with a larger argsz in the reply to request a +* larger buffer on the next iteration via vfio_device_get_region_info(). +* Reject values that would trigger an oversized realloc. +*/ +if (msgp->argsz > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info reply argsz too large\n" ); +return -E2BIG ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
Signature · 1 line
2.34.1
Re: [PATCH v2 4/6] vfio-user: vfio_user_get_region_info: prevent excessive malloc
Quoted 23 lines · Thanos Makatos
If the vfio-user server responds with a value larger than
max_xfer_sizevfio_device_get_region_info()blindly uses it in the next loop ing_realloc. An value larger thanmax_xfer_sizeis anyway rejected by the check at the beginning ofvfio_user_get_region_info(), however that only happens _after_ theg_realloc, and if that value is excessively large it can causeg_reallocto fail, so check it here.Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)hw/vfio-user/device.c +3
-0@@ -170,6 +170,16 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,return -EINVAL ; } +/* +* The server can respond with a larger argsz in the reply to request a +* larger buffer on the next iteration via vfio_device_get_region_info().
hw/vfio-user/device.c static int vfio_user_get_region_info(VFIOUserProxy *proxy, · line 185
Quoted 10 lines
hw/vfio-user/device.c +7
-0+* Reject values that would trigger an oversized realloc. +*/ +if (msgp->argsz > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info reply argsz too large\n" ); +return -E2BIG ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
Thanks,
C.
PATCH v2 5/6 vfio-user: vfio_user_device_io_get_region_info: fix capability check
In reply to Thanos MakatosThe existing check for PCI capabilities misses the case where info->cap_offset == info->argsz, which results in accessing unallocated memory. Fix the comparison.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3865
--- hw/vfio-user/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio-user/device.c +1 -1
@@ -214,7 +214,7 @@ static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev,/* cap_offset in valid area */ if ((info->flags &VFIO_REGION_INFO_FLAG_CAPS ) && - (info->cap_offset <sizeof (*info) || info->cap_offset > info->argsz)) { + (info->cap_offset <sizeof (*info) || info->cap_offset >= info->argsz)) {return -EINVAL ; }
Signature · 1 line
2.34.1
Re: [PATCH v2 5/6] vfio-user: vfio_user_device_io_get_region_info: fix capability check
Quoted 16 lines · Thanos Makatos
The existing check for PCI capabilities misses the case where
info->cap_offset==info->argsz, which results in accessing unallocated memory. Fix the comparison.Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3865
Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio-user/device.c +0
-0
hw/vfio-user/device.c static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev, · line 220
Quoted 8 lines
hw/vfio-user/device.c +1
-1@@ -214,7 +214,7 @@ static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev,/* cap_offset in valid area */ if ((info->flags &VFIO_REGION_INFO_FLAG_CAPS ) && - (info->cap_offset <sizeof (*info) || info->cap_offset > info->argsz)) { + (info->cap_offset <sizeof (*info) || info->cap_offset >= info->argsz)) {return -EINVAL ; }
Thanks,
C.
PATCH v2 6/6 vfio-user: vfio_user_device_io_device_feature: prevent buffer overflow
In reply to Thanos MakatosThis isn't in practise a problem since feature->argsz is not externally provided, it's a good hardening step nonetheless.
--- hw/vfio-user/device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
hw/vfio-user/device.c +7 -1
@@ -79,9 +79,15 @@ vfio_user_device_io_device_feature(VFIODevice *vbasedev, struct vfio_device_feature *feature) { g_autofree VFIOUserDeviceFeature *msgp = NULL; -int size =sizeof (VFIOUserHdr) + feature->argsz;VFIOUserProxy *proxy = vbasedev->proxy;Error *local_err =NULL ; +int size; + +if (__builtin_add_overflow (feature->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_device_io_device_feature argsz too large\n" ); +return -E2BIG ; + } + msgp =g_malloc0 (size);
Signature · 1 line
2.34.1
Re: [PATCH v2 6/6] vfio-user: vfio_user_device_io_device_feature: prevent buffer overflow
Quoted 19 lines · Thanos Makatos
This isn't in practise a problem since
feature->argszis not externally provided, it's a good hardening step nonetheless.Signed-off-by Thanos Makatos <[email protected]>--- hw/vfio-user/device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)hw/vfio-user/device.c +0
-1@@ -79,9 +79,15 @@ vfio_user_device_io_device_feature(VFIODevice *vbasedev, struct vfio_device_feature *feature) { g_autofree VFIOUserDeviceFeature *msgp = NULL; -int size =sizeof (VFIOUserHdr) + feature->argsz;VFIOUserProxy *proxy = vbasedev->proxy;Error *local_err =NULL ;
hw/vfio-user/device.c vfio_user_device_io_device_feature(VFIODevice *vbasedev, · line 93
Quoted 10 lines
hw/vfio-user/device.c +7
-0+int size; + +if (__builtin_add_overflow (feature->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_device_io_device_feature argsz too large\n" ); +return -E2BIG ; + } + msgp =g_malloc0 (size);
Thanks,
C.
Re: [PATCH v2 6/6] vfio-user: vfio_user_device_io_device_feature: prevent buffer overflow
In reply to Thanos MakatosQuoted 2 lines · Thanos Makatos
This isn't in practise a problem since
feature->argszis not externally provided, it's a good hardening step nonetheless.
"In practiCe", fwiw (it's applied already).
Thanks,
/mjt
Hello Thanos,
Quoted 11 lines · Thanos Makatos
This patch series fixes some bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (6):
vfio-user:vfio_user_get_region_info: prevent buffer overflow
vfio-user:vfio_user_get_region_info: respectmax_xfer_size
vfio-user:vfio_user_get_region_info: reject unreasonably short struct
vfio-user:vfio_user_get_region_info: prevent excessive malloc
vfio-user:vfio_user_device_io_get_region_info: fix capability check
vfio-user:vfio_user_device_io_device_feature: prevent buffer overflow
Quoted 9 lines
hw/vfio-user/device.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-)Changes since v1:
- added 'Resolves:' in patches 1 and 5
- added missing SOB from patch 1
- removed reassignment in patch 1
- added a new patch to address the same issue as in patch 1
Could you please add 'Fixes:' tags ? No need to resend, just reply to the email you sent.
Thanks,
C.
Quoted 24 lines · Cédric Le Goater
Hello Thanos,
Quoted 11 lines · Thanos Makatos
This patch series fixes some bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (6):
vfio-user:vfio_user_get_region_info: prevent buffer overflow
vfio-user:vfio_user_get_region_info: respectmax_xfer_size
vfio-user:vfio_user_get_region_info: reject unreasonably short struct
vfio-user:vfio_user_get_region_info: prevent excessive malloc
vfio-user:vfio_user_device_io_get_region_info: fix capability check
vfio-user:vfio_user_device_io_device_feature: prevent buffer overflowQuoted 9 lines
hw/vfio-user/device.c| 40 +++++++++++++++++++++++++++++++++++++---1 file changed, 37 insertions(+), 3 deletions(-)Changes since v1:
- added 'Resolves:' in patches 1 and 5
- added missing SOB from patch 1
- removed reassignment in patch 1
- added a new patch to address the same issue as in patch 1
Quoted 2 lines
Could you please add 'Fixes:' tags ? No need to resend, just reply to the email you sent.
Patches 1-5 address issues introduced by:
667866d66620 ("vfio-user: implement VFIO_USER_DEVICE_GET_REGION_INFO")
Patch 6 addresses an issue introduced by:
e2358af5838d ("vfio-user: support VFIO_USER_DEVICE_FEATURE")
Also, in patch 6, the vfio_user_device_io_device_feature() code does
memcpy(feature, &msgp->argsz, feature->argsz)
without the hardening as done in region_info. That would be a good addition.
vfio_user_device_io_set_irqs() is vulnerable.
I should to send a PR this week. Please tell me if you want plan to respin soon. Or I will send v2 and we will address the rest later.
Thanks,
C.
Quoted 48 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: 21 July 2026 08:04
To: Thanos Makatos <[email protected]>; qemu- [email protected]
Cc: John Levon <[email protected]>
Subject: Re: [PATCH v2 0/6] vfio-user: validate server responses!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 15 lines · Cédric Le Goater
Hello Thanos,
Quoted 12 lines · Thanos Makatos
This patch series fixes some bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (6):
vfio-user:vfio_user_get_region_info: prevent buffer overflow
vfio-user:vfio_user_get_region_info: respectmax_xfer_size
vfio-user:vfio_user_get_region_info: reject unreasonably short struct
vfio-user:vfio_user_get_region_info: prevent excessive malloc
vfio-user:vfio_user_device_io_get_region_info: fix capability check
vfio-user:vfio_user_device_io_device_feature: prevent buffer overflow
hw/vfio-user/device.c| 40+++++++++++++++++++++++++++++++++++++---
Quoted 11 lines
Quoted 8 lines
1 file changed, 37 insertions(+), 3 deletions(-)Changes since v1:
- added 'Resolves:' in patches 1 and 5
- added missing SOB from patch 1
- removed reassignment in patch 1
- added a new patch to address the same issue as in patch 1Could you please add 'Fixes:' tags ? No need to resend, just reply to the email you sent.
Patches 1-5 address issues introduced by:
667866d66620 ("vfio-user: implement
VFIO_USER_DEVICE_GET_REGION_INFO")Patch 6 addresses an issue introduced by:
Quoted 8 lines
e2358af5838d ("vfio-user: support VFIO_USER_DEVICE_FEATURE")Also, in patch 6, the
vfio_user_device_io_device_feature()code doesmemcpy(feature, &msgp->argsz, feature->argsz)without the hardening as done in
region_info. That would be a good addition.
Added a patch.
Quoted 2 lines
vfio_user_device_io_set_irqs()is vulnerable.
Added two patches.
Quoted 4 lines
I should to send a PR this week. Please tell me if you want plan to respin soon. Or I will send v2 and we will address the rest later.
No worries I've just sent v3. I can fold all the buffer overflow patches into a single patch and all the excessive malloc patches into a single patch if you prefer, I don't mind either way.
Quoted 5 lines
Thanks,
C.
v3 cover vfio-user: validate server responses
In reply to Thanos MakatosThis patch series fixes some bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (9):
vfio-user: vfio_user_get_region_info: prevent buffer overflow
vfio-user: vfio_user_get_region_info: respect max_xfer_size
vfio-user: vfio_user_get_region_info: reject unreasonably short struct
vfio-user: vfio_user_get_region_info: prevent excessive malloc
vfio-user: vfio_user_device_io_get_region_info: fix capability check
vfio-user: vfio_user_device_io_device_feature: prevent buffer overflow
vfio-user: vfio_user_device_io_device_feature: prevent excessive
malloc
vfio-user: vfio_user_device_io_set_irqs: prevent buffer overflow
vfio-user: vfio_user_device_io_set_irqs: prevent excessive malloc
hw/vfio-user/device.c | 54 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-)
Changes since v1:
- added 'Resolves:' in patches 1 and 5
- added missing SOB from patch 1
- removed reassignment in patch 1
- added a new patch to address the same issue as in patch 1
Changes since v2:
- expanded cover letter
- added 'Fixes' tags
- improved check in patch 5
- removed extraneous new line in patch 6
- added patch 7 and 9 with same check as in patch 4
- added patch 8 with same check as in patch 6
Patches 1-5 address issues introduced by:
667866d66620 ("vfio-user: implement VFIO_USER_DEVICE_GET_REGION_INFO")
Patches 6-7 address issues introduced by:
e2358af5838d ("vfio-user: support VFIO_USER_DEVICE_FEATURE")
Patch 8-9 addresses issues introduced by:
ca1add1696 ("vfio-user: implement VFIO_USER_DEVICE_GET/SET_IRQ*")
Signature · 1 line
2.34.1
PATCH v3 1/9 vfio-user: vfio_user_get_region_info: prevent buffer overflow
If the vfio-user responds with a value large enough such that adding the header size to it overflows, a smaller buffer would be inadvertently allocated, leading to buffer overflow.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3867
--- hw/vfio-user/device.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
hw/vfio-user/device.c +10 -1
@@ -128,12 +128,21 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too small\n" );return -E2BIG ; } + +/* +* Ensure that size doesn't overflow, otherwise we'll allocate a much +* smaller buffer than we need. +*/ +if (__builtin_add_overflow (info->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + } +if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );return -EINVAL ; } - size = info->argsz +sizeof (VFIOUserHdr); msgp =g_malloc0 (size); vfio_user_request_msg(&msgp->hdr, VFIO_USER_DEVICE_GET_REGION_INFO,
Signature · 1 line
2.34.1
PATCH v3 2/9 vfio-user: vfio_user_get_region_info: respect max_xfer_size
In reply to Thanos Makatos--- hw/vfio-user/device.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/vfio-user/device.c +4 -0
@@ -137,6 +137,10 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,error_printf ("vfio_user_get_region_info argsz too large\n" );return -E2BIG ; } +if (size > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info argsz too large\n" ); +return -E2BIG ; + }if (fds !=NULL && fds->send_fds !=0 ) {error_printf ("vfio_user_get_region_info can't send FDs\n" );
Signature · 1 line
2.34.1
PATCH v3 3/9 vfio-user: vfio_user_get_region_info: reject unreasonably short struct
In reply to Thanos MakatosWhile this isn't technically a bug, it's highly unlikely that the server wouldn't be writing an entire struct.
--- hw/vfio-user/device.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/vfio-user/device.c +5 -0
@@ -165,6 +165,11 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy, }trace_vfio_user_get_region_info (msgp->index, msgp->flags, msgp->size); +if (msgp->argsz <sizeof (*info)) { +error_printf ("vfio_user_get_region_info reply argsz too small\n" ); +return -EINVAL ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
Signature · 1 line
2.34.1
PATCH v3 4/9 vfio-user: vfio_user_get_region_info: prevent excessive malloc
In reply to Thanos MakatosIf the vfio-user server responds with a value larger than max_xfer_size vfio_device_get_region_info() blindly uses it in the next loop in g_realloc. An value larger than max_xfer_size is anyway rejected by the check at the beginning of vfio_user_get_region_info(), however that only happens _after_ the g_realloc, and if that value is excessively large it can cause g_realloc to fail, so check it here.
--- hw/vfio-user/device.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/vfio-user/device.c +10 -0
@@ -170,6 +170,16 @@ static int vfio_user_get_region_info(VFIOUserProxy *proxy,return -EINVAL ; } +/* +* The server can respond with a larger argsz in the reply to request a +* larger buffer on the next iteration via vfio_device_get_region_info(). +* Reject values that would trigger an oversized realloc. +*/ +if (msgp->argsz > proxy->max_xfer_size) { +error_printf ("vfio_user_get_region_info reply argsz too large\n" ); +return -E2BIG ; + } +memcpy (info, &msgp->argsz, info->argsz);/*
Signature · 1 line
2.34.1
PATCH v3 5/9 vfio-user: vfio_user_device_io_get_region_info: fix capability check
In reply to Thanos MakatosThe existing check for PCI capabilities misses the case where info->cap_offset == info->argsz, which results in accessing unallocated memory. Fix the comparison.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3865
--- hw/vfio-user/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/vfio-user/device.c +2 -1
@@ -214,7 +214,8 @@ static int vfio_user_device_io_get_region_info(VFIODevice *vbasedev,/* cap_offset in valid area */ if ((info->flags &VFIO_REGION_INFO_FLAG_CAPS ) && - (info->cap_offset <sizeof (*info) || info->cap_offset > info->argsz)) { + (info->cap_offset <sizeof (*info) + || info->cap_offset +sizeof (struct vfio_info_cap_header ) > info->argsz)) {return -EINVAL ; }
Signature · 1 line
2.34.1
PATCH v3 6/9 vfio-user: vfio_user_device_io_device_feature: prevent buffer overflow
In reply to Thanos MakatosThis isn't in practise a problem since feature->argsz is not externally provided, it's a good hardening step nonetheless.
--- hw/vfio-user/device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
hw/vfio-user/device.c +6 -1
@@ -79,9 +79,14 @@ vfio_user_device_io_device_feature(VFIODevice *vbasedev, struct vfio_device_feature *feature) { g_autofree VFIOUserDeviceFeature *msgp = NULL; -int size =sizeof (VFIOUserHdr) + feature->argsz;VFIOUserProxy *proxy = vbasedev->proxy;Error *local_err =NULL ; +int size; + +if (__builtin_add_overflow (feature->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_device_io_device_feature argsz too large\n" ); +return -E2BIG ; + } msgp =g_malloc0 (size);
Signature · 1 line
2.34.1
PATCH v3 7/9 vfio-user: vfio_user_device_io_device_feature: prevent excessive malloc
In reply to Thanos MakatosThis isn't in practise a problem since feature->argsz is not externally provided, it's a good hardening step nonetheless.
--- hw/vfio-user/device.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/vfio-user/device.c +4 -0
@@ -87,6 +87,10 @@ vfio_user_device_io_device_feature(VFIODevice *vbasedev,error_printf ("vfio_user_device_io_device_feature argsz too large\n" );return -E2BIG ; } +if (size > proxy->max_xfer_size) { +error_printf ("vfio_user_device_io_device_feature argsz too large\n" ); +return -E2BIG ; + } msgp =g_malloc0 (size);
Signature · 1 line
2.34.1
PATCH v3 8/9 vfio-user: vfio_user_device_io_set_irqs: prevent buffer overflow
In reply to Thanos MakatosThis isn't in practise a problem since irq->argsz is not externally provided, it's a good hardening step nonetheless.
--- hw/vfio-user/device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/vfio-user/device.c +4 -1
@@ -293,7 +293,10 @@ static int vfio_user_device_io_set_irqs(VFIODevice *vbasedev,* Handle simple case */ if ((irq->flags &VFIO_IRQ_SET_DATA_EVENTFD ) ==0 ) { - size =sizeof (VFIOUserHdr) + irq->argsz; +if (__builtin_add_overflow (irq->argsz,sizeof (VFIOUserHdr), &size)) { +error_printf ("vfio_user_set_irqs argsz too large\n" ); +return -E2BIG ; + } msgp =g_malloc0 (size);vfio_user_request_msg (&msgp->hdr,VFIO_USER_DEVICE_SET_IRQS , size,0 );
Signature · 1 line
2.34.1
PATCH v3 9/9 vfio-user: vfio_user_device_io_set_irqs: prevent excessive malloc
In reply to Thanos MakatosThis isn't in practise a problem since irq->argsz is not externally provided, it's a good hardening step nonetheless.
--- hw/vfio-user/device.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/vfio-user/device.c +5 -0
@@ -297,6 +297,11 @@ static int vfio_user_device_io_set_irqs(VFIODevice *vbasedev,error_printf ("vfio_user_set_irqs argsz too large\n" );return -E2BIG ; } +if (size > proxy->max_xfer_size) { +error_printf ("vfio_user_device_io_set_irqs argsz too large\n" ); +return -E2BIG ; + } + msgp =g_malloc0 (size);vfio_user_request_msg (&msgp->hdr,VFIO_USER_DEVICE_SET_IRQS , size,0 );
Signature · 1 line
2.34.1
Quoted 33 lines · Thanos Makatos
This patch series fixes some bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (9):
vfio-user:vfio_user_get_region_info: prevent buffer overflow
vfio-user:vfio_user_get_region_info: respectmax_xfer_size
vfio-user:vfio_user_get_region_info: reject unreasonably short struct
vfio-user:vfio_user_get_region_info: prevent excessive malloc
vfio-user:vfio_user_device_io_get_region_info: fix capability check
vfio-user:vfio_user_device_io_device_feature: prevent buffer overflow
vfio-user:vfio_user_device_io_device_feature: prevent excessive
malloc
vfio-user:vfio_user_device_io_set_irqs: prevent buffer overflow
vfio-user:vfio_user_device_io_set_irqs: prevent excessive mallochw/vfio-user/device.c | 54 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-)Changes since v1:
- added 'Resolves:' in patches 1 and 5
- added missing SOB from patch 1
- removed reassignment in patch 1
- added a new patch to address the same issue as in patch 1Changes since v2:
- expanded cover letter
- added 'Fixes' tags
- improved check in patch 5
- removed extraneous new line in patch 6
- added patch 7 and 9 with same check as in patch 4
- added patch 8 with same check as in patch 6
Quoted 9 lines
Patches 1-5 address issues introduced by:
667866d66620 ("vfio-user: implement VFIO_USER_DEVICE_GET_REGION_INFO")Patches 6-7 address issues introduced by:
e2358af5838d ("vfio-user: support VFIO_USER_DEVICE_FEATURE")Patch 8-9 addresses issues introduced by:
ca1add1696 ("vfio-user: implement VFIO_USER_DEVICE_GET/SET_IRQ*")
Thanks,
C.
Quoted 11 lines · Thanos Makatos
This patch series fixes some bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (6):
vfio-user:vfio_user_get_region_info: prevent buffer overflow
vfio-user:vfio_user_get_region_info: respectmax_xfer_size
vfio-user:vfio_user_get_region_info: reject unreasonably short struct
vfio-user:vfio_user_get_region_info: prevent excessive malloc
vfio-user:vfio_user_device_io_get_region_info: fix capability check
vfio-user:vfio_user_device_io_device_feature: prevent buffer overflow
Quoted 2 lines
hw/vfio-user/device.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-)
I'm picking this patch set for the stable-11.0 branch, except of the last change which fixes a problem introduced after v11.0.0. Please let me know if I shouldn't.
Thanks,
/mjt
Quoted 26 lines
-----Original Message-----
From: Michael Tokarev <[email protected]>
Sent: 24 July 2026 09:51
To: Thanos Makatos <[email protected]>; qemu- [email protected]
Cc: John Levon <[email protected]>; [email protected]; QEMU Stable <[email protected]>
Subject: Re: [PATCH v2 0/6] vfio-user: validate server responses!-------------------------------------------------------------------|
CAUTION: External Email|-------------------------------------------------------------------!
Quoted 11 lines · Thanos Makatos
This patch series fixes some bugs where the vfio-user client doesn't properly validate information returned by the vfio-user server.
Thanos Makatos (6):
vfio-user:vfio_user_get_region_info: prevent buffer overflow
vfio-user:vfio_user_get_region_info: respectmax_xfer_size
vfio-user:vfio_user_get_region_info: reject unreasonably short struct
vfio-user:vfio_user_get_region_info: prevent excessive malloc
vfio-user:vfio_user_device_io_get_region_info: fix capability check
vfio-user:vfio_user_device_io_device_feature: prevent buffer overflow
Quoted 7 lines
Quoted 1 line
hw/vfio-user/device.c | 40+++++++++++++++++++++++++++++++++++++---
Quoted 1 line
1 file changed, 37 insertions(+), 3 deletions(-)I'm picking this patch set for the stable-11.0 branch, except of the last change which fixes a problem introduced after v11.0.0. Please let me know if I shouldn't.
Sounds good to me.
Quoted 4 lines
Thanks,
/mjt