mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hangyu Hua <hbh25y@gmail.com>
To: mchehab@kernel.org, senozhatsky@chromium.org,
	cai.huoqing@linux.dev, hverkuil-cisco@xs4all.nl,
	sw0312.kim@samsung.com, satendra.t@samsung.com,
	jh1009.sung@samsung.com, nenggun.kim@samsung.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] media: dvb_vb2: fix possible out of bound access
Date: Tue, 27 Sep 2022 10:01:11 +0800	[thread overview]
Message-ID: <b4b52911-e135-38b6-ab2e-4580e1ac0302@gmail.com> (raw)
In-Reply-To: <20220519021743.8295-1-hbh25y@gmail.com>

On 19/5/2022 10:17, Hangyu Hua wrote:
> vb2_core_qbuf and vb2_core_querybuf don't check the range of b->index
> controlled by the user.
> 
> Fix this by adding range checking code before using them.
> 
> Fixes: 57868acc369a ("media: videobuf2: Add new uAPI for DVB streaming I/O")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
> ---
> 
> v2:
> 1. fix inappropriate use of dprintk.
> 2. add "fixes" tag
> 
>   drivers/media/dvb-core/dvb_vb2.c | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c
> index a1bd6d9c9223..909df82fed33 100644
> --- a/drivers/media/dvb-core/dvb_vb2.c
> +++ b/drivers/media/dvb-core/dvb_vb2.c
> @@ -354,6 +354,12 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req)
>   
>   int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b)
>   {
> +	struct vb2_queue *q = &ctx->vb_q;
> +
> +	if (b->index >= q->num_buffers) {
> +		dprintk(1, "[%s] buffer index out of range\n", ctx->name);
> +		return -EINVAL;
> +	}
>   	vb2_core_querybuf(&ctx->vb_q, b->index, b);
>   	dprintk(3, "[%s] index=%d\n", ctx->name, b->index);
>   	return 0;
> @@ -378,8 +384,13 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp)
>   
>   int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b)
>   {
> +	struct vb2_queue *q = &ctx->vb_q;
>   	int ret;
>   
> +	if (b->index >= q->num_buffers) {
> +		dprintk(1, "[%s] buffer index out of range\n", ctx->name);
> +		return -EINVAL;
> +	}
>   	ret = vb2_core_qbuf(&ctx->vb_q, b->index, b, NULL);
>   	if (ret) {
>   		dprintk(1, "[%s] index=%d errno=%d\n", ctx->name,

Hi guys,

Looks like this patch was forgotten to to merge into master branch. This 
bug still in:
https://git.linuxtv.org/media_tree.git/tree/drivers/media/dvb-core/dvb_vb2.c#n355
and
https://git.linuxtv.org/media_tree.git/tree/drivers/media/dvb-core/dvb_vb2.c#n379

Thanks,
Hangyu

  reply	other threads:[~2022-09-27  2:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19  2:17 Hangyu Hua
2022-09-27  2:01 ` Hangyu Hua [this message]
2022-09-27  8:10   ` Hans Verkuil
2022-09-27  8:36     ` Hans Verkuil

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=b4b52911-e135-38b6-ab2e-4580e1ac0302@gmail.com \
    --to=hbh25y@gmail.com \
    --cc=cai.huoqing@linux.dev \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jh1009.sung@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nenggun.kim@samsung.com \
    --cc=satendra.t@samsung.com \
    --cc=senozhatsky@chromium.org \
    --cc=sw0312.kim@samsung.com \
    /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

all inboxes | Powered by JetHome®