OrangePi_CM5/drivers/media
Takashi Iwai a1806694fc UPSTREAM: media: dvb-core: Fix UAF due to refcount races at releasing
commit fd3d91ab1c6ab0628fe642dd570b56302c30a792 upstream.

The dvb-core tries to sync the releases of opened files at
dvb_dmxdev_release() with two refcounts: dvbdev->users and
dvr_dvbdev->users.  A problem is present in those two syncs: when yet
another dvb_demux_open() is called during those sync waits,
dvb_demux_open() continues to process even if the device is being
closed.  This includes the increment of the former refcount, resulting
in the leftover refcount after the sync of the latter refcount at
dvb_dmxdev_release().  It ends up with use-after-free, since the
function believes that all usages were gone and releases the
resources.

This patch addresses the problem by adding the check of dmxdev->exit
flag at dvb_demux_open(), just like dvb_dvr_open() already does.  With
the exit flag check, the second call of dvb_demux_open() fails, hence
the further corruption can be avoided.

Also for avoiding the races of the dmxdev->exit flag reference, this
patch serializes the dmxdev->exit set up and the sync waits with the
dmxdev->mutex lock at dvb_dmxdev_release().  Without the mutex lock,
dvb_demux_open() (or dvb_dvr_open()) may run concurrently with
dvb_dmxdev_release(), which allows to skip the exit flag check and
continue the open process that is being closed.

CVE-2022-41218 is assigned to those bugs above.

Bug: 248356119
Reported-by: Hyunwoo Kim <imv4bel@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/20220908132754.30532-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I5a0dd4444ca25d07a050dcb07609c7c7ccf658af
2023-01-31 17:48:42 +00:00
..
cec media: cros-ec-cec: limit msg.len to CEC_MAX_MSG_SIZE 2022-11-10 18:14:22 +01:00
common media: videobuf2-core: take mmap_lock in vb2_get_unmapped_area() 2022-12-14 11:31:57 +01:00
dvb-core UPSTREAM: media: dvb-core: Fix UAF due to refcount races at releasing 2023-01-31 17:48:42 +00:00
dvb-frontends media: dvb-frontends/drxk: initialize err to 0 2022-11-10 18:14:22 +01:00
firewire media: firewire: firedtv-avc: fix a buffer overflow in avc_ca_pmt() 2021-11-06 14:10:09 +01:00
i2c This is the 5.10.121 stable release 2022-07-23 16:10:22 +02:00
mc Merge branch 'android12-5.10' into `android12-5.10-lts` 2021-07-22 13:32:27 +02:00
mmc
pci This is the 5.10.150 stable release 2022-11-15 19:14:08 +00:00
platform This is the 5.10.152 stable release 2022-11-21 15:46:22 +00:00
radio media: si470x-i2c: fix possible memory leak in si470x_i2c_probe() 2022-01-27 10:53:51 +01:00
rc media: mceusb: set timeout to at least timeout provided 2022-10-30 09:41:15 +01:00
spi media: cxd2880-spi: Fix a null pointer dereference on error handling path 2021-11-18 14:04:04 +01:00
test-drivers media: vivid: set num_in/outputs to 0 if not supported 2022-11-03 23:57:53 +09:00
tuners media: msi001: fix possible null-ptr-deref in msi001_probe() 2022-01-27 10:53:56 +01:00
usb media: flexcop-usb: fix endpoint type check 2022-09-28 11:10:26 +02:00
v4l2-core This is the 5.10.159 stable release 2022-12-14 13:11:31 +01:00
Kconfig This is the 5.10.94 stable release 2022-01-27 11:49:22 +01:00
Makefile