Re: [PATCH] tee: add overflow check in tee_ioctl_shm_register()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 22, 2022 at 12:01 PM Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Mon, Aug 22, 2022 at 11:59:17AM +0200, Greg KH wrote:
> > On Mon, Aug 22, 2022 at 11:26:21AM +0200, Jens Wiklander wrote:
> > > commit 573ae4f13f630d6660008f1974c0a8a29c30e18a upstream.
> > >
> > > With special lengths supplied by user space, tee_shm_register() has
> > > an integer overflow when calculating the number of pages covered by a
> > > supplied user space memory region.
> > >
> > > This may cause pin_user_pages_fast() to do a NULL pointer dereference.
> > >
> > > Fix this by adding an an explicit call to access_ok() in
> > > tee_ioctl_shm_register() to catch an invalid user space address early.
> > >
> > > Fixes: 033ddf12bcf5 ("tee: add register user memory")
> > > Cc: stable@xxxxxxxxxxxxxxx # 5.4
> > > Reported-by: Nimish Mishra <neelam.nimish@xxxxxxxxx>
> > > Reported-by: Anirban Chakraborty <ch.anirban00727@xxxxxxxxx>
> > > Reported-by: Debdeep Mukhopadhyay <debdeep.mukhopadhyay@xxxxxxxxx>
> > > Suggested-by: Jerome Forissier <jerome.forissier@xxxxxxxxxx>
> > > Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> > > [JW: backport to stable-5.4 + update commit message]
> >
> > Will this also work for 4.19?
>
> Nope, it breaks the build on 4.19.y, needs a different backport there:

Yeah, I'm just about to post a 4.19.y backport too.

Cheers,
Jens

>
>   CC [M]  drivers/tee/tee_core.o
> drivers/tee/tee_core.c: In function ‘tee_ioctl_shm_register’:
> drivers/tee/tee_core.c:178:76: error: macro "access_ok" requires 3 arguments, but only 2 given
>   178 |         if (!access_ok((void __user *)(unsigned long)data.addr, data.length))
>       |                                                                            ^
> In file included from ./include/linux/uaccess.h:14,
>                  from drivers/tee/tee_core.c:24:
> ./arch/x86/include/asm/uaccess.h:98: note: macro "access_ok" defined here
>    98 | #define access_ok(type, addr, size)                                     \
>       |
> drivers/tee/tee_core.c:178:14: error: ‘access_ok’ undeclared (first use in this function)
>   178 |         if (!access_ok((void __user *)(unsigned long)data.addr, data.length))
>       |              ^~~~~~~~~
>
>




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux