linux/drivers/media/platform
Zheng Wang 715c0200b4 media: mtk-jpeg: Fix use after free bug due to uncanceled work
[ Upstream commit c677d7ae83 ]

In mtk_jpeg_probe, &jpeg->job_timeout_work is bound with
mtk_jpeg_job_timeout_work. Then mtk_jpeg_dec_device_run
and mtk_jpeg_enc_device_run may be called to start the
work.
If we remove the module which will call mtk_jpeg_remove
to make cleanup, there may be a unfinished work. The
possible sequence is as follows, which will cause a
typical UAF bug.

Fix it by canceling the work before cleanup in the mtk_jpeg_remove

CPU0                  CPU1

                    |mtk_jpeg_job_timeout_work
mtk_jpeg_remove     |
  v4l2_m2m_release  |
    kfree(m2m_dev); |
                    |
                    | v4l2_m2m_get_curr_priv
                    |   m2m_dev->curr_ctx //use
Fixes: b2f0d2724b ("[media] vcodec: mediatek: Add Mediatek JPEG Decoder Driver")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-09-13 09:42:50 +02:00
..
allegro-dvt
amlogic
amphion media: amphion: add helper function to get id name 2023-09-13 09:42:50 +02:00
aspeed
atmel
cadence
chips-media
intel
marvell
mediatek media: mtk-jpeg: Fix use after free bug due to uncanceled work 2023-09-13 09:42:50 +02:00
nvidia
nxp media: imx-jpeg: Apply clk_bulk api instead of operating specific clk 2023-03-10 09:33:43 +01:00
qcom media: camss: set VFE bpl_alignment to 16 for sdm845 and sm8250 2023-08-23 17:52:23 +02:00
renesas media: rcar-vin: Select correct interrupt mode for V4L2_FIELD_ALTERNATE 2023-06-09 10:34:08 +02:00
rockchip
samsung media: Prefer designated initializers over memset for subdev pad ops 2023-05-24 17:32:36 +01:00
st media: bdisp: Add missing check for create_workqueue 2023-05-11 23:03:10 +09:00
sunxi
ti media: Prefer designated initializers over memset for subdev pad ops 2023-05-24 17:32:36 +01:00
verisilicon media: hantro: Fix JPEG encoder ENUM_FRMSIZE on RK3399 2023-03-10 09:33:43 +01:00
via
xilinx
Kconfig
m2m-deinterlace.c
Makefile
video-mux.c