Skip to content

Commit ff9f9c6

Browse files
Dan Carpentermstsirkin
authored andcommitted
vduse: fix memory corruption in vduse_dev_ioctl()
The "config.offset" comes from the user. There needs to a check to prevent it being out of bounds. The "config.offset" and "dev->config_size" variables are both type u32. So if the offset if out of bounds then the "dev->config_size - config.offset" subtraction results in a very high u32 value. The out of bounds offset can result in memory corruption. Fixes: c8a6153 ("vduse: Introduce VDUSE - vDPA Device in Userspace") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/20211208103307.GA3778@kili Signed-off-by: Michael S. Tsirkin <[email protected]> Cc: [email protected]
1 parent 0fcfb00 commit ff9f9c6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/vdpa/vdpa_user/vduse_dev.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,8 @@ static long vduse_dev_ioctl(struct file *file, unsigned int cmd,
975975
break;
976976

977977
ret = -EINVAL;
978-
if (config.length == 0 ||
978+
if (config.offset > dev->config_size ||
979+
config.length == 0 ||
979980
config.length > dev->config_size - config.offset)
980981
break;
981982

0 commit comments

Comments
 (0)