OpenCloudOS-Kernel/drivers/media/dvb-core
Zhipeng Lu 779e8db7ef media: edia: dvbdev: fix a use-after-free
[ Upstream commit 8c64f4cdf4e6cc5682c52523713af8c39c94e6d5 ]

In dvb_register_device, *pdvbdev is set equal to dvbdev, which is freed
in several error-handling paths. However, *pdvbdev is not set to NULL
after dvbdev's deallocation, causing use-after-frees in many places,
for example, in the following call chain:

budget_register
  |-> dvb_dmxdev_init
        |-> dvb_register_device
  |-> dvb_dmxdev_release
        |-> dvb_unregister_device
              |-> dvb_remove_device
                    |-> dvb_device_put
                          |-> kref_put

When calling dvb_unregister_device, dmxdev->dvbdev (i.e. *pdvbdev in
dvb_register_device) could point to memory that had been freed in
dvb_register_device. Thereafter, this pointer is transferred to
kref_put and triggering a use-after-free.

Link: https://lore.kernel.org/linux-media/20240203134046.3120099-1-alexious@zju.edu.cn
Fixes: b619010247 ("V4L/DVB (5244): Dvbdev: fix illegal re-usage of fileoperations struct")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:45 -04:00
..
Kconfig media: Kconfig: cleanup VIDEO_DEV dependencies 2022-03-18 05:58:35 +01:00
Makefile lib/math: Move dvb_math.c into lib/math/int_log.c 2023-07-09 22:47:48 +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-core: Fix use-after-free due to race condition at dvb_ca_en50221 2023-05-14 16:04:48 +01:00
dvb_demux.c media: dvb_demux: fix a bug for the continuity counter 2023-05-13 08:20:01 +01:00
dvb_frontend.c Revert "media: dvb-core: Fix use-after-free on race condition at dvb_frontend" 2023-06-14 23:16:29 +01:00
dvb_net.c media: dvb-core: Fix use-after-free due on race condition at dvb_net 2023-05-14 06:30:45 +01:00
dvb_ringbuffer.c media: dvb_ringbuffer : Fix a bug in dvb_ringbuffer.c 2022-11-25 10:05:25 +00:00
dvb_vb2.c media: dvb_vb2: fix possible out of bound access 2022-09-27 10:24:44 +02:00
dvbdev.c media: edia: dvbdev: fix a use-after-free 2024-03-26 18:19:45 -04:00