Commit c4920678 authored by Takashi Iwai's avatar Takashi Iwai Committed by Mauro Carvalho Chehab

media: dvb-usb: Fix use-after-free access

dvb_usb_device_init() copies the properties to the own data, so that
the callers can release the original properties later (as done in the
commit 299c7007 ("media: dw2102: Fix memleak on sequence of
probes")).  However, it also stores dev->desc pointer that is a
reference to the original properties data.  Since dev->desc is
referred later, it may result in use-after-free, in the worst case,
leading to a kernel Oops as reported.

This patch addresses the problem by allocating and copying the
properties at first, then get the desc from the copied properties.
Reported-and-tested-by: default avatarStefan Seyfried <seife+kernel@b1-systems.com>
BugLink: http://bugzilla.opensuse.org/show_bug.cgi?id=1181104Reviewed-by: default avatarRobert Foss <robert.foss@linaro.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 13a79f14
...@@ -264,27 +264,30 @@ int dvb_usb_device_init(struct usb_interface *intf, ...@@ -264,27 +264,30 @@ int dvb_usb_device_init(struct usb_interface *intf,
if (du != NULL) if (du != NULL)
*du = NULL; *du = NULL;
if ((desc = dvb_usb_find_device(udev, props, &cold)) == NULL) { d = kzalloc(sizeof(*d), GFP_KERNEL);
if (!d) {
err("no memory for 'struct dvb_usb_device'");
return -ENOMEM;
}
memcpy(&d->props, props, sizeof(struct dvb_usb_device_properties));
desc = dvb_usb_find_device(udev, &d->props, &cold);
if (!desc) {
deb_err("something went very wrong, device was not found in current device list - let's see what comes next.\n"); deb_err("something went very wrong, device was not found in current device list - let's see what comes next.\n");
return -ENODEV; ret = -ENODEV;
goto error;
} }
if (cold) { if (cold) {
info("found a '%s' in cold state, will try to load a firmware", desc->name); info("found a '%s' in cold state, will try to load a firmware", desc->name);
ret = dvb_usb_download_firmware(udev, props); ret = dvb_usb_download_firmware(udev, props);
if (!props->no_reconnect || ret != 0) if (!props->no_reconnect || ret != 0)
return ret; goto error;
} }
info("found a '%s' in warm state.", desc->name); info("found a '%s' in warm state.", desc->name);
d = kzalloc(sizeof(struct dvb_usb_device), GFP_KERNEL);
if (d == NULL) {
err("no memory for 'struct dvb_usb_device'");
return -ENOMEM;
}
d->udev = udev; d->udev = udev;
memcpy(&d->props, props, sizeof(struct dvb_usb_device_properties));
d->desc = desc; d->desc = desc;
d->owner = owner; d->owner = owner;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment