Re: [PATCH v3 net] vsock: fix buffer size clamping order
From: Stefano Garzarella
Date: Fri Apr 10 2026 - 04:41:52 EST
On Thu, Apr 09, 2026 at 06:34:12PM +0200, Norbert Szetei wrote:
In vsock_update_buffer_size(), the buffer size was being clamped to the
maximum first, and then to the minimum. If a user sets a minimum buffer
size larger than the maximum, the minimum check overrides the maximum
check, inverting the constraint.
This breaks the intended socket memory boundaries by allowing the
vsk->buffer_size to grow beyond the configured vsk->buffer_max_size.
Fix this by checking the minimum first, and then the maximum. This
ensures the buffer size never exceeds the buffer_max_size.
Fixes: b9f2b0ffde0c ("vsock: handle buffer_size sockopts in the core")
Suggested-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
Signed-off-by: Norbert Szetei <norbert@xxxxxxxxxxxx>
---
v3:
- Added Fixes and Suggested-by tags.
net/vmw_vsock/af_vsock.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>