kernel_samsung_a53x/drivers/dma-buf
T.J. Mercier 9b399ee577 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
2025-01-19 00:09:58 +01:00
..
heaps UPSTREAM: dma-buf: heaps: Fix off-by-one in CMA heap fault handler 2025-01-19 00:09:58 +01:00
dma-buf-sysfs-stats.c
dma-buf-sysfs-stats.h
dma-buf.c
dma-fence-array.c dma-buf: fix dma_fence_array_signaled v4 2024-12-17 13:24:29 +01:00
dma-fence-chain.c
dma-fence.c
dma-heap.c
dma-resv.c
Kconfig
Makefile
selftest.c
selftest.h
selftests.h
seqno-fence.c
st-dma-fence-chain.c
st-dma-fence.c
sw_sync.c
sync_debug.c dma-buf/sw-sync: don't enable IRQ from sync_print_obj() 2024-11-19 12:27:10 +01:00
sync_debug.h
sync_file.c dma-buf/sync_file: Speed up ioctl by omitting debug names 2024-11-19 17:53:23 +01:00
sync_trace.h
udmabuf.c udmabuf: also check for F_SEAL_FUTURE_WRITE 2025-01-15 16:29:47 +01:00