<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/tee/tee_core.c, branch linux-4.19.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.19.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.19.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-08-25T09:15:48Z</updated>
<entry>
<title>tee: add overflow check in register_shm_helper()</title>
<updated>2022-08-25T09:15:48Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2022-08-18T11:08:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b37e0f17653c00b586cdbcdf0dbca475358ecffd'/>
<id>urn:sha1:b37e0f17653c00b586cdbcdf0dbca475358ecffd</id>
<content type='text'>
commit 573ae4f13f630d6660008f1974c0a8a29c30e18a upstream.

With special lengths supplied by user space, register_shm_helper() has
an integer overflow when calculating the number of pages covered by a
supplied user space memory region.

This causes internal_get_user_pages_fast() a helper function of
pin_user_pages_fast() to do a NULL pointer dereference:

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010
  Modules linked in:
  CPU: 1 PID: 173 Comm: optee_example_a Not tainted 5.19.0 #11
  Hardware name: QEMU QEMU Virtual Machine, BIOS 0.0.0 02/06/2015
  pc : internal_get_user_pages_fast+0x474/0xa80
  Call trace:
   internal_get_user_pages_fast+0x474/0xa80
   pin_user_pages_fast+0x24/0x4c
   register_shm_helper+0x194/0x330
   tee_shm_register_user_buf+0x78/0x120
   tee_ioctl+0xd0/0x11a0
   __arm64_sys_ioctl+0xa8/0xec
   invoke_syscall+0x48/0x114

Fix this by adding an an explicit call to access_ok() in
tee_shm_register_user_buf() to catch an invalid user space address
early.

Fixes: 033ddf12bcf5 ("tee: add register user memory")
Cc: stable@vger.kernel.org
Reported-by: Nimish Mishra &lt;neelam.nimish@gmail.com&gt;
Reported-by: Anirban Chakraborty &lt;ch.anirban00727@gmail.com&gt;
Reported-by: Debdeep Mukhopadhyay &lt;debdeep.mukhopadhyay@gmail.com&gt;
Suggested-by: Jerome Forissier &lt;jerome.forissier@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
[JW: backport to stable-4.19 + update commit message]
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tee: fix put order in teedev_close_context()</title>
<updated>2022-01-27T08:04:17Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2021-06-15T20:23:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=564a7ca7b4b657d5cbe41c9240fef44faebb6266'/>
<id>urn:sha1:564a7ca7b4b657d5cbe41c9240fef44faebb6266</id>
<content type='text'>
[ Upstream commit f18397ab3ae23e8e43bba9986e66af6d4497f2ad ]

Prior to this patch was teedev_close_context() calling tee_device_put()
before teedev_ctx_put() leading to teedev_ctx_release() accessing
ctx-&gt;teedev just after the reference counter was decreased on the
teedev. Fix this by calling teedev_ctx_put() before tee_device_put().

Fixes: 217e0250cccb ("tee: use reference counting for tee_context")
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>tee: check shm references are consistent in offset/size</title>
<updated>2018-05-07T09:51:03Z</updated>
<author>
<name>Etienne Carriere</name>
</author>
<published>2018-04-29T12:22:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ab9d3db5b320a052452b9cd035599ee3c84bbee9'/>
<id>urn:sha1:ab9d3db5b320a052452b9cd035599ee3c84bbee9</id>
<content type='text'>
This change prevents userland from referencing TEE shared memory
outside the area initially allocated by its owner. Prior this change an
application could not reference or access memory it did not own but
it could reference memory not explicitly allocated by owner but still
allocated to the owner due to the memory allocation granule.

Reported-by: Alexandre Jutras &lt;alexandre.jutras@nxp.com&gt;
Signed-off-by: Etienne Carriere &lt;etienne.carriere@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: correct max value for id allocation</title>
<updated>2018-03-06T10:03:55Z</updated>
<author>
<name>Peng Fan</name>
</author>
<published>2018-01-15T09:27:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7dd003aec2016e90d33f25f90ad4cebb12224a8a'/>
<id>urn:sha1:7dd003aec2016e90d33f25f90ad4cebb12224a8a</id>
<content type='text'>
The privileged dev id range is [TEE_NUM_DEVICES / 2, TEE_NUM_DEVICES).
The non-privileged dev id range is [0, TEE_NUM_DEVICES / 2).

So when finding a slot for them, need to use different max value.

Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'tee-drv-dynamic-shm-for-v4.16' of https://git.linaro.org/people/jens.wiklander/linux-tee into next/drivers</title>
<updated>2017-12-21T16:23:52Z</updated>
<author>
<name>Arnd Bergmann</name>
</author>
<published>2017-12-21T16:23:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bad19e0d0460564a067f901b6848c0cc0c403c52'/>
<id>urn:sha1:bad19e0d0460564a067f901b6848c0cc0c403c52</id>
<content type='text'>
Pull "tee dynamic shm for v4.16" from Jens Wiklander:

