From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>, Greg KH <greg@kroah.com>,
stable <stable@vger.kernel.org>
Subject: Re: [patch NOT added to 3.12 stable tree] Don't feed anything but regular iovec's to blk_rq_map_user_iov
Date: Thu, 15 Dec 2016 01:54:12 +0000 [thread overview]
Message-ID: <20161215015412.GQ1555@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CA+55aFyO-bZo24dT7m8PU8+vxsLEWDZzKrJyP=Tm7RAT=cCd0Q@mail.gmail.com>
On Tue, Dec 13, 2016 at 09:09:25AM -0800, Linus Torvalds wrote:
> On Tue, Dec 13, 2016 at 9:05 AM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > I really doubt it - there might be something subtle I'd missed, but AFAICS
> > it is vulnerable to the scenario above.
>
> Hmm. So maybe just add
>
> if (segment_eq(get_fs(), KERNEL_DS))
> return -EINVAL;
>
> to blk_rq_map_user_iov()?
To sg_write(), actually. And we need it both in old branches and in
the mainline - sg_new_write() problem applies in mainline as well, and
if nothing else, it allows to perform reads from arbitrary kernel
space address; I'm not sure how easy it is to see the value it has
fetched, but it certainly can do unpleasant things to memory-mapped
IO registers.
As the matter of fact, bsg_write() is no better - blk_fill_sgv4_hdr_rq()
is called before we get to blk_rq_map_user() where your test would make
it fail, and it does
if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
hdr->request_len))
return -EFAULT;
with *hdr, including hrd->request, has come from the data fed to bsg_write().
So I think we should make both sg_write() and bsg_write() to fail as early
as possible when called with KERNEL_DS, mainline and all -stable branches.
prev parent reply other threads:[~2016-12-15 1:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-12 15:07 [patch NOT added to 3.12 stable tree] Don't feed anything but regular iovec's to blk_rq_map_user_iov Jiri Slaby
2016-12-12 22:49 ` Greg KH
2016-12-13 14:40 ` Jiri Slaby
2016-12-13 15:24 ` Greg KH
2016-12-13 15:32 ` Jiri Slaby
2016-12-13 16:46 ` Linus Torvalds
2016-12-13 17:05 ` Al Viro
2016-12-13 17:09 ` Linus Torvalds
2016-12-13 17:12 ` Jiri Slaby
2016-12-13 17:42 ` Linus Torvalds
2016-12-15 1:54 ` Al Viro [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=20161215015412.GQ1555@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=greg@kroah.com \
--cc=jslaby@suse.cz \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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 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).