linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Pan Bian <bianpan2016@163.com>,
	Jacob Chen <jacob-chen@iotwrt.com>,
	Ezequiel Garcia <ezequiel@collabora.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>
Cc: linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] media: rockchip/rga: fix potential use after free
Date: Sat, 9 Nov 2019 12:08:01 +0100	[thread overview]
Message-ID: <e89f6a90-4899-0945-e11a-67be6a28e7c0@xs4all.nl> (raw)
In-Reply-To: <1572969354-8967-1-git-send-email-bianpan2016@163.com>

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

      reply	other threads:[~2019-11-09 11:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-05 15:55 [PATCH] media: rockchip/rga: fix potential use after free Pan Bian
2019-11-09 11:08 ` Hans Verkuil [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e89f6a90-4899-0945-e11a-67be6a28e7c0@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=bianpan2016@163.com \
    --cc=ezequiel@collabora.com \
    --cc=heiko@sntech.de \
    --cc=jacob-chen@iotwrt.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).