Skip to content

userfaultfd shmem updates

Andrea Arcangeli linux-mm lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 3 repliesIn review 4 of 5 applied

Patches in v1 4 of 5 applied

#Subject and filesSizeRepliesApplied
1/5userfaultfd: use ENOENT instead of EFAULT if the atomic copy user failsmm/hugetlb.c mm/shmem.c mm/userfaultfd.c+5 -50 repliesApplied
2/5userfaultfd: shmem: allocate anonymous memory for MAP_PRIVATE shmemmm/userfaultfd.c+13 -20 repliesApplied
3/5userfaultfd: shmem/hugetlbfs: only allow to register VM_MAYWRITE vmasfs/userfaultfd.c mm/userfaultfd.c+21 -90 repliesApplied
4/5userfaultfd: shmem: add i_size checksmm/shmem.c mm/userfaultfd.c+40 -42 repliesApplied
5/5userfaultfd: shmem: UFFDIO_COPY: set the page dirty if VM_WRITE is not setmm/shmem.c+11 -01 reply

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchMike RapoportHugh Dickins
1/5R-b R-b
2/5R-b
3/5R-b R-b
4/5R-b R-b R-b R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] userfaultfd shmem updates

Hello,

Jann found two bugs in the userfaultfd shmem MAP_SHARED backend: the lack of the VM_MAYWRITE check and the lack of i_size checks.

Then looking into the above we also fixed the MAP_PRIVATE case.

Hugh by source review also found a data loss source if UFFDIO_COPY is used on shmem MAP_SHARED PROT_READ mappings (the production usages incidentally run with PROT_READ|PROT_WRITE, so the data loss couldn't happen in those production usages like with QEMU).

The whole patchset is marked for stable.

We verified QEMU postcopy live migration with guest running on shmem MAP_PRIVATE run as well as before after the fix of shmem MAP_PRIVATE. Regardless if it's shmem or hugetlbfs or MAP_PRIVATE or MAP_SHARED, QEMU unconditionally invokes a punch hole if the guest mapping is filebacked and a MADV_DONTNEED too (needed to get rid of the MAP_PRIVATE COWs and for the anon backend).

Thank you,
Andrea

Andrea Arcangeli (5):
userfaultfd: use ENOENT instead of EFAULT if the atomic copy user
fails
userfaultfd: shmem: allocate anonymous memory for MAP_PRIVATE shmem
userfaultfd: shmem/hugetlbfs: only allow to register VM_MAYWRITE vmas
userfaultfd: shmem: add i_size checks
userfaultfd: shmem: UFFDIO_COPY: set the page dirty if VM_WRITE is not
set

 fs/userfaultfd.c | 15 ++++++++++++
 mm/hugetlb.c     |  2 +-
 mm/shmem.c       | 31 +++++++++++++++++++++---
 mm/userfaultfd.c | 62 +++++++++++++++++++++++++++++++++++-------------
 4 files changed, 90 insertions(+), 20 deletions(-)