android_kernel_xiaomi_sm8450/drivers/dma-buf
T.J. Mercier 9b6fc2bc30 UPSTREAM: dma-buf: heaps: Fix off-by-one in CMA heap fault handler
commit ea5ff5d351b520524019f7ff7f9ce418de2dad87 upstream.

Until VM_DONTEXPAND was added in commit 1c1914d6e8c6 ("dma-buf: heaps:
Don't track CMA dma-buf pages under RssFile") it was possible to obtain
a mapping larger than the buffer size via mremap and bypass the overflow
check in dma_buf_mmap_internal. When using such a mapping to attempt to
fault past the end of the buffer, the CMA heap fault handler also checks
the fault offset against the buffer size, but gets the boundary wrong by
1. Fix the boundary check so that we don't read off the end of the pages
array and insert an arbitrary page in the mapping.

Bug: 363259128
Reported-by: Xingyu Jin <xingyuj@google.com>
Fixes: a5d2d29e24be ("dma-buf: heaps: Move heap-helper logic into the cma_heap implementation")
Cc: stable@vger.kernel.org # Applicable >= 5.10. Needs adjustments only for 5.10.
Signed-off-by: T.J. Mercier <tjmercier@google.com>
Acked-by: John Stultz <jstultz@google.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240830192627.2546033-1-tjmercier@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 79cce5e81d20fa9ad553be439d665ac3302d3c95)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ifc9c940e0a3cd721d29c783753b0dfd13a8aafc6
2024-10-30 09:12:05 +00:00
..
heaps UPSTREAM: dma-buf: heaps: Fix off-by-one in CMA heap fault handler 2024-10-30 09:12:05 +00:00
dma-buf-sysfs-stats.c ANDROID: dma-buf: don't re-purpose kobject as work_struct 2022-12-13 21:11:56 +00:00
dma-buf-sysfs-stats.h ANDROID: Delete the DMA-BUF attachment sysfs statistics 2021-07-14 20:52:01 -07:00
dma-buf.c UPSTREAM: dma-buf: ensure unique directory name for dmabuf stats 2022-10-17 16:11:46 +00:00
dma-fence-array.c dma_fence_array: Fix PENDING_ERROR leak in dma_fence_array_signaled() 2022-01-27 10:53:43 +01:00
dma-fence-chain.c dma-buf: fence-chain: Document missing dma_fence_chain_init() parameter in kerneldoc 2020-09-03 17:47:02 +05:30
dma-fence.c UPSTREAM: dma-fence: allow signaling drivers to set fence timestamp 2021-04-07 14:17:51 +00:00
dma-heap.c This is the 5.10.157 stable release 2022-12-04 12:51:21 +00:00
dma-resv.c dma-buf/dma-resv: Respect num_fences when initializing the shared fence list. 2020-12-30 11:54:26 +01:00
Kconfig UPSTREAM: dma-buf: DMABUF_SYSFS_STATS should depend on DMA_SHARED_BUFFER 2022-11-09 13:57:12 +00:00
Makefile BACKPORT: FROMLIST: dmabuf: Add the capability to expose DMA-BUF stats in sysfs 2021-02-02 18:47:43 +00:00
selftest.c
selftest.h
selftests.h Merge drm/drm-next into drm-intel-next-queued 2020-06-25 18:05:03 +03:00
seqno-fence.c
st-dma-fence-chain.c dma-buf: fix dma-fence-chain out of order test 2020-07-02 15:21:40 +02:00
st-dma-fence.c
sw_sync.c dma-buf/sw_sync: Avoid recursive lock during fence signal 2023-08-30 16:23:19 +02:00
sync_debug.c dma-buf/sw-sync: don't enable IRQ from sync_print_obj() 2024-06-16 13:32:28 +02:00
sync_debug.h
sync_file.c dma-buf/sync_file: Don't leak fences on merge failure 2021-07-25 14:36:20 +02:00
sync_trace.h
udmabuf.c udmabuf: Set ubuf->sg = NULL if the creation of sg table fails 2022-10-26 13:25:48 +02:00