linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Suren Baghdasaryan <surenb@google.com>, akpm@linux-foundation.org
Cc: sfr@canb.auug.org.au, peterx@redhat.com, aarcange@redhat.com,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	syzbot+705209281e36404998f6@syzkaller.appspotmail.com
Subject: Re: [PATCH 1/1] userfaultfd: avoid huge_zero_page in UFFDIO_MOVE
Date: Fri, 12 Jan 2024 09:57:12 +0100	[thread overview]
Message-ID: <511e07da-9b34-4707-8f5a-f1e534c4445a@redhat.com> (raw)
In-Reply-To: <20240112013935.1474648-1-surenb@google.com>

On 12.01.24 02:39, Suren Baghdasaryan wrote:
> While testing UFFDIO_MOVE ioctl, syzbot triggered VM_BUG_ON_PAGE caused
> by a call to PageAnonExclusive() with a huge_zero_page as a parameter.
> UFFDIO_MOVE does not yet handle zeropages and returns EBUSY when one is
> encountered. Add an early huge_zero_page check in the PMD move path
> to avoid this situation.
> 
> Reported-by: syzbot+705209281e36404998f6@syzkaller.appspotmail.com
> Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> ---
> Applies cleanly over linux-next, mm-stable and mm-unstable branches
> 
>   mm/userfaultfd.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
> index 216ab4c8621f..20e3b0d9cf7e 100644
> --- a/mm/userfaultfd.c
> +++ b/mm/userfaultfd.c
> @@ -1393,6 +1393,12 @@ ssize_t move_pages(struct userfaultfd_ctx *ctx, struct mm_struct *mm,
>   				err = -ENOENT;
>   				break;
>   			}
> +			/* Avoid moving zeropages for now */
> +			if (is_huge_zero_pmd(*src_pmd)) {
> +				spin_unlock(ptl);
> +				err = -EBUSY;
> +				break;
> +			}

As an alternative (and more future proof?) just reject anything that is 
not an anon folio as well?

Anyhow, this should handle the issue at hand.

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

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2024-01-12  8:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-12  1:39 Suren Baghdasaryan
2024-01-12  8:57 ` David Hildenbrand [this message]
2024-01-12 17:31   ` Suren Baghdasaryan

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=511e07da-9b34-4707-8f5a-f1e534c4445a@redhat.com \
    --to=david@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=sfr@canb.auug.org.au \
    --cc=surenb@google.com \
    --cc=syzbot+705209281e36404998f6@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