This is a note to let you know that I've just added the patch titled media: dvb-usb: Fix use-after-free access to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: media-dvb-usb-fix-use-after-free-access.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From c49206786ee252f28b7d4d155d1fff96f145a05d Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@xxxxxxx> Date: Mon, 1 Feb 2021 09:32:47 +0100 Subject: media: dvb-usb: Fix use-after-free access From: Takashi Iwai <tiwai@xxxxxxx> commit c49206786ee252f28b7d4d155d1fff96f145a05d upstream. 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 299c7007e936 ("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: Stefan Seyfried <seife+kernel@xxxxxxxxxxxxxx> BugLink: http://bugzilla.opensuse.org/show_bug.cgi?id=1181104 Reviewed-by: Robert Foss <robert.foss@xxxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Takashi Iwai <tiwai@xxxxxxx> Signed-off-by: Sean Young <sean@xxxxxxxx> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/media/usb/dvb-usb/dvb-usb-init.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) --- a/drivers/media/usb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c @@ -267,27 +267,30 @@ int dvb_usb_device_init(struct usb_inter if (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"); - return -ENODEV; + ret = -ENODEV; + goto error; } if (cold) { info("found a '%s' in cold state, will try to load a firmware", desc->name); ret = dvb_usb_download_firmware(udev, props); if (!props->no_reconnect || ret != 0) - return ret; + goto error; } 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; - memcpy(&d->props, props, sizeof(struct dvb_usb_device_properties)); d->desc = desc; d->owner = owner; Patches currently in stable-queue which might be from tiwai@xxxxxxx are queue-5.4/alsa-hda-realtek-ga503-use-same-quirks-as-ga401.patch queue-5.4/alsa-usb-audio-more-constifications.patch queue-5.4/alsa-emu8000-fix-a-use-after-free-in-snd_emu8000_create_mixer.patch queue-5.4/alsa-hda-realtek-fix-mic-boost-on-intel-nuc-8.patch queue-5.4/media-dvb-usb-fix-use-after-free-access.patch queue-5.4/alsa-hda-realtek-add-quirk-for-intel-clevo-pcx0dx.patch queue-5.4/alsa-hda-realtek-fix-static-noise-on-alc285-lenovo-laptops.patch queue-5.4/alsa-sb-fix-two-use-after-free-in-snd_sb_qsound_build.patch queue-5.4/alsa-usb-audio-add-db-range-mapping-for-sennheiser-communications-headset-pc-8.patch queue-5.4/alsa-hda-conexant-re-order-cx5066-quirk-table-entries.patch queue-5.4/media-dvb-usb-fix-memory-leak-at-error-in-dvb_usb_device_init.patch queue-5.4/alsa-usb-audio-explicitly-set-up-the-clock-selector.patch