]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: rc: check for integer overflow
authorSean Young <sean@mess.org>
Sun, 8 Oct 2017 18:18:52 +0000 (14:18 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Feb 2018 18:32:09 +0000 (18:32 +0000)
commit 3e45067f94bbd61dec0619b1c32744eb0de480c8 upstream.

The ioctl LIRC_SET_REC_TIMEOUT would set a timeout of 704ns if called
with a timeout of 4294968us.

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
[bwh: Backported to 3.2: open-code U32_MAX]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/media/rc/ir-lirc-codec.c

index 695fef9ce6b1235aa5947f60648284331d94157d..4ee9f4e5a71d5b4c32e1c4104fc2cf014fdbd670 100644 (file)
@@ -255,11 +255,14 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
                if (!dev->max_timeout)
                        return -ENOSYS;
 
+               /* Check for multiply overflow */
+               if (val > (u32)(-1) / 1000)
+                       return -EINVAL;
+
                tmp = val * 1000;
 
-               if (tmp < dev->min_timeout ||
-                   tmp > dev->max_timeout)
-                               return -EINVAL;
+               if (tmp < dev->min_timeout || tmp > dev->max_timeout)
+                       return -EINVAL;
 
                dev->timeout = tmp;
                break;