Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Alex Williamson <alex@shazbot.org>, Fei Li <fei1.li@intel.com>,
	Peter Xu <peterx@redhat.com>,
	linux-s390@vger.kernel.org, linux-mm@kvack.org,
	Sergio Lopez <slp@redhat.com>
Subject: Re: [PATCH] mm: pull writability check to follow_pfnmap_start()
Date: Mon, 3 Aug 2026 10:55:24 +0200	[thread overview]
Message-ID: <0a9c8cc8-1fa7-4f4c-b7df-e847925c2b24@kernel.org> (raw)
In-Reply-To: <20260731160514.1101989-1-pbonzini@redhat.com>

On 7/31/26 18:05, Paolo Bonzini wrote:
> All callers of follow_pfnmap_start() except s390_pci_mmio_write() are
> following it, if they are doing a write, with a check that args.writable
> is true; for s390_pci_mmio_write() that's a bug.  Most of them return
> -EFAULT if it is not, but because follow_pfnmap_start() returned success,
> they do not attempt to upgrade the page from read-only to read-write
> with fixup_user_fault().
> 
> Pull the check directly into follow_pfnmap_start() through another
> input parameter args.write_fault; this eliminates the need to do it in
> the caller and, for callers that do use fixup_user_fault(), lets it
> attempt to upgrade the page.
> 
> The change in return code to -EFAULT is okay:
> 
> - s390 is the only one to have a functional change in this respect;
>   but EINVAL is only documented for "Invalid length argument", while
>   "The address in mmio_addr is invalid" should already return EFAULT
>   (https://www.man7.org/linux/man-pages/man2/s390_pci_mmio_read.2.html)
> 
> - for VFIO and ACRN, -EFAULT was returned already
> 
> - for KVM, -EFAULT is eaten
> 
> - for generic_access_phys() the caller is __access_remote_vm()
>   which does not care about the error code.
> 
> Reported-by: Sergio Lopez <slp@redhat.com>

Reported-by: without Fixes: is odd.

> Link: https://lore.kernel.org/kvm/CAAiTLFU1ALsDoJoKW3d9bUvv990AozAoX=bEHmfnG54qyBAHFg@mail.gmail.com/
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---

[...]

> index 485df9c2dbdd..34c79b5fcb9b 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -3136,9 +3136,12 @@ struct follow_pfnmap_args {
>  	 * Inputs:
>  	 * @vma: Pointer to @vm_area_struct struct
>  	 * @address: the virtual address to walk
> +	 * @write_fault: if true, fail with -EFAULT unless the mapping is

Just wondering whether EPERM would be better.

> +	 * writable
>  	 */
>  	struct vm_area_struct *vma;
>  	unsigned long address;
> +	bool write_fault;

"write_fault" is a rather odd name for this, given that this function will not
trigger a write fault.

You want something that matches FOLL_WRITE.

"write_access" / "check_writable" maybe?

-- 
Cheers,

David

      parent reply	other threads:[~2026-08-03  8:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 16:05 [PATCH] mm: pull writability check to follow_pfnmap_start() Paolo Bonzini
2026-07-31 16:20 ` sashiko-bot
2026-07-31 16:41   ` Paolo Bonzini
2026-08-03  8:55 ` David Hildenbrand (Arm) [this message]

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=0a9c8cc8-1fa7-4f4c-b7df-e847925c2b24@kernel.org \
    --to=david@kernel.org \
    --cc=alex@shazbot.org \
    --cc=fei1.li@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=slp@redhat.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