Skip to contentSkip to conversation

media: v4l2-compat-ioctl32: check for max size

PATCH In review Defang Bo 2 participants 2 messages Oct 19, 2020 – Oct 30, 2020 Media (V4L/DVB)

lore
Share & tools
lore

Defang Bo

author
#0 lore raw

PATCH 1/1 media: v4l2-compat-ioctl32: check for max size

Similar to commit<ea72fbf588ac>("media: v4l2-compat-ioctl32: prevent go past max size"} ,add max size check for count variable.

---
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +1 -1
index a99e82e..5041d60 100644
@@ -207,7 +207,7 @@ static int put_v4l2_window32(struct v4l2_window __user *p64,
 	    get_user(clipcount, &p64->clipcount) ||
 	    put_user(clipcount, &p32->clipcount))
 		return -EFAULT;
-	if (!clipcount)
+	if (!clipcount || count > (U32_MAX/sizeof(*uclips)))
 		return 0;
 
 	if (get_user(kclips, &p64->clips))
Signature · 1 line
1.9.1
#1 lore raw
Quoted 12 lines · Defang Bo

Similar to commit<ea72fbf588ac>("media: v4l2-compat-ioctl32: prevent go past max size"} ,add max size check for count variable.

---
 drivers/media/v4l2-core/v4l2-compat-ioctl32.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +0 -0
index a99e82e..5041d60 100644

drivers/media/v4l2-core/v4l2-compat-ioctl32.c static int put_v4l2_window32(struct v4l2_window __user *p64, · line 210

Quoted 5 lines
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +1 -1
@@ -207,7 +207,7 @@ static int put_v4l2_window32(struct v4l2_window __user *p64,
 	    get_user(clipcount, &p64->clipcount) ||
 	    put_user(clipcount, &p32->clipcount))
 		return -EFAULT;
-	if (!clipcount)
+	if (!clipcount || count > (U32_MAX/sizeof(*uclips)))

Clearly you didn't compile this since count should have been clipcount.

And in any case, this is bogus since get_v4l2_window32() already checks that clipcount doesn't exceed 2048.

Regards,

Hans

Quoted 4 lines
drivers/media/v4l2-core/v4l2-compat-ioctl32.c +0 -0
 		return 0;
 
 	if (get_user(kclips, &p64->clips))