diff mbox

[CVE-2016-5728,Trusty,Vivid,Xenial] misc: mic: Fix for double fetch security bug in VOP driver

Message ID 1469027737-22624-1-git-send-email-luis.henriques@canonical.com
State New
Headers show

Commit Message

Luis Henriques July 20, 2016, 3:15 p.m. UTC
From: Ashutosh Dixit <ashutosh.dixit@intel.com>

The MIC VOP driver does two successive reads from user space to read a
variable length data structure. Kernel memory corruption can result if
the data structure changes between the two reads. This patch disallows
the chance of this happening.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116651
Reported by: Pengfei Wang <wpengfeinudt@gmail.com>
Reviewed-by: Sudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(backported from commit 9bf292bfca94694a721449e3fd752493856710f6)
[ luis: apply changes to mic_copy_dp_entry(), in file
  drivers/misc/mic/host/mic_virtio.c; adjust context ]
CVE-2016-5728
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 drivers/misc/mic/host/mic_virtio.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Tim Gardner July 20, 2016, 3:32 p.m. UTC | #1

Kamal Mostafa July 20, 2016, 4:08 p.m. UTC | #2

diff mbox

Patch

diff --git a/drivers/misc/mic/host/mic_virtio.c b/drivers/misc/mic/host/mic_virtio.c
index 58b107a24a8b..3314b2f285b2 100644
--- a/drivers/misc/mic/host/mic_virtio.c
+++ b/drivers/misc/mic/host/mic_virtio.c
@@ -556,6 +556,12 @@  static int mic_copy_dp_entry(struct mic_vdev *mvdev,
 		goto exit;
 	}
 
+	/* Ensure desc has not changed between the two reads */
+	if (memcmp(&dd, dd_config, sizeof(dd))) {
+		ret = -EINVAL;
+		goto exit;
+	}
+
 	vqconfig = mic_vq_config(dd_config);
 	for (i = 0; i < dd.num_vq; i++) {
 		if (le16_to_cpu(vqconfig[i].num) > MIC_MAX_VRING_ENTRIES) {