linux/drivers/media/dvb-core
Takashi Iwai fd3d91ab1c media: dvb-core: Fix UAF due to refcount races at releasing
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.

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>
2022-11-04 16:56:43 +01:00
..
dmxdev.c media: dvb-core: Fix UAF due to refcount races at releasing 2022-11-04 16:56:43 +01:00
dvb_ca_en50221.c media: dvb_ca_en50221: avoid speculation from CA slot 2021-06-17 09:24:10 +02:00
dvb_demux.c media: dvb-core: Convert to SPDX identifier 2021-11-19 15:22:13 +00:00
dvb_frontend.c media: dvb-core: dvb_frontend: address some clang warnings 2021-11-29 10:15:04 +01:00
dvb_math.c media: move dvb kAPI headers to include/media 2017-12-28 13:16:01 -05:00
dvb_net.c media: use eth_hw_addr_set() 2021-10-28 12:46:31 +01:00
dvb_ringbuffer.c docs: Fix some broken references 2018-06-15 18:10:01 -03:00
dvb_vb2.c media: dvb_vb2: fix possible out of bound access 2022-09-27 10:24:44 +02:00
dvbdev.c media: dvb-core: Convert to SPDX identifier 2021-11-19 15:22:13 +00:00
Kconfig media: Kconfig: cleanup VIDEO_DEV dependencies 2022-03-18 05:58:35 +01:00
Makefile media: dvb: fix DVB_MMAP symbol name 2018-02-23 05:20:01 -05:00