linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Peter Xu <peterx@redhat.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: Nadav Amit <nadav.amit@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	syzbot+d8426b591c36b21c750e@syzkaller.appspotmail.com
Subject: Re: [PATCH] mm/userfaultfd: Reset ptes when close() for wr-protected ones
Date: Mon, 22 Apr 2024 17:09:26 +0200	[thread overview]
Message-ID: <4328e879-f5dc-4b90-89bd-d7969afba350@redhat.com> (raw)
In-Reply-To: <20240422133311.2987675-1-peterx@redhat.com>

On 22.04.24 15:33, Peter Xu wrote:
> Userfaultfd unregister includes a step to remove wr-protect bits from all
> the relevant pgtable entries, but that only covered an explicit
> UFFDIO_UNREGISTER ioctl, not a close() on the userfaultfd itself.  Cover
> that too.
> 
> Link: https://lore.kernel.org/all/000000000000ca4df20616a0fe16@google.com/
> Analyzed-by: David Hildenbrand <david@redhat.com>
> Reported-by: syzbot+d8426b591c36b21c750e@syzkaller.appspotmail.com
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>   fs/userfaultfd.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
> index 3e6ddda6f159..d2c3879745e5 100644
> --- a/fs/userfaultfd.c
> +++ b/fs/userfaultfd.c
> @@ -898,6 +898,10 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
>   			prev = vma;
>   			continue;
>   		}
> +		/* Reset ptes for the whole vma range if wr-protected */
> +		if (userfaultfd_wp(vma))
> +			uffd_wp_range(vma, vma->vm_start,
> +				      vma->vm_end - vma->vm_start, false);
>   		new_flags = vma->vm_flags & ~__VM_UFFD_FLAGS;
>   		vma = vma_modify_flags_uffd(&vmi, prev, vma, vma->vm_start,
>   					    vma->vm_end, new_flags,

LGTM

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-04-22 15:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 13:33 Peter Xu
2024-04-22 15:09 ` David Hildenbrand [this message]
2024-04-22 19:47 ` Andrew Morton
2024-04-22 21:08   ` Peter Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4328e879-f5dc-4b90-89bd-d7969afba350@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nadav.amit@gmail.com \
    --cc=peterx@redhat.com \
    --cc=syzbot+d8426b591c36b21c750e@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox