lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 2 Nov 2012 10:43:54 +0800
From:	Fengguang Wu <fengguang.wu@...el.com>
To:	Alex Williamson <alex.williamson@...hat.com>
Cc:	linux-kernel@...r.kernel.org, Julia Lawall <julia.lawall@...6.fr>
Subject: [PATCH] vfio: simplify kmalloc+copy_from_user to memdup_user

Generated by: coccinelle/api/memdup_user.cocci

Acked-by: Julia Lawall <julia.lawall@...6.fr>
Reported-by: Fengguang Wu <fengguang.wu@...el.com>
---

 drivers/vfio/pci/vfio_pci.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

--- linux.orig/drivers/vfio/pci/vfio_pci.c	2012-10-23 18:21:57.118168335 +0800
+++ linux/drivers/vfio/pci/vfio_pci.c	2012-11-02 10:39:36.101317628 +0800
@@ -327,15 +327,10 @@ static long vfio_pci_ioctl(void *device_
 			    hdr.count > vfio_pci_get_irq_count(vdev, hdr.index))
 				return -EINVAL;
 
-			data = kmalloc(hdr.count * size, GFP_KERNEL);
-			if (!data)
-				return -ENOMEM;
-
-			if (copy_from_user(data, (void __user *)(arg + minsz),
-					   hdr.count * size)) {
-				kfree(data);
-				return -EFAULT;
-			}
+			data = memdup_user((void __user *)(arg + minsz),
+					   hdr.count * size);
+			if (IS_ERR(data))
+				return PTR_ERR(data);
 		}
 
 		mutex_lock(&vdev->igate);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