This pull request enables dynamic shared memory support in the TEE
subsystem as a whole and in OP-TEE in particular.

Global Platform TEE specification [1] allows client applications
to register part of own memory as a shared buffer between
application and TEE. This allows fast zero-copy communication between
TEE and REE. But current implementation of TEE in Linux does not support
this feature.

Also, current implementation of OP-TEE transport uses fixed size
pre-shared buffer for all communications with OP-TEE OS. This is okay
in the most use cases. But this prevents use of OP-TEE in virtualized
environments, because:
 a) We can't share the same buffer between different virtual machines
 b) Physically contiguous memory as seen by VM can be non-contiguous
    in reality (and as seen by OP-TEE OS) due to second stage of
    MMU translation.
 c) Size of this pre-shared buffer is limited.

So, first part of this pull request adds generic register/unregister
interface to tee subsystem. The second part adds necessary features into
OP-TEE driver, so it can use not only static pre-shared buffer, but
whole RAM to communicate with OP-TEE OS.

This change is backwards compatible allowing older secure world or
user space to work with newer kernels and vice versa.

[1] https://www.globalplatform.org/specificationsdevice.asp

* tag 'tee-drv-dynamic-shm-for-v4.16' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: shm: inline tee_shm_get_id()
  tee: use reference counting for tee_context
  tee: optee: enable dynamic SHM support
  tee: optee: add optee-specific shared pool implementation
  tee: optee: store OP-TEE capabilities in private data
  tee: optee: add registered buffers handling into RPC calls
  tee: optee: add registered shared parameters handling
  tee: optee: add shared buffer registration functions
  tee: optee: add page list manipulation functions
  tee: optee: Update protocol definitions
  tee: shm: add page accessor functions
  tee: shm: add accessors for buffer size and page offset
  tee: add register user memory
  tee: flexible shared memory pool creation
</content>
</entry>
<entry>
<title>tee: use reference counting for tee_context</title>
<updated>2017-12-15T12:36:18Z</updated>
<author>
<name>Volodymyr Babchuk</name>
</author>
<published>2017-11-29T12:48:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=217e0250cccb9e54d457991446cd3fab413085e1'/>
<id>urn:sha1:217e0250cccb9e54d457991446cd3fab413085e1</id>
<content type='text'>
We need to ensure that tee_context is present until last
shared buffer will be freed.

Signed-off-by: Volodymyr Babchuk &lt;vlad.babchuk@gmail.com&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: add register user memory</title>
<updated>2017-12-15T12:32:20Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2017-11-29T12:48:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=033ddf12bcf5326b93bd604f50a7474a434a35f9'/>
<id>urn:sha1:033ddf12bcf5326b93bd604f50a7474a434a35f9</id>
<content type='text'>
Added new ioctl to allow users register own buffers as a shared memory.

Signed-off-by: Volodymyr Babchuk &lt;vlad.babchuk@gmail.com&gt;
[jw: moved tee_shm_is_registered() declaration]
[jw: added space after __tee_shm_alloc() implementation]
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: add TEE_IOCTL_PARAM_ATTR_META</title>
<updated>2017-11-29T09:37:13Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2016-12-23T12:13:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f2aa97240c84b8f258710e297ba60048bd9c153e'/>
<id>urn:sha1:f2aa97240c84b8f258710e297ba60048bd9c153e</id>
<content type='text'>
Adds TEE_IOCTL_PARAM_ATTR_META which can be used to indicate meta
parameters when communicating with user space. These meta parameters can
be used by supplicant support multiple parallel requests at a time.

Reviewed-by: Etienne Carriere &lt;etienne.carriere@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: add tee_param_is_memref() for driver use</title>
<updated>2017-11-29T09:37:13Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2016-12-23T12:13:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=84debcc53533f162bf11f24e6a503d227c175cbe'/>
<id>urn:sha1:84debcc53533f162bf11f24e6a503d227c175cbe</id>
<content type='text'>
Reviewed-by: Etienne Carriere &lt;etienne.carriere@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: indicate privileged dev in gen_caps</title>
<updated>2017-08-04T08:30:27Z</updated>
<author>
<name>Jens Wiklander</name>
</author>
<published>2017-02-16T08:07:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=059cf566e123ca7eb7434285c6455d7afafb4e02'/>
<id>urn:sha1:059cf566e123ca7eb7434285c6455d7afafb4e02</id>
<content type='text'>
Mirrors the TEE_DESC_PRIVILEGED bit of struct tee_desc:flags into struct
tee_ioctl_version_data:gen_caps as TEE_GEN_CAP_PRIVILEGED in
tee_ioctl_version()

Reviewed-by: Jerome Forissier &lt;jerome.forissier@linaro.org&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
</feed>
