* [PATCH] media: rockchip/rga: fix potential use after free
@ 2019-11-05 15:55 Pan Bian
2019-11-09 11:08 ` Hans Verkuil
0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2019-11-05 15:55 UTC (permalink / raw)
To: Jacob Chen, Ezequiel Garcia, Mauro Carvalho Chehab, Heiko Stuebner
Cc: linux-rockchip, Pan Bian, linux-kernel, linux-arm-kernel, linux-media
The variable vga->vfd is an alias for vfd. Therefore, releasing vfd and
then unregister vga->vfd will lead to a use after free bug. In fact, the
free operation and the unregister operation are reversed.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/media/platform/rockchip/rga/rga.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
index e9ff12b6b5bb..613b868fce33 100644
--- a/drivers/media/platform/rockchip/rga/rga.c
+++ b/drivers/media/platform/rockchip/rga/rga.c
@@ -901,9 +901,9 @@ static int rga_probe(struct platform_device *pdev)
return 0;
rel_vdev:
- video_device_release(vfd);
-unreg_video_dev:
video_unregister_device(rga->vfd);
+unreg_video_dev:
+ video_device_release(vfd);
unreg_v4l2_dev:
v4l2_device_unregister(&rga->v4l2_dev);
err_put_clk:
--
2.7.4
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] media: rockchip/rga: fix potential use after free
2019-11-05 15:55 [PATCH] media: rockchip/rga: fix potential use after free Pan Bian
@ 2019-11-09 11:08 ` Hans Verkuil
0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2019-11-09 11:08 UTC (permalink / raw)
To: Pan Bian, Jacob Chen, Ezequiel Garcia, Mauro Carvalho Chehab,
Heiko Stuebner
Cc: linux-rockchip, linux-kernel, linux-arm-kernel, linux-media
On 11/5/19 4:55 PM, Pan Bian wrote:
> The variable vga->vfd is an alias for vfd. Therefore, releasing vfd and
> then unregister vga->vfd will lead to a use after free bug. In fact, the
> free operation and the unregister operation are reversed.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
> drivers/media/platform/rockchip/rga/rga.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c
> index e9ff12b6b5bb..613b868fce33 100644
> --- a/drivers/media/platform/rockchip/rga/rga.c
> +++ b/drivers/media/platform/rockchip/rga/rga.c
> @@ -901,9 +901,9 @@ static int rga_probe(struct platform_device *pdev)
> return 0;
>
> rel_vdev:
> - video_device_release(vfd);
> -unreg_video_dev:
> video_unregister_device(rga->vfd);
> +unreg_video_dev:
> + video_device_release(vfd);
> unreg_v4l2_dev:
> v4l2_device_unregister(&rga->v4l2_dev);
> err_put_clk:
>
This isn't right, you need to update the goto labels as well.
With this change unreg_video_dev releases the vdev, while rel_vdev
unregisters it. Very confusing.
I'd also rename unreg_video_dev to unreg_vdev to be consistent with
rel_vdev.
Regards,
Hans
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-09 11:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 15:55 [PATCH] media: rockchip/rga: fix potential use after free Pan Bian
2019-11-09 11:08 ` Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).