Vulnerability: drivers/media/usb/dvb-usb-v2/dvb_usb_core.c in the Linux kernel 4.9.x and 4.10.x before 4.10.12 interacts incorrectly with the CONFIG_VMAP_STACK option, which allows local users to cause a denial of service (system crash or memory corruption) or possibly have unspecified other impact by leveraging use of more than one virtual page for a DMA scatterlist.
Vulnerability ID: CVE-2017-8064
CWE: CWE-119
Severity score: 10
Project: https://github.com/torvalds/linux
Published: 2017-04-23
File: drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
Commit message: [media] dvb-usb-v2: avoid use-after-free

I ran into a stack frame size warning because of the on-stack copy of
the USB device structure:

drivers/media/usb/dvb-usb-v2/dvb_usb_core.c: In function 'dvb_usbv2_disconnect':
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c:1029:1: error: the frame size of 1104 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

Copying a device structure like this is wrong for a number of other reasons
too aside from the possible stack overflow. One of them is that the
dev_info() call will print the name of the device later, but AFAICT
we have only copied a pointer to the name earlier and the actual name
has been freed by the time it gets printed.

This removes the on-stack copy of the device and instead copies the
device name using kstrdup(). I'm ignoring the possible failure here
as both printk() and kfree() are able to deal with NULL pointers.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Commit author: Arnd Bergmann

Vulnerable version (before fix):
 EXPORT_SYMBOL(dvb_usbv2_probe); void dvb_usbv2_disconnect(struct usb_interface *intf) { 	struct dvb_usb_device *d = usb_get_intfdata(intf); 	const char *name = d->name; 	struct device dev = d->udev->dev;  	dev_dbg(&d->udev->dev, "%s: bInterfaceNumber=%d\n", __func__, 			intf->cur_altsetting->desc.bInterfaceNumber); void dvb_usbv2_disconnect(struct usb_interface *intf)  	dvb_usbv2_exit(d);  	dev_info(&dev, "%s: '%s' successfully deinitialized and disconnected\n", 			KBUILD_MODNAME, name); } EXPORT_SYMBOL(dvb_usbv2_disconnect); 

Fixed version (after fix):
 EXPORT_SYMBOL(dvb_usbv2_probe); void dvb_usbv2_disconnect(struct usb_interface *intf) { 	struct dvb_usb_device *d = usb_get_intfdata(intf); 	const char *devname = kstrdup(dev_name(&d->udev->dev), GFP_KERNEL); 	const char *drvname = d->name;  	dev_dbg(&d->udev->dev, "%s: bInterfaceNumber=%d\n", __func__, 			intf->cur_altsetting->desc.bInterfaceNumber); void dvb_usbv2_disconnect(struct usb_interface *intf)  	dvb_usbv2_exit(d);  	pr_info("%s: '%s:%s' successfully deinitialized and disconnected\n", 		KBUILD_MODNAME, drvname, devname); 	kfree(devname); } EXPORT_SYMBOL(dvb_usbv2_disconnect); 

Patch:
patch: @@ -1012,8 +1012,8 @@ EXPORT_SYMBOL(dvb_usbv2_probe);
 void dvb_usbv2_disconnect(struct usb_interface *intf)
 {
 	struct dvb_usb_device *d = usb_get_intfdata(intf);
-	const char *name = d->name;
-	struct device dev = d->udev->dev;
+	const char *devname = kstrdup(dev_name(&d->udev->dev), GFP_KERNEL);
+	const char *drvname = d->name;
 
 	dev_dbg(&d->udev->dev, "%s: bInterfaceNumber=%d\n", __func__,
 			intf->cur_altsetting->desc.bInterfaceNumber);
@@ -1023,8 +1023,9 @@ void dvb_usbv2_disconnect(struct usb_interface *intf)
 
 	dvb_usbv2_exit(d);
 
-	dev_info(&dev, "%s: '%s' successfully deinitialized and disconnected\n",
-			KBUILD_MODNAME, name);
+	pr_info("%s: '%s:%s' successfully deinitialized and disconnected\n",
+		KBUILD_MODNAME, drvname, devname);
+	kfree(devname);
 }
 EXPORT_SYMBOL(dvb_usbv2_disconnect);
path: drivers/media/usb/dvb-usb-v2/dvb_usb_core.c