summaryrefslogtreecommitdiffstats
path: root/drivers/misc/mic/host/mic_virtio.c
diff options
context:
space:
mode:
authorSudeep Dutt2014-02-03 23:53:19 +0100
committerGreg Kroah-Hartman2014-02-08 00:30:34 +0100
commit3b1cc9b9622a022208ec95b1259b05bbdf712eb7 (patch)
treec80a0f6b893b3bb48b70b23c13f5258ba06a8d82 /drivers/misc/mic/host/mic_virtio.c
parentARM: sunxi: dt: Convert to the new SID compatibles (diff)
downloadkernel-qcow2-linux-3b1cc9b9622a022208ec95b1259b05bbdf712eb7.tar.gz
kernel-qcow2-linux-3b1cc9b9622a022208ec95b1259b05bbdf712eb7.tar.xz
kernel-qcow2-linux-3b1cc9b9622a022208ec95b1259b05bbdf712eb7.zip
misc: mic: fix possible signed underflow (undefined behavior) in userspace API
iovcnt is declared as a signed integer in both the userspace API and as a local variable in mic_virtio.c. The while() loop in mic_virtio.c iterates until the local variable iovcnt reaches the value 0. If userspace passes e.g. INT_MIN as iovcnt field, this loop then appears to depend on an undefined behavior (signed underflow) to complete. The fix is to use unsigned integers in both the userspace API and the local variable. This issue was reported @ https://lkml.org/lkml/2014/1/10/10 Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/mic/host/mic_virtio.c')
-rw-r--r--drivers/misc/mic/host/mic_virtio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/misc/mic/host/mic_virtio.c b/drivers/misc/mic/host/mic_virtio.c
index 752ff873f891..7e1ef0ebbb80 100644
--- a/drivers/misc/mic/host/mic_virtio.c
+++ b/drivers/misc/mic/host/mic_virtio.c
@@ -156,7 +156,8 @@ static int mic_vringh_copy(struct mic_vdev *mvdev, struct vringh_kiov *iov,
static int _mic_virtio_copy(struct mic_vdev *mvdev,
struct mic_copy_desc *copy)
{
- int ret = 0, iovcnt = copy->iovcnt;
+ int ret = 0;
+ u32 iovcnt = copy->iovcnt;
struct iovec iov;
struct iovec __user *u_iov = copy->iov;
void __user *ubuf = NULL;