From: Deepa Guthyappa Madivalara <deepa.madivalara@oss.qualcomm.com>
To: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>,
Vikash Garodia <vikash.garodia@oss.qualcomm.com>,
Dikshita Agarwal <dikshita.agarwal@oss.qualcomm.com>,
Abhinav Kumar <abhinav.kumar@linux.dev>,
Bryan O'Donoghue <bod@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@kernel.org>,
Stefan Schmidt <stefan.schmidt@linaro.org>
Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Birk Skyum <birk.skyum@pm.me>
Subject: Re: [PATCH v2] media: iris: Fix out-of-bounds read in timestamp metadata fallback
Date: Thu, 3 Dec 2026 16:14:24 -0800 [thread overview]
Message-ID: <d08f79cc-aaee-4a0b-b506-60546ff95a91@oss.qualcomm.com> (raw)
In-Reply-To: <20261117-fix-oob-tss-v2-1-8bbf753a4ee0@oss.qualcomm.com>
On 11/17/2026 3:43 AM, Vishnu Reddy wrote:
> inst->tss[] has VIDEO_MAX_FRAME (32) entries, so valid indexes are 0
> through 31. iris_set_ts_metadata() writes at metadata_idx and then
> increments it, wrapping only on the next call. After the 32nd input
> buffer, metadata_idx is 32 until the next input buffer is queued.
>
> If iris_get_ts_metadata() finds no matching timestamp in that window,
> its fallback reads inst->tss[32], one entry past the end of the array.
> UBSAN reports this as an array-index-out-of-bounds error.
>
> Advance metadata_idx before the write instead, starting from the last
> slot so the first write still lands in slot 0. The index then always
> refers to the last written entry and is never out of range, so the
> fallback read needs no special handling.
>
> Fixes: 17f2a485ca67 ("media: iris: implement vb2 ops for buf_queue and firmware response")
> Cc: stable@vger.kernel.org
> Tested-by: Birk Skyum <birk.skyum@pm.me> # Lenovo Yoga Slim 7x (X1E80100)
> Tested-by: Deepa Madivalara <deepa.madivalara@oss.qualcomm.com>
> Signed-off-by: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
> ---
> Changes in v2:
> - Wrap metadata_idx in iris_set_ts_metadata() instead of fixing the fallback read (Bryan)
> - Link to v1: https://patch.msgid.link/20261017-fix-oob-tss-v1-1-fb86f4cabf65@oss.qualcomm.com
> ---
> drivers/media/platform/qcom/iris/iris_common.c | 4 ++--
> drivers/media/platform/qcom/iris/iris_vidc.c | 1 +
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/iris/iris_common.c b/drivers/media/platform/qcom/iris/iris_common.c
> index 25836561bcf3e..2ff15edeac286 100644
> --- a/drivers/media/platform/qcom/iris/iris_common.c
> +++ b/drivers/media/platform/qcom/iris/iris_common.c
> @@ -33,6 +33,8 @@ void iris_set_ts_metadata(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf)
> struct vb2_buffer *vb = &vbuf->vb2_buf;
> u64 ts_us = vb->timestamp;
>
> + inst->metadata_idx++;
> +
> if (inst->metadata_idx >= ARRAY_SIZE(inst->tss))
> inst->metadata_idx = 0;
>
> @@ -42,8 +44,6 @@ void iris_set_ts_metadata(struct iris_inst *inst, struct vb2_v4l2_buffer *vbuf)
> inst->tss[inst->metadata_idx].tc = vbuf->timecode;
> inst->tss[inst->metadata_idx].ts_us = ts_us;
> inst->tss[inst->metadata_idx].ts_ns = vb->timestamp;
> -
> - inst->metadata_idx++;
> }
>
> int iris_process_streamon_input(struct iris_inst *inst)
> diff --git a/drivers/media/platform/qcom/iris/iris_vidc.c b/drivers/media/platform/qcom/iris/iris_vidc.c
> index 05aab6e3005d5..c85626195285b 100644
> --- a/drivers/media/platform/qcom/iris/iris_vidc.c
> +++ b/drivers/media/platform/qcom/iris/iris_vidc.c
> @@ -183,6 +183,7 @@ int iris_open(struct file *filp)
> inst->domain = session_type;
> inst->session_id = hash32_ptr(inst);
> inst->state = IRIS_INST_DEINIT;
> + inst->metadata_idx = ARRAY_SIZE(inst->tss) - 1;
> kref_init(&inst->kref);
>
> mutex_init(&inst->lock);
>
> ---
> base-commit: 749a4de370409464cf8501ec5b2451df45c84eb4
> change-id: 20261013-fix-oob-tss-7d317d612cf0
>
> Best regards,
> --
> Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
Tested-by: Deepa Madivalara<deepa.madivalara@oss.qualcomm.com>
prev parent reply other threads:[~2026-12-04 0:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 11:43 Vishnu Reddy
2026-11-27 12:32 ` Vikash Garodia
2026-11-30 12:32 ` bod
2026-12-04 0:14 ` Deepa Guthyappa Madivalara [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=d08f79cc-aaee-4a0b-b506-60546ff95a91@oss.qualcomm.com \
--to=deepa.madivalara@oss.qualcomm.com \
--cc=abhinav.kumar@linux.dev \
--cc=birk.skyum@pm.me \
--cc=bod@kernel.org \
--cc=busanna.reddy@oss.qualcomm.com \
--cc=dikshita.agarwal@oss.qualcomm.com \
--cc=hverkuil@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=stefan.schmidt@linaro.org \
--cc=vikash.garodia@oss.qualcomm.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®