Files
linux/drivers
Greg Hackmann 78819480da staging: android: ion: fix ION_IOC_{MAP,SHARE} use-after-free
This patch is 4.9.y only.  Kernels 4.12 and later are unaffected, since
all the underlying ion_handle infrastructure has been ripped out.

The ION_IOC_{MAP,SHARE} ioctls drop and reacquire client->lock several
times while operating on one of the client's ion_handles.  This creates
windows where userspace can call ION_IOC_FREE on the same client with
the same handle, and effectively make the kernel drop its own reference.
For example:

- thread A: ION_IOC_ALLOC creates an ion_handle with refcount 1
- thread A: starts ION_IOC_MAP and increments the refcount to 2
- thread B: ION_IOC_FREE decrements the refcount to 1
- thread B: ION_IOC_FREE decrements the refcount to 0 and frees the
            handle
- thread A: continues ION_IOC_MAP with a dangling ion_handle * to
            freed memory

Fix this by holding client->lock for the duration of
ION_IOC_{MAP,SHARE}, preventing the concurrent ION_IOC_FREE.  Also
remove ion_handle_get_by_id(), since there's literally no way to use it
safely.

Cc: stable@vger.kernel.org # v4.11-
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-12 17:15:23 +09:00
..
2023-05-12 16:27:16 +09:00
2023-05-12 16:28:00 +09:00
2018-07-03 18:27:19 +02:00
2018-05-30 13:19:56 +02:00
2018-06-06 18:34:12 +02:00
2018-05-30 13:19:56 +02:00
2018-02-25 11:05:55 +01:00
2023-05-12 16:57:29 +09:00
2017-09-09 17:39:41 +02:00
2018-05-25 17:06:35 +02:00
2023-05-12 17:14:58 +09:00
2023-05-12 17:05:02 +09:00
2018-06-26 09:32:02 +08:00
2018-04-30 06:05:25 -07:00
2023-05-12 16:37:13 +09:00
2018-07-03 18:27:19 +02:00