Skip to content

Commit 3723869

Browse files
HBh25Ymchehab
authored andcommitted
media: dvb_vb2: fix possible out of bound access
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: 57868ac ("media: videobuf2: Add new uAPI for DVB streaming I/O") Signed-off-by: Hangyu Hua <[email protected]> Reviewed-by: Sergey Senozhatsky <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent f0da34f commit 3723869

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/media/dvb-core/dvb_vb2.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req)
354354

355355
int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b)
356356
{
357+
struct vb2_queue *q = &ctx->vb_q;
358+
359+
if (b->index >= q->num_buffers) {
360+
dprintk(1, "[%s] buffer index out of range\n", ctx->name);
361+
return -EINVAL;
362+
}
357363
vb2_core_querybuf(&ctx->vb_q, b->index, b);
358364
dprintk(3, "[%s] index=%d\n", ctx->name, b->index);
359365
return 0;
@@ -378,8 +384,13 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp)
378384

379385
int dvb_vb2_qbuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b)
380386
{
387+
struct vb2_queue *q = &ctx->vb_q;
381388
int ret;
382389

390+
if (b->index >= q->num_buffers) {
391+
dprintk(1, "[%s] buffer index out of range\n", ctx->name);
392+
return -EINVAL;
393+
}
383394
ret = vb2_core_qbuf(&ctx->vb_q, b->index, b, NULL);
384395
if (ret) {
385396
dprintk(1, "[%s] index=%d errno=%d\n", ctx->name,

0 commit comments

Comments
 (0)