Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2521983rwb; Mon, 3 Oct 2022 01:53:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49942I+eNyZp8REhvza4jm43oWWIdYAh0Qxroy/C/rppYcdFRRFBborMgJuo33mFHNAhCr X-Received: by 2002:a63:f305:0:b0:43f:6af:7553 with SMTP id l5-20020a63f305000000b0043f06af7553mr18194939pgh.570.1664787186678; Mon, 03 Oct 2022 01:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664787186; cv=none; d=google.com; s=arc-20160816; b=udzeePyHNCwSS2mv1T6/JwY4ECe52JmuPR1uQaF4IZ9l1Z9B/UUCQO+ktMaii40z6r MaaonOvId8aUdxNjFkNpJeQ+QCYK4YU+lnktVeKqJSuGKcoQmHjXS9esjnFEA456ji7B +5XcDZj//iu5RtgLKx+ZpcWYw/sl1+BcSd4GAGRgi3z+shyJSWaFm7dJvZEbyY3hiqyX JxMkjQ5Q+KCssJENbsIZ8FtKzhObj0jC4oaY3qYJ0MXgMCsO5o7NreMhvVCJ+AuMX7cV dQA5F8lZAeT2eIBJ0agE1Xhl+v0dhitLkUHi8x5zKkqw4AIFm9jGyoEJ6dkARUmE+DWC tNew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xzWuCoxRfeAGc1vAmbMvJNVd35seL3dsjUNRlnTEmWk=; b=J6OGffRmtXAxfHC9ogKCr+8FWkpUw7rQULy0RTiuXwGw9iOzc2gqQKoJy78S5/WRtq 4lZ6sVDS6T+rvTyzjzd9cRFQ/hgJxeNQGIcP3ZrtSeuMKPKQk1BYphpeuop6RlGrZsRo KVfiDp97+q+RGFTjTegym4sCbUIlZSjmft9/ATIoY3LHuKzk1E2r+Vuju3V7ihU6gqLf 4j0Jl5IvRANuLk7UEhjflCuNPqq00kZPzpH2cZhZ3D1mPtNYCLP+U8pSGmEG8Gi9LZiF lnTcAuvclDbFIBaY11remXO8Q+vIm6hyerfnd923l7v7d6XY7QXesMNQkLUm3UZlaTEx Oj8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GkCosw6m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 9-20020a17090a0f0900b00200aafea6d6si14933220pjy.171.2022.10.03.01.52.54; Mon, 03 Oct 2022 01:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GkCosw6m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231467AbiJCHcK (ORCPT + 99 others); Mon, 3 Oct 2022 03:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230140AbiJCHbB (ORCPT ); Mon, 3 Oct 2022 03:31:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8AEB39B9A; Mon, 3 Oct 2022 00:20:26 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 96411B80E8F; Mon, 3 Oct 2022 07:19:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5EA5C433C1; Mon, 3 Oct 2022 07:19:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781556; bh=C3YAV3lrI8QAUFa6ta1NH/nFMDR6H6EJh8SGAbeV0q0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GkCosw6mUqs17qtqur8Gk7O5j+bitWPu/xBPKe0lSz8g8f2AhY5ZrJrVJ6rcia1R7 JrU/GQj7D8wHJNerBaR0GiTRKfO80rgEzE1b8jWFwPNLqmDG+KVxuFdHTbCrmvW6S4 I1EGNaw7uH31fHwUUfP0tyZFyncvKiyhQIT5470A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Sergey Senozhatsky , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.15 35/83] media: dvb_vb2: fix possible out of bound access Date: Mon, 3 Oct 2022 09:11:00 +0200 Message-Id: <20221003070722.877315558@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070721.971297651@linuxfoundation.org> References: <20221003070721.971297651@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangyu Hua commit 37238699073e7e93f05517e529661151173cd458 upstream. 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 Reviewed-by: Sergey Senozhatsky Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/dvb-core/dvb_vb2.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -358,6 +358,12 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx * 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; @@ -382,8 +388,13 @@ int dvb_vb2_expbuf(struct dvb_vb2_ctx *c 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,