LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
stable <stable@vger.kernel.org>,
syzbot+6304bf97ef436580fede@syzkaller.appspotmail.com,
linux-mm <linux-mm@kvack.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Huang Ying <ying.huang@intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Thorsten Leemhuis <regressions@leemhuis.info>
Subject: Re: [PATCH] gup: return -EFAULT on access_ok failure
Date: Wed, 4 Apr 2018 19:40:36 -0700 [thread overview]
Message-ID: <CA+55aFwpe92MzEX2qRHO-MQsa1CP-iz6AmanFqXCV6_EaNKyMg@mail.gmail.com> (raw)
In-Reply-To: <20180405045231-mutt-send-email-mst@kernel.org>
On Wed, Apr 4, 2018 at 6:53 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
>
> Any feedback on this? As this fixes a bug in vhost, I'll merge
> through the vhost tree unless someone objects.
NAK.
__get_user_pages_fast() returns the number of pages it gets.
It has never returned an error code, and all the other versions of it
(architecture-specific) don't either.
If you ask for one page, and get zero pages, then that's an -EFAULT.
Note that that's an EFAULT regardless of whether that zero page
happened due to kernel addresses or just lack of mapping in user
space.
The documentation is simply wrong if it says anything else. Fix the
docs, and fix the users.
The correct use has always been to check the number of pages returned.
Just looking around, returning an error number looks like it could
seriously confuse some things. You have things like the kvm code that
does the *right* thing:
unsigned long ... npinned ...
npinned = get_user_pages_fast(uaddr, npages, write ?
FOLL_WRITE : 0, pages);
if (npinned != npages) {
...
err:
if (npinned > 0)
release_pages(pages, npinned);
and the above code clearly depends on the actual behavior, not on the
documentation.
Any changes in this area would need some *extreme* care, exactly
because of code like the above that clearly depends on the existing
semantics.
In fact, the documentation really seems to be just buggy. The actual
get_user_pages() function itself is expressly being careful *not* to
return an error code, it even has a comment to the effect ("Have to be
a bit careful with return values").
So the "If no pages were pinned, returns -errno" comment is just bogus.
Linus
next prev parent reply other threads:[~2018-04-05 2:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1522431382-4232-1-git-send-email-mst@redhat.com>
2018-04-05 1:53 ` Michael S. Tsirkin
2018-04-05 2:40 ` Linus Torvalds [this message]
2018-04-05 14:17 ` Michael S. Tsirkin
2018-04-05 15:40 ` Linus Torvalds
2018-04-05 18:28 ` Michael S. Tsirkin
2018-04-05 18:43 ` Linus Torvalds
2018-04-05 19:34 ` Michael S. Tsirkin
2018-04-05 19:39 ` Chris Wilson
2018-04-05 21:08 ` Michael S. Tsirkin
2018-04-06 11:35 ` Alan Cox
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=CA+55aFwpe92MzEX2qRHO-MQsa1CP-iz6AmanFqXCV6_EaNKyMg@mail.gmail.com \
--to=torvalds@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mst@redhat.com \
--cc=peterz@infradead.org \
--cc=regressions@leemhuis.info \
--cc=stable@vger.kernel.org \
--cc=syzbot+6304bf97ef436580fede@syzkaller.appspotmail.com \
--cc=tglx@linutronix.de \
--cc=ying.huang@intel.com \
--subject='Re: [PATCH] gup: return -EFAULT on access_ok failure' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).