From: "Michael S. Tsirkin" <mst@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Jason Wang <jasowang@redhat.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH RFC] uaccess: user_access_begin_after_access_ok()
Date: Wed, 3 Jun 2020 02:01:58 -0400 [thread overview]
Message-ID: <20200603014944-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAHk-=wgYu+qk15_NpUZXwbetEU5eiWppJ=Z_A6dCSCWKxCfDfw@mail.gmail.com>
On Tue, Jun 02, 2020 at 01:43:20PM -0700, Linus Torvalds wrote:
> On Tue, Jun 2, 2020 at 1:33 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > Hmm are you sure we can drop it? access_ok is done in the context
> > of the process. Access itself in the context of a kernel thread
> > that borrows the same mm. IIUC if the process can be 32 bit
> > while the kernel is 64 bit, access_ok in the context of the
> > kernel thread will not DTRT.
>
> You're historically expected to just "set_fs()" when you do use_mm().
Right and we do that, but that still sets the segment according to the
current thread's flags, right?
E.g. I see:
#define USER_DS MAKE_MM_SEG(TASK_SIZE_MAX)
and
#define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
IA32_PAGE_OFFSET : TASK_SIZE_MAX)
so if this is run from a kernel thread on a 64 bit kernel, we get
TASK_SIZE_MAX even if we got the pointer from a 32 bit userspace
address.
> Then we fixed it in commit...
>
> Oh, when I look for it, I notice that it still hasn't gotten merged.
> It's still pending, see
>
> https://lore.kernel.org/lkml/20200416053158.586887-4-hch@lst.de/
>
> for the current thing.
>
> Linus
Maybe kthread_use_mm should also get the fs, not just mm.
Then we can just use access_ok directly before the access.
--
MST
next prev parent reply other threads:[~2020-06-03 6:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 8:45 [PATCH RFC] uaccess: user_access_begin_after_access_ok() Michael S. Tsirkin
2020-06-02 10:15 ` Jason Wang
2020-06-02 16:33 ` Al Viro
2020-06-02 17:18 ` Linus Torvalds
2020-06-02 17:44 ` Al Viro
2020-06-02 17:46 ` Al Viro
2020-06-02 20:32 ` Michael S. Tsirkin
2020-06-02 20:41 ` David Laight
2020-06-02 21:58 ` Al Viro
2020-06-03 8:08 ` David Laight
2020-06-02 20:43 ` Linus Torvalds
2020-06-03 6:01 ` Michael S. Tsirkin [this message]
[not found] ` <CAHk-=wi3=QuD30fRq8fYYTj9WmkgeZ0VR_Sh3DQHU+nmwj-jMg@mail.gmail.com>
2020-06-03 16:59 ` Linus Torvalds
2020-06-02 16:30 ` Al Viro
2020-06-02 20:42 ` Michael S. Tsirkin
2020-06-02 22:10 ` Al Viro
2020-06-03 5:17 ` Michael S. Tsirkin
2020-06-03 1:48 ` Al Viro
2020-06-03 3:57 ` Jason Wang
2020-06-03 4:18 ` Al Viro
2020-06-03 5:18 ` Jason Wang
2020-06-03 5:46 ` Michael S. Tsirkin
2020-06-03 6:23 ` Jason Wang
2020-06-03 6:30 ` Michael S. Tsirkin
2020-06-03 6:36 ` Jason Wang
2020-06-04 16:49 ` Michael S. Tsirkin
2020-06-05 10:03 ` Jason Wang
2020-06-06 20:08 ` Michael S. Tsirkin
2020-06-03 6:25 ` Michael S. Tsirkin
2020-06-03 5:29 ` Michael S. Tsirkin
2020-06-03 16:52 ` Al Viro
2020-06-04 6:10 ` Jason Wang
2020-06-04 14:59 ` Al Viro
2020-06-04 16:46 ` Michael S. Tsirkin
2020-06-04 10:10 ` Michael S. Tsirkin
2020-06-04 15:03 ` Al Viro
2020-06-04 16:47 ` Michael S. Tsirkin
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=20200603014944-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).