[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHUa44G2yaB28sd0FjkjyCNJKXjx2Jg9j-9HXytyvsmiQ3ThAA@mail.gmail.com>
Date: Wed, 24 Sep 2025 11:21:34 +0200
From: Jens Wiklander <jens.wiklander@...aro.org>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Amirreza Zarrabi <amirreza.zarrabi@....qualcomm.com>, Sumit Garg <sumit.garg@...nel.org>,
linux-arm-msm@...r.kernel.org, op-tee@...ts.trustedfirmware.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH next] tee: qcom: prevent potential off by one read
On Wed, Sep 24, 2025 at 9:36 AM Dan Carpenter <dan.carpenter@...aro.org> wrote:
>
> On Wed, Sep 24, 2025 at 08:58:45AM +1000, Amirreza Zarrabi wrote:
> >
> >
> > On 9/24/2025 8:48 AM, Amirreza Zarrabi wrote:
> > > On 9/18/2025 7:50 PM, Dan Carpenter wrote:
> > >> Re-order these checks to check if "i" is a valid array index before using
> > >> it. This prevents a potential off by one read access.
> > >>
> > >> Fixes: d6e290837e50 ("tee: add Qualcomm TEE driver")
> > >> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> > >> ---
> > >> drivers/tee/qcomtee/call.c | 2 +-
> > >> 1 file changed, 1 insertion(+), 1 deletion(-)
> > >>
> > >> diff --git a/drivers/tee/qcomtee/call.c b/drivers/tee/qcomtee/call.c
> > >> index cc17a48d0ab7..ac134452cc9c 100644
> > >> --- a/drivers/tee/qcomtee/call.c
> > >> +++ b/drivers/tee/qcomtee/call.c
> > >> @@ -308,7 +308,7 @@ static int qcomtee_params_from_args(struct tee_param *params,
> > >> }
> > >>
> > >> /* Release any IO and OO objects not processed. */
> > >> - for (; u[i].type && i < num_params; i++) {
> > >> + for (; i < num_params && u[i].type; i++) {
> > >> if (u[i].type == QCOMTEE_ARG_TYPE_OO ||
> > >> u[i].type == QCOMTEE_ARG_TYPE_IO)
> > >> qcomtee_object_put(u[i].o);
> > >
> > > This is not required, considering the sequence of clean up, this
> > > would never happen. `i` at least have been accessed once in the
> > > switch above.
> > >
> > > Regards,
> > > Amir
> > >
> > >
> >
> > Also, size of u is always num_params + 1 for the ending 0.
> > (basically means `i < num_params` can be removed).
> >
>
> Yes. This is true.
So this patch isn't needed. I'll drop it if no one objects.
Cheers,
Jens
Powered by blists - more mailing lists