android_kernel_motorola_sm6375/include
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Jens Wiklander f1a1171f3c UPSTREAM: tee: handle lookup of shm with reference count 0
commit dfd0743f1d9ea76931510ed150334d571fbab49d upstream.

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->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->idr before releasing the mutex. This means that the tee_shm can
never be found unless it has a refcount larger than 0.

Fixes: 967c9cca2c ("tee: generic TEE subsystem")
Cc: stable@vger.kernel.org
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Lars Persson <larper@axis.com>
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Reported-by: Patrik Lantz <patrik.lantz@axis.com>
[JW: backport to 5.4-stable]
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Change-Id: Ibd2809a225b167563c65faff4a44e56e23c2e97b
2022-01-26 08:46:30 +00:00
..
acpi ACPI: fix NULL pointer dereference 2021-08-08 09:04:08 +02:00
asm-generic This is the 5.4.142 stable release 2021-08-27 16:27:13 +02:00
clocksource
crypto BACKPORT: crypto: blake2b - sync with blake2s implementation 2021-10-23 19:32:26 -07:00
drm This is the 5.4.136 stable release 2021-07-28 13:46:04 +02:00
dt-bindings
keys certs: Add EFI_CERT_X509_GUID support for dbx entries 2021-06-30 08:47:55 -04:00
kvm
linux UPSTREAM: tee: handle lookup of shm with reference count 0 2022-01-26 08:46:30 +00:00
math-emu
media Revert "media: subdev: disallow ioctl for saa6588/davinci" 2021-07-20 11:32:59 +02:00
misc
net Revert "net: sched: update default qdisc visibility after Tx queue cnt changes" 2021-11-19 13:42:39 +01:00
pcmcia
ras
rdma
scsi This is the 5.4.134 stable release 2021-07-20 16:30:12 +02:00
soc
sound This is the 5.4.104 stable release 2021-03-09 11:24:14 +01:00
target scsi: target: core: Add cmd length set before cmd complete 2021-03-17 17:03:45 +01:00
trace This is the 5.4.150 stable release 2021-10-01 14:08:40 +02:00
uapi Merge tag 'android11-5.4.161_r00' into android11-5.4 2022-01-21 08:26:49 +01:00
vdso
video
xen Xen/gntdev: correct error checking in gntdev_map_grant_pages() 2021-02-23 15:02:26 +01:00
OWNERS ANDROID: Add OWNERS files referring to the respective android-mainline OWNERS 2021-04-01 13:45:14 +00:00