diff options
author | Axel Rasmussen <axelrasmussen@google.com> | 2022-06-10 10:38:12 -0700 |
---|---|---|
committer | akpm <akpm@linux-foundation.org> | 2022-07-03 15:42:32 -0700 |
commit | 73f37dbcfe1763ee2294c7717a1f571e27d17fd8 (patch) | |
tree | 9aa244594be59eeb038b115708db562bc3d2b114 /arch/sh | |
parent | 03c765b0e3b4cb5063276b086c76f7a612856a9a (diff) | |
download | linux-stable-73f37dbcfe1763ee2294c7717a1f571e27d17fd8.tar.gz linux-stable-73f37dbcfe1763ee2294c7717a1f571e27d17fd8.tar.bz2 linux-stable-73f37dbcfe1763ee2294c7717a1f571e27d17fd8.zip |
mm: userfaultfd: fix UFFDIO_CONTINUE on fallocated shmem pages
When fallocate() is used on a shmem file, the pages we allocate can end up
with !PageUptodate.
Since UFFDIO_CONTINUE tries to find the existing page the user wants to
map with SGP_READ, we would fail to find such a page, since
shmem_getpage_gfp returns with a "NULL" pagep for SGP_READ if it discovers
!PageUptodate. As a result, UFFDIO_CONTINUE returns -EFAULT, as it would
do if the page wasn't found in the page cache at all.
This isn't the intended behavior. UFFDIO_CONTINUE is just trying to find
if a page exists, and doesn't care whether it still needs to be cleared or
not. So, instead of SGP_READ, pass in SGP_NOALLOC. This is the same,
except for one critical difference: in the !PageUptodate case, SGP_NOALLOC
will clear the page and then return it. With this change, UFFDIO_CONTINUE
works properly (succeeds) on a shmem file which has been fallocated, but
otherwise not modified.
Link: https://lkml.kernel.org/r/20220610173812.1768919-1-axelrasmussen@google.com
Fixes: 153132571f02 ("userfaultfd/shmem: support UFFDIO_CONTINUE for shmem")
Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>
Acked-by: Peter Xu <peterx@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'arch/sh')
0 files changed, 0 insertions, 0 deletions