Re: [PATCH v2] tee: fix register_shm_helper()

From: Jens Wiklander
Date: Wed Sep 24 2025 - 04:28:53 EST


On Mon, Sep 22, 2025 at 10:50 AM Sumit Garg <sumit.garg@xxxxxxxxxx> wrote:
>
> On Mon, Sep 22, 2025 at 10:31:58AM +0200, Jens Wiklander wrote:
> > In register_shm_helper(), fix incorrect error handling for a call to
> > iov_iter_extract_pages(). A case is missing for when
> > iov_iter_extract_pages() only got some pages and return a number larger
> > than 0, but not the requested amount.
> >
> > This fixes a possible NULL pointer dereference following a bad input from
> > ioctl(TEE_IOC_SHM_REGISTER) where parts of the buffer isn't mapped.
> >
> > Cc: stable@xxxxxxxxxxxxxxx
> > Reported-by: Masami Ichikawa <masami256@xxxxxxxxx>
> > Closes: https://lore.kernel.org/op-tee/CACOXgS-Bo2W72Nj1_44c7bntyNYOavnTjJAvUbEiQfq=u9W+-g@xxxxxxxxxxxxxx/
> > Tested-by: Masami Ichikawa <masami256@xxxxxxxxx>
> > Fixes: 7bdee4157591 ("tee: Use iov_iter to better support shared buffer registration")
> > Signed-off-by: Jens Wiklander <jens.wiklander@xxxxxxxxxx>
> > ---
> > Changes from v1
> > - Refactor the if statement as requested by Sumit
> > - Adding Tested-by: Masami Ichikawa <masami256@xxxxxxxxx
> > - Link to v1:
> > https://lore.kernel.org/op-tee/20250919124217.2934718-1-jens.wiklander@xxxxxxxxxx/
> > ---
> > drivers/tee/tee_shm.c | 8 ++++++++
> > 1 file changed, 8 insertions(+)
>
> Reviewed-by: Sumit Garg <sumit.garg@xxxxxxxxxxxxxxxx>

I'm picking up this.

Thanks,
Jens