]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/shmem: Fix race in shmem_undo_range w/THP
authorDavid Stevens <stevensd@chromium.org>
Tue, 18 Apr 2023 08:40:31 +0000 (17:40 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 21 Apr 2023 23:07:52 +0000 (16:07 -0700)
commitbaac0f9f362db62d80ce0017b530436c34a53e8c
treee5227028ec0055a571f1212707757f2d2252a2c6
parent7f57dade6ab5cf06d45294805852e41bfeece2f1
mm/shmem: Fix race in shmem_undo_range w/THP

Split folios during the second loop of shmem_undo_range.  It's not
sufficient to only split folios when dealing with partial pages, since
it's possible for a THP to be faulted in after that point.  Calling
truncate_inode_folio in that situation can result in throwing away data
outside of the range being targeted.

Link: https://lkml.kernel.org/r/20230418084031.3439795-1-stevensd@google.com
Fixes: b9a8a4195c7d ("truncate,shmem: Handle truncates that split large folios")
Signed-off-by: David Stevens <stevensd@chromium.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Suleiman Souhlal <suleiman@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shmem.c