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. Reported-by:Xingyu 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:
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>
-
mentioned in commit cd227937
-
mentioned in commit efda96a3
-
mentioned in commit 8ccaede7
-
mentioned in commit 9b6fc2bc
-
mentioned in commit 0ed5daa7
-
mentioned in commit 55fd072a
-
mentioned in commit b39bede9
-
mentioned in commit 93d7ac63
-
mentioned in commit 7e6427a0
-
mentioned in commit ffb95009
-
mentioned in commit 8434c92b
-
mentioned in commit 8a2060bf
-
mentioned in commit 28959046
-
mentioned in commit 0bf42be7
-
mentioned in commit d5b332d0
-
mentioned in commit 1c775377
-
mentioned in commit 31a4a67b
-
mentioned in commit c4cd0bca
-
mentioned in commit f124355e
-
mentioned in commit b877b7c1
-
mentioned in commit fd48f580
-
mentioned in commit 001d613e
-
mentioned in commit 3c0def32
-
mentioned in commit 48c8cec6
-
mentioned in commit 534fb7b0
-
mentioned in commit 5ab6ca61
-
mentioned in commit 35fae635
-
mentioned in commit 43283148
-
mentioned in commit fc735645
-
mentioned in commit db208de4
-
mentioned in commit 8962b1cc
-
mentioned in commit 5cca89bb
-
mentioned in commit bb26f73c
-
mentioned in commit 45b55744
-
mentioned in commit ecfdf980
-
mentioned in commit 27acbcf7