Commit 55fd072a authored by T.J. Mercier's avatar T.J. Mercier Committed by Lee Jones
Browse files

UPSTREAM: dma-buf: heaps: Fix off-by-one in CMA heap fault handler



commit ea5ff5d3 upstream.

Until VM_DONTEXPAND was added in commit 1c1914d6 ("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: default avatarXingyu Jin <xingyuj@google.com>
Fixes: a5d2d29e ("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: default avatarT.J. Mercier <tjmercier@google.com>
Acked-by: default avatarJohn Stultz <jstultz@google.com>
Signed-off-by: default avatarSumit Semwal <sumit.semwal@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240830192627.2546033-1-tjmercier@google.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 79cce5e8)
Signed-off-by: default avatarLee Jones <joneslee@google.com>
Change-Id: Ifc9c940e0a3cd721d29c783753b0dfd13a8aafc6
parent 5f2796bf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment