Skip to content

Commit 937c783

Browse files
harshimogalapallimstsirkin
authored andcommitted
vduse: Validate vq_num in vduse_validate_config()
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 <[email protected]> Signed-off-by: Harshit Mogalapalli <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent 8193101 commit 937c783

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,9 @@ static bool vduse_validate_config(struct vduse_dev_config *config)
14401440
if (config->config_size > PAGE_SIZE)
14411441
return false;
14421442

1443+
if (config->vq_num > 0xffff)
1444+
return false;
1445+
14431446
if (!device_is_allowed(config->device_id))
14441447
return false;
14451448

0 commit comments

Comments
 (0)