<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/drivers/tee, branch v5.16.19</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.16.19</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v5.16.19'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2022-02-23T11:05:54Z</updated>
<entry>
<title>optee: use driver internal tee_context for some rpc</title>
<updated>2022-02-23T11:05:54Z</updated>
<author>
<name>Jens Wiklander</name>
<email>jens.wiklander@linaro.org</email>
</author>
<published>2022-01-27T14:29:39Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f333857e0f857d69aea6c1fb49fbfb7cfdb69b1b'/>
<id>urn:sha1:f333857e0f857d69aea6c1fb49fbfb7cfdb69b1b</id>
<content type='text'>
commit aceeafefff736057e8f93f19bbfbef26abd94604 upstream.

Adds a driver private tee_context by moving the tee_context in struct
optee_notif to struct optee. This tee_context was previously used when
doing internal calls to secure world to deliver notification.

The new driver internal tee_context is now also when allocating driver
private shared memory. This decouples the shared memory object from its
original tee_context. This is needed when the life time of such a memory
allocation outlives the client tee_context.

This patch fixes the problem described below:

The addition of a shutdown hook by commit f25889f93184 ("optee: fix tee out
of memory failure seen during kexec reboot") introduced a kernel shutdown
regression that can be triggered after running the OP-TEE xtest suites.

Once the shutdown hook is called it is not possible to communicate any more
with the supplicant process because the system is not scheduling task any
longer. Thus if the optee driver shutdown path receives a supplicant RPC
request from the OP-TEE we will deadlock the kernel's shutdown.

Fixes: f25889f93184 ("optee: fix tee out of memory failure seen during kexec reboot")
Fixes: 217e0250cccb ("tee: use reference counting for tee_context")
Reported-by: Lars Persson &lt;larper@axis.com&gt;
Cc: stable@vger.kernel.org
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
[JW: backport to 5.16-stable + 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: export teedev_open() and teedev_close_context()</title>
<updated>2022-02-23T11:05:54Z</updated>
<author>
<name>Jens Wiklander</name>
<email>jens.wiklander@linaro.org</email>
</author>
<published>2021-10-04T14:11:52Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=b07508c74408b6704812812255ef37ff4ede0a61'/>
<id>urn:sha1:b07508c74408b6704812812255ef37ff4ede0a61</id>
<content type='text'>
[ Upstream commit 1e2c3ef0496e72ba9001da5fd1b7ed56ccb30597 ]

Exports the two functions teedev_open() and teedev_close_context() in
order to make it easier to create a driver internal struct 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>optee: add error checks in optee_ffa_do_call_with_arg()</title>
<updated>2022-02-16T11:58:27Z</updated>
<author>
<name>Jens Wiklander</name>
<email>jens.wiklander@linaro.org</email>
</author>
<published>2021-12-28T20:25:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7e246eb9c1519666e1330bb1b58c23b6a721498a'/>
<id>urn:sha1:7e246eb9c1519666e1330bb1b58c23b6a721498a</id>
<content type='text'>
[ Upstream commit 4064c461148ab129dfe5eaeea129b4af6cf4b9b7 ]

Adds error checking in optee_ffa_do_call_with_arg() for correctness.

Fixes: 4615e5a34b95 ("optee: add FF-A support")
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: optee: do not check memref size on return from Secure World</title>
<updated>2022-02-16T11:58:27Z</updated>
<author>
<name>Jerome Forissier</name>
<email>jerome@forissier.org</email>
</author>
<published>2022-01-13T15:27:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=306eb7325a386f8b37d6b477a2a11290c0359cd1'/>
<id>urn:sha1:306eb7325a386f8b37d6b477a2a11290c0359cd1</id>
<content type='text'>
[ Upstream commit abc8dc34d1f6e34ed346c6e3fc554127e421b769 ]

Commit c650b8dc7a79 ("tee: optee: do not check memref size on return
from Secure World") was mistakenly lost in commit 4602c5842f64 ("optee:
refactor driver with internal callbacks"). Remove the unwanted code
again.

Fixes: 4602c5842f64 ("optee: refactor driver with internal callbacks")
Signed-off-by: Jerome Forissier &lt;jerome@forissier.org&gt;
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: fix put order in teedev_close_context()</title>
<updated>2022-01-27T11:01:31Z</updated>
<author>
<name>Jens Wiklander</name>
<email>jens.wiklander@linaro.org</email>
</author>
<published>2021-06-15T20:23:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=034e93a7e9b0bf3838352ca02c0b9c6ea11ea295'/>
<id>urn:sha1:034e93a7e9b0bf3838352ca02c0b9c6ea11ea295</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>Merge tag 'arm-fixes-5.16-4' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc</title>
<updated>2021-12-23T17:22:34Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2021-12-23T17:22:34Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c8cc50a98e4fb58022c64008bf4157f8b7af47f2'/>
<id>urn:sha1:c8cc50a98e4fb58022c64008bf4157f8b7af47f2</id>
<content type='text'>
Pull ARM SoC fixes from Arnd Bergmann:
 "This is my last set of fixes for 5.16, including

   - multiple code fixes for the op-tee firmware driver

   - Two patches for allwinner SoCs, one fixing the phy mode on a board,
     the other one fixing a driver bug in the "RSB" bus driver. This was
     originally targeted for 5.17, but seemed worth moving to 5.16

   - Two small fixes for devicetree files on i.MX platforms, resolving
     problems with ethernet and i2c"

* tag 'arm-fixes-5.16-4' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc:
  optee: Suppress false positive kmemleak report in optee_handle_rpc()
  tee: optee: Fix incorrect page free bug
  arm64: dts: lx2160a: fix scl-gpios property name
  tee: handle lookup of shm with reference count 0
  ARM: dts: imx6qdl-wandboard: Fix Ethernet support
  bus: sunxi-rsb: Fix shutdown
  arm64: dts: allwinner: orangepi-zero-plus: fix PHY mode
</content>
</entry>
<entry>
<title>optee: Suppress false positive kmemleak report in optee_handle_rpc()</title>
<updated>2021-12-16T14:32:48Z</updated>
<author>
<name>Xiaolei Wang</name>
<email>xiaolei.wang@windriver.com</email>
</author>
<published>2021-12-06T12:05:33Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6add87fdae9bcb1d20b4503df5bd02ce5246cc8b'/>
<id>urn:sha1:6add87fdae9bcb1d20b4503df5bd02ce5246cc8b</id>
<content type='text'>
We observed the following kmemleak report:
unreferenced object 0xffff000007904500 (size 128):
  comm "swapper/0", pid 1, jiffies 4294892671 (age 44.036s)
  hex dump (first 32 bytes):
    00 47 90 07 00 00 ff ff 60 00 c0 ff 00 00 00 00  .G......`.......
    60 00 80 13 00 80 ff ff a0 00 00 00 00 00 00 00  `...............
  backtrace:
    [&lt;000000004c12b1c7&gt;] kmem_cache_alloc+0x1ac/0x2f4
    [&lt;000000005d23eb4f&gt;] tee_shm_alloc+0x78/0x230
    [&lt;00000000794dd22c&gt;] optee_handle_rpc+0x60/0x6f0
    [&lt;00000000d9f7c52d&gt;] optee_do_call_with_arg+0x17c/0x1dc
    [&lt;00000000c35884da&gt;] optee_open_session+0x128/0x1ec
    [&lt;000000001748f2ff&gt;] tee_client_open_session+0x28/0x40
    [&lt;00000000aecb5389&gt;] optee_enumerate_devices+0x84/0x2a0
    [&lt;000000003df18bf1&gt;] optee_probe+0x674/0x6cc
    [&lt;000000003a4a534a&gt;] platform_drv_probe+0x54/0xb0
    [&lt;000000000c51ce7d&gt;] really_probe+0xe4/0x4d0
    [&lt;000000002f04c865&gt;] driver_probe_device+0x58/0xc0
    [&lt;00000000b485397d&gt;] device_driver_attach+0xc0/0xd0
    [&lt;00000000c835f0df&gt;] __driver_attach+0x84/0x124
    [&lt;000000008e5a429c&gt;] bus_for_each_dev+0x70/0xc0
    [&lt;000000001735e8a8&gt;] driver_attach+0x24/0x30
    [&lt;000000006d94b04f&gt;] bus_add_driver+0x104/0x1ec

This is not a memory leak because we pass the share memory pointer
to secure world and would get it from secure world before releasing it.

Signed-off-by: Xiaolei Wang &lt;xiaolei.wang@windriver.com&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: optee: Fix incorrect page free bug</title>
<updated>2021-12-16T14:32:37Z</updated>
<author>
<name>Sumit Garg</name>
<email>sumit.garg@linaro.org</email>
</author>
<published>2021-12-16T05:47:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=18549bf4b21c739a9def39f27dcac53e27286ab5'/>
<id>urn:sha1:18549bf4b21c739a9def39f27dcac53e27286ab5</id>
<content type='text'>
Pointer to the allocated pages (struct page *page) has already
progressed towards the end of allocation. It is incorrect to perform
__free_pages(page, order) using this pointer as we would free any
arbitrary pages. Fix this by stop modifying the page pointer.

Fixes: ec185dd3ab25 ("optee: Fix memory leak when failing to register shm pages")
Cc: stable@vger.kernel.org
Reported-by: Patrik Lantz &lt;patrik.lantz@axis.com&gt;
Signed-off-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Reviewed-by: Tyler Hicks &lt;tyhicks@linux.microsoft.com&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: handle lookup of shm with reference count 0</title>
<updated>2021-12-16T08:30:14Z</updated>
<author>
<name>Jens Wiklander</name>
<email>jens.wiklander@linaro.org</email>
</author>
<published>2021-12-09T14:59:37Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=dfd0743f1d9ea76931510ed150334d571fbab49d'/>
<id>urn:sha1:dfd0743f1d9ea76931510ed150334d571fbab49d</id>
<content type='text'>
Since the tee subsystem does not keep a strong reference to its idle
shared memory buffers, it races with other threads that try to destroy a
shared memory through a close of its dma-buf fd or by unmapping the
memory.

In tee_shm_get_from_id() when a lookup in teedev-&gt;idr has been
successful, it is possible that the tee_shm is in the dma-buf teardown
path, but that path is blocked by the teedev mutex. Since we don't have
an API to tell if the tee_shm is in the dma-buf teardown path or not we
must find another way of detecting this condition.

Fix this by doing the reference counting directly on the tee_shm using a
new refcount_t refcount field. dma-buf is replaced by using
anon_inode_getfd() instead, this separates the life-cycle of the
underlying file from the tee_shm. tee_shm_put() is updated to hold the
mutex when decreasing the refcount to 0 and then remove the tee_shm from
teedev-&gt;idr before releasing the mutex. This means that the tee_shm can
never be found unless it has a refcount larger than 0.

Fixes: 967c9cca2cc5 ("tee: generic TEE subsystem")
Cc: stable@vger.kernel.org
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Reviewed-by: Lars Persson &lt;larper@axis.com&gt;
Reviewed-by: Sumit Garg &lt;sumit.garg@linaro.org&gt;
Reported-by: Patrik Lantz &lt;patrik.lantz@axis.com&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
<entry>
<title>tee: amdtee: fix an IS_ERR() vs NULL bug</title>
<updated>2021-11-29T08:55:49Z</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2021-11-24T14:54:04Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9d7482771fac8d8e38e763263f2ca0ca12dd22c6'/>
<id>urn:sha1:9d7482771fac8d8e38e763263f2ca0ca12dd22c6</id>
<content type='text'>
The __get_free_pages() function does not return error pointers it returns
NULL so fix this condition to avoid a NULL dereference.

Fixes: 757cc3e9ff1d ("tee: add AMD-TEE driver")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Acked-by: Rijo Thomas &lt;Rijo-john.Thomas@amd.com&gt;
Signed-off-by: Jens Wiklander &lt;jens.wiklander@linaro.org&gt;
</content>
</entry>
</feed>
