From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Wei Chen <harperchen1110@gmail.com>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sasha Levin <sashal@kernel.org>,
tiffany.lin@mediatek.com, andrew-ct.chen@mediatek.com,
yunfei.dong@mediatek.com, matthias.bgg@gmail.com,
linux-media@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: [PATCH AUTOSEL 6.2 37/37] media: mediatek: vcodec: Fix potential array out-of-bounds in decoder queue_setup
Date: Sun, 30 Apr 2023 22:59:45 -0400 [thread overview]
Message-ID: <20230501025945.3253774-37-sashal@kernel.org> (raw)
In-Reply-To: <20230501025945.3253774-1-sashal@kernel.org>
From: Wei Chen <harperchen1110@gmail.com>
[ Upstream commit 8fbcf730cb89c3647f3365226fe7014118fa93c7 ]
variable *nplanes is provided by user via system call argument. The
possible value of q_data->fmt->num_planes is 1-3, while the value
of *nplanes can be 1-8. The array access by index i can cause array
out-of-bounds.
Fix this bug by checking *nplanes against the array size.
Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
index 641f533c417fd..173407664cf42 100644
--- a/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mediatek/vcodec/mtk_vcodec_dec.c
@@ -753,6 +753,13 @@ int vb2ops_vdec_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
}
if (*nplanes) {
+ if (vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+ if (*nplanes != q_data->fmt->num_planes)
+ return -EINVAL;
+ } else {
+ if (*nplanes != 1)
+ return -EINVAL;
+ }
for (i = 0; i < *nplanes; i++) {
if (sizes[i] < q_data->sizeimage[i])
return -EINVAL;
--
2.39.2
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2023-05-01 3:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230501025945.3253774-1-sashal@kernel.org>
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 09/37] remoteproc: imx_dsp_rproc: Add custom memory copy implementation for i.MX DSP Cores Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 12/37] media: imx-jpeg: Bounds check sizeimage access Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 17/37] drm/rockchip: dw_hdmi: cleanup drm encoder during unbind Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 19/37] arm64: dts: imx8mq-librem5: Remove dis_u3_susphy_quirk from usb_dwc3_0 Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 20/37] firmware: arm_sdei: Fix sleep from invalid context BUG Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 23/37] remoteproc: stm32_rproc: Add mutex protection for workqueue Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 29/37] irqchip/gicv3: Workaround for NVIDIA erratum T241-FABRIC-4 Sasha Levin
2023-05-01 2:59 ` [PATCH AUTOSEL 6.2 35/37] media: Prefer designated initializers over memset for subdev pad ops Sasha Levin
2023-05-01 2:59 ` Sasha Levin [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=20230501025945.3253774-37-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=andrew-ct.chen@mediatek.com \
--cc=harperchen1110@gmail.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tiffany.lin@mediatek.com \
--cc=yunfei.dong@mediatek.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;
as well as URLs for NNTP newsgroup(s).