All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: David Hildenbrand <david@redhat.com>
Cc: kvm@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-mm@kvack.org, amd-gfx@lists.freedesktop.org,
	"H . Peter Anvin" <hpa@zytor.com>,
	David Airlie <airlied@gmail.com>,
	x86@kernel.org, Matthew Wilcox <willy@infradead.org>,
	Jason Gunthorpe <jgg@ziepe.ca>, Ingo Molnar <mingo@redhat.com>,
	Jason Gunthorpe <jgg@nvidia.com>, Arnd Bergmann <arnd@arndb.de>,
	John Hubbard <jhubbard@nvidia.com>,
	Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-sgx@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	Dimitri Sivanich <dimitri.sivanich@hpe.com>,
	Lorenzo Stoakes <lstoakes@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Xinhui Pan <Xinhui.Pan@amd.com>,
	linux-kernel@vger.kernel.org,
	Christian Konig <christian.koenig@amd.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	Daniel Vetter <daniel@ffwll.ch>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pavel Begunkov <asml.silence@gmail.com>
Subject: Re: [PATCH v5 1/6] mm/gup: remove unused vmas parameter from get_user_pages()
Date: Tue, 16 May 2023 07:30:01 -0700	[thread overview]
Message-ID: <ZGOTadDG/b0904YI@google.com> (raw)
In-Reply-To: <b97e8c2a-b629-f597-d011-395071011f1b@redhat.com>

