This is a note to let you know that I've just added the patch titled vduse: Validate vq_num in vduse_validate_config() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: vduse-validate-vq_num-in-vduse_validate_config.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 139b1ac76679309d5ac1fbb05c175b1b9e11ec20 Author: Harshit Mogalapalli <harshit.m.mogalapalli@xxxxxxxxxx> Date: Mon Nov 28 07:57:15 2022 -0800 vduse: Validate vq_num in vduse_validate_config() [ Upstream commit 937c783aa3d8d77963ec91918d3298edb45b9161 ] Add a limit to 'config->vq_num' which is user controlled data which comes from an vduse_ioctl to prevent large memory allocations. Micheal says - This limit is somewhat arbitrary. However, currently virtio pci and ccw are limited to a 16 bit vq number. While MMIO isn't it is also isn't used with lots of VQs due to current lack of support for per-vq interrupts. Thus, the 0xffff limit on number of VQs corresponding to a 16-bit VQ number seems sufficient for now. This is found using static analysis with smatch. Suggested-by: Michael S. Tsirkin <mst@xxxxxxxxxx> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@xxxxxxxxxx> Message-Id: <20221128155717.2579992-1-harshit.m.mogalapalli@xxxxxxxxxx> Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx> Acked-by: Jason Wang <jasowang@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/vdpa/vdpa_user/vduse_dev.c b/drivers/vdpa/vdpa_user/vduse_dev.c index e7d2d5b7e125..3467c75f310a 100644 --- a/drivers/vdpa/vdpa_user/vduse_dev.c +++ b/drivers/vdpa/vdpa_user/vduse_dev.c @@ -1251,6 +1251,9 @@ static bool vduse_validate_config(struct vduse_dev_config *config) if (config->config_size > PAGE_SIZE) return false; + if (config->vq_num > 0xffff) + return false; + if (!device_is_allowed(config->device_id)) return false;