public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Jens Wiklander <jens.wiklander@linaro.org>
Cc: stable@vger.kernel.org, Sumit Garg <sumit.garg@linaro.org>,
	Jerome Forissier <jerome.forissier@linaro.org>,
	Nimish Mishra <neelam.nimish@gmail.com>,
	Anirban Chakraborty <ch.anirban00727@gmail.com>,
	Debdeep Mukhopadhyay <debdeep.mukhopadhyay@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] tee: add overflow check in tee_ioctl_shm_register()
Date: Mon, 22 Aug 2022 12:01:22 +0200	[thread overview]
Message-ID: <YwNT8tkhHl6K5D2L@kroah.com> (raw)
In-Reply-To: <YwNTdQTj8SC/wnYD@kroah.com>

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@vger.kernel.org # 5.4
> > Reported-by: Nimish Mishra <neelam.nimish@gmail.com>
> > Reported-by: Anirban Chakraborty <ch.anirban00727@gmail.com>
> > Reported-by: Debdeep Mukhopadhyay <debdeep.mukhopadhyay@gmail.com>
> > Suggested-by: Jerome Forissier <jerome.forissier@linaro.org>
> > Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> > [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:

  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))
      |              ^~~~~~~~~



  reply	other threads:[~2022-08-22 10:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22  9:26 [PATCH] tee: add overflow check in tee_ioctl_shm_register() Jens Wiklander
2022-08-22  9:59 ` Greg KH
2022-08-22 10:01   ` Greg KH [this message]
2022-08-22 12:07     ` Jens Wiklander
  -- strict thread matches above, loose matches on Subject: below --
2022-08-22 13:12 Jens Wiklander
2022-08-22 13:32 ` Greg KH
2022-08-22 14:29   ` Jens Wiklander
2022-08-22 14:57     ` Greg KH
2022-08-23  7:00       ` Jens Wiklander
2022-08-23  7:14         ` Greg KH
2022-11-08  6:12 ` Sumit Garg
2022-11-08  6:23   ` Greg Kroah-Hartman
2022-08-22 15:02 Jens Wiklander
2022-08-22 15:13 ` Greg KH

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=YwNT8tkhHl6K5D2L@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=ch.anirban00727@gmail.com \
    --cc=debdeep.mukhopadhyay@gmail.com \
    --cc=jens.wiklander@linaro.org \
    --cc=jerome.forissier@linaro.org \
    --cc=neelam.nimish@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=sumit.garg@linaro.org \
    --cc=torvalds@linux-foundation.org \
    /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