diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 830f620f9ad2..ce0e23398482 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -27,6 +27,7 @@ #include #include #include +#include int sysctl_unprivileged_userfaultfd __read_mostly = 1; @@ -1480,7 +1481,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, * the next vma was merged into the current one and * the current one has not been updated yet. */ - vma->vm_flags = new_flags; + vma->vm_flags = vma_pad_fixup_flags(vma, new_flags); vma->vm_userfaultfd_ctx.ctx = ctx; skip: @@ -1643,7 +1644,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx, * the next vma was merged into the current one and * the current one has not been updated yet. */ - vma->vm_flags = new_flags; + vma->vm_flags = vma_pad_fixup_flags(vma, new_flags); vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX; skip: diff --git a/mm/madvise.c b/mm/madvise.c index ed1fffbe6f03..890630a670e4 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -167,7 +167,7 @@ success: /* * vm_flags is protected by the mmap_sem held in write mode. */ - vma->vm_flags = new_flags; + vma->vm_flags = vma_pad_fixup_flags(vma, new_flags); out_convert_errno: /*