On Tue, May 16, 2023, David Hildenbrand wrote:
> On 15.05.23 21:07, Sean Christopherson wrote:
> > On Sun, May 14, 2023, Lorenzo Stoakes wrote:
> > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > > index cb5c13eee193..eaa5bb8dbadc 100644
> > > --- a/virt/kvm/kvm_main.c
> > > +++ b/virt/kvm/kvm_main.c
> > > @@ -2477,7 +2477,7 @@ static inline int check_user_page_hwpoison(unsigned long addr)
> > >   {
> > >   	int rc, flags = FOLL_HWPOISON | FOLL_WRITE;
> > > -	rc = get_user_pages(addr, 1, flags, NULL, NULL);
> > > +	rc = get_user_pages(addr, 1, flags, NULL);
> > >   	return rc == -EHWPOISON;
> > 
> > Unrelated to this patch, I think there's a pre-existing bug here.  If gup() returns
> > a valid page, KVM will leak the refcount and unintentionally pin the page.  That's
> 
> When passing NULL as "pages" to get_user_pages(), __get_user_pages_locked()
> won't set FOLL_GET. As FOLL_PIN is also not set, we won't be messing with
> the mapcount of the page.

Ah, that's what I'm missing.

> So even if get_user_pages() returns "1", we should be fine.
> 
> 
> Or am I misunderstanding your concern?

Nope, you covered everything.  I do think we can drop the extra gup() though,
AFAICT it's 100% redundant.  But it's not a bug.

Thanks!

WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: David Hildenbrand <david@redhat.com>
Cc: Lorenzo Stoakes <lstoakes@gmail.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Matthew Wilcox <willy@infradead.org>,
	x86@kernel.org, linux-sgx@vger.kernel.org,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	kvm@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	"H . Peter Anvin" <hpa@zytor.com>,
	Xinhui Pan <Xinhui.Pan@amd.com>, David Airlie <airlied@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	Dimitri Sivanich <dimitri.sivanich@hpe.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Paolo Bonzini <pbonzini@redhat.com>, Jens Axboe <axboe@kernel.dk>,
	Pavel Begunkov <asml.silence@gmail.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>,
	Christian Konig <christian.koenig@amd.com>,
	Jason Gunthorpe <jgg@nvidia.com>
Subject: Re: [PATCH v5 1/6] mm/gup: remove unused vmas parameter from get_user_pages()
Date: Tue, 16 May 2023 07:30:01 -0700	[thread overview]
Message-ID: <ZGOTadDG/b0904YI@google.com> (raw)
In-Reply-To: <b97e8c2a-b629-f597-d011-395071011f1b@redhat.com>

On Tue, May 16, 2023, David Hildenbrand wrote:
> On 15.05.23 21:07, Sean Christopherson wrote:
> > On Sun, May 14, 2023, Lorenzo Stoakes wrote:
> > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > > index cb5c13eee193..eaa5bb8dbadc 100644
> > > --- a/virt/kvm/kvm_main.c
> > > +++ b/virt/kvm/kvm_main.c
> > > @@ -2477,7 +2477,7 @@ static inline int check_user_page_hwpoison(unsigned long addr)
> > >   {
> > >   	int rc, flags = FOLL_HWPOISON | FOLL_WRITE;
> > > -	rc = get_user_pages(addr, 1, flags, NULL, NULL);
> > > +	rc = get_user_pages(addr, 1, flags, NULL);
> > >   	return rc == -EHWPOISON;
> > 
> > Unrelated to this patch, I think there's a pre-existing bug here.  If gup() returns
> > a valid page, KVM will leak the refcount and unintentionally pin the page.  That's
> 
> When passing NULL as "pages" to get_user_pages(), __get_user_pages_locked()
> won't set FOLL_GET. As FOLL_PIN is also not set, we won't be messing with
> the mapcount of the page.

Ah, that's what I'm missing.

> So even if get_user_pages() returns "1", we should be fine.
> 
> 
> Or am I misunderstanding your concern?

Nope, you covered everything.  I do think we can drop the extra gup() though,
AFAICT it's 100% redundant.  But it's not a bug.

Thanks!

WARNING: multiple messages have this Message-ID (diff)
From: Sean Christopherson <seanjc@google.com>
To: David Hildenbrand <david@redhat.com>
Cc: kvm@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-mm@kvack.org, amd-gfx@lists.freedesktop.org,
	"H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Matthew Wilcox <willy@infradead.org>,
	Jason Gunthorpe <jgg@ziepe.ca>, Ingo Molnar <mingo@redhat.com>,
	Jason Gunthorpe <jgg@nvidia.com>, Arnd Bergmann <arnd@arndb.de>,
	John Hubbard <jhubbard@nvidia.com>,
	Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-sgx@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	Dimitri Sivanich <dimitri.sivanich@hpe.com>,
	Lorenzo Stoakes <lstoakes@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Xinhui Pan <Xinhui.Pan@amd.com>,
	linux-kernel@vger.kernel.org,
	Christian Konig <christian.koenig@amd.com>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pavel Begunkov <asml.silence@gmail.com>
Subject: Re: [PATCH v5 1/6] mm/gup: remove unused vmas parameter from get_user_pages()
Date: Tue, 16 May 2023 07:30:01 -0700	[thread overview]
Message-ID: <ZGOTadDG/b0904YI@google.com> (raw)
In-Reply-To: <b97e8c2a-b629-f597-d011-395071011f1b@redhat.com>

On Tue, May 16, 2023, David Hildenbrand wrote:
> On 15.05.23 21:07, Sean Christopherson wrote:
> > On Sun, May 14, 2023, Lorenzo Stoakes wrote:
> > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > > index cb5c13eee193..eaa5bb8dbadc 100644
> > > --- a/virt/kvm/kvm_main.c
> > > +++ b/virt/kvm/kvm_main.c
> > > @@ -2477,7 +2477,7 @@ static inline int check_user_page_hwpoison(unsigned long addr)
> > >   {
> > >   	int rc, flags = FOLL_HWPOISON | FOLL_WRITE;
> > > -	rc = get_user_pages(addr, 1, flags, NULL, NULL);
> > > +	rc = get_user_pages(addr, 1, flags, NULL);
> > >   	return rc == -EHWPOISON;
> > 
> > Unrelated to this patch, I think there's a pre-existing bug here.  If gup() returns
> > a valid page, KVM will leak the refcount and unintentionally pin the page.  That's
> 
> When passing NULL as "pages" to get_user_pages(), __get_user_pages_locked()
> won't set FOLL_GET. As FOLL_PIN is also not set, we won't be messing with
> the mapcount of the page.

Ah, that's what I'm missing.

> So even if get_user_pages() returns "1", we should be fine.
> 
> 
> Or am I misunderstanding your concern?

Nope, you covered everything.  I do think we can drop the extra gup() though,
AFAICT it's 100% redundant.  But it's not a bug.

Thanks!

  reply	other threads:[~2023-05-16 14:30 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-14 21:26 [PATCH v5 0/6] remove the vmas parameter from GUP APIs Lorenzo Stoakes
2023-05-14 21:26 ` [PATCH v5 1/6] mm/gup: remove unused vmas parameter from get_user_pages() Lorenzo Stoakes
2023-05-14 21:26   ` Lorenzo Stoakes
2023-05-14 21:26   ` Lorenzo Stoakes
2023-05-15 11:48   ` Christoph Hellwig
2023-05-15 11:48     ` Christoph Hellwig
2023-05-15 19:07   ` Sean Christopherson
2023-05-15 19:07     ` Sean Christopherson
2023-05-15 19:07     ` Sean Christopherson
2023-05-16 10:21     ` David Hildenbrand
2023-05-16 10:21       ` David Hildenbrand
2023-05-16 10:21       ` David Hildenbrand
2023-05-16 14:30       ` Sean Christopherson [this message]
2023-05-16 14:30         ` Sean Christopherson
2023-05-16 14:30         ` Sean Christopherson
2023-05-16 14:35         ` David Hildenbrand
2023-05-16 14:35           ` David Hildenbrand
2023-05-16 14:35           ` David Hildenbrand
2023-05-16 17:03           ` John Hubbard
2023-05-16 17:03             ` John Hubbard
2023-05-16 17:03             ` John Hubbard
2023-05-14 21:26 ` [PATCH v5 2/6] mm/gup: remove unused vmas parameter from pin_user_pages_remote() Lorenzo Stoakes
2023-05-15 11:48   ` Christoph Hellwig
2023-05-14 21:26 ` [PATCH v5 3/6] mm/gup: remove vmas parameter from get_user_pages_remote() Lorenzo Stoakes
2023-05-15 11:49   ` Christoph Hellwig
2023-05-15 11:49     ` Christoph Hellwig
2023-05-16  9:49   ` Anders Roxell
2023-05-16  9:49     ` Anders Roxell
2023-05-16 18:37     ` Lorenzo Stoakes
2023-05-16 18:37       ` Lorenzo Stoakes
2023-05-16 22:02     ` Andrew Morton
2023-05-16 22:02       ` Andrew Morton
2023-05-14 21:26 ` [PATCH v5 4/6] io_uring: rsrc: delegate VMA file-backed check to GUP Lorenzo Stoakes
2023-05-15 11:50   ` Christoph Hellwig
2023-05-15 19:55   ` Jens Axboe
2023-05-16  8:25     ` David Hildenbrand
2023-05-16 13:19       ` Jens Axboe
2023-05-16  8:28   ` David Hildenbrand
2023-05-14 21:26 ` [PATCH v5 5/6] mm/gup: remove vmas parameter from pin_user_pages() Lorenzo Stoakes
2023-05-14 21:26   ` Lorenzo Stoakes
2023-05-15 11:50   ` Christoph Hellwig
2023-05-15 11:50     ` Christoph Hellwig
2023-05-15 11:50     ` Christoph Hellwig
2023-05-17 13:04   ` Sakari Ailus
2023-05-17 13:04     ` Sakari Ailus
2023-05-14 21:27 ` [PATCH v5 6/6] mm/gup: remove vmas array from internal GUP functions Lorenzo Stoakes
2023-05-15 11:50   ` Christoph Hellwig
2023-05-15 19:56   ` John Hubbard

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=ZGOTadDG/b0904YI@google.com \
    --to=seanjc@google.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arnd@arndb.de \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=bp@alien8.de \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=david@redhat.com \
    --cc=dimitri.sivanich@hpe.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=lstoakes@gmail.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=willy@infradead.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.