From: Al Viro <viro@ZenIV.linux.org.uk>
To: Jann Horn <jannh@google.com>
Cc: axboe@kernel.dk, fujita.tomonori@lab.ntt.co.jp,
dgilbert@interlog.com, jejb@linux.vnet.ibm.com,
martin.petersen@oracle.com, linux-block@vger.kernel.org,
linux-scsi@vger.kernel.org,
kernel list <linux-kernel@vger.kernel.org>,
Kernel Hardening <kernel-hardening@lists.openwall.com>,
security@kernel.org
Subject: Re: [PATCH] sg, bsg: mitigate read/write abuse, block uaccess in release
Date: Fri, 15 Jun 2018 17:53:10 +0100 [thread overview]
Message-ID: <20180615165310.GF30522@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CAG48ez2Fku77S+FM2w5n8J_utOhO0EW_RFbMib=t5Nmwc9pwfQ@mail.gmail.com>
On Fri, Jun 15, 2018 at 06:44:51PM +0200, Jann Horn wrote:
> On Fri, Jun 15, 2018 at 6:40 PM Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > On Fri, Jun 15, 2018 at 05:23:35PM +0200, Jann Horn wrote:
> >
> > > I've mostly copypasted ib_safe_file_access() over as
> > > scsi_safe_file_access() because I couldn't find a good common header -
> > > please tell me if you know a better way.
> > > The duplicate pr_err_once() calls are so that each of them fires once;
> > > otherwise, this would probably have to be a macro.
> > >
> > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> > > Cc: <stable@vger.kernel.org>
> > > Signed-off-by: Jann Horn <jannh@google.com>
> > > ---
> >
> > WTF do you mean, in ->release()? That makes no sense whatsoever -
> > what kind of copy_{to,from}_user() would be possible in there?
>
> bsg_release -> bsg_put_device -> bsg_complete_all_commands ->
> blk_complete_sgv4_hdr_rq -> bsg_scsi_complete_rq -> copy_to_user.
> I don't think that was intentional.
>
> Basically, the sense buffer is copied to a userspace address supplied
> in the previous ->write() when you ->read() the reply. But when you
> ->release() the file without reading the reply, they have to clean it
> up, and for that, they reuse the same code they use for ->read() - so
> the sense buffer is written to userspace on ->release().
Pardon me, that has only one fix - git rm. This is too broken for words -
if your reading is correct, the interface is unsalvagable. I hope you
*are* misreading it, but if not... how did that insanity get through
review at merge time?
next prev parent reply other threads:[~2018-06-15 16:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 15:23 [PATCH] sg, bsg: mitigate read/write abuse, block uaccess in release Jann Horn
2018-06-15 16:40 ` Al Viro
2018-06-15 16:44 ` Jann Horn
2018-06-15 16:53 ` Al Viro [this message]
2018-06-15 17:10 ` Al Viro
2018-06-15 17:13 ` Jann Horn
2018-06-15 20:47 ` Douglas Gilbert
2018-06-18 15:26 ` Benjamin Block
2018-06-18 15:26 ` Benjamin Block
2018-06-18 15:37 ` Jens Axboe
2018-06-18 16:16 ` Al Viro
2018-06-18 16:23 ` Jens Axboe
2018-06-21 12:34 ` Christoph Hellwig
2018-06-21 12:34 ` Christoph Hellwig
2018-06-21 12:51 ` Jann Horn
2018-06-21 13:03 ` Christoph Hellwig
2018-06-21 14:07 ` Jens Axboe
2018-07-08 14:58 ` Christoph Hellwig
2018-07-10 20:53 ` Jann Horn
2018-07-11 6:33 ` Christoph Hellwig
2018-06-15 16:49 ` Al Viro
2018-06-15 16:58 ` Jann Horn
2018-06-15 17:02 ` Jann Horn
2018-06-21 12:40 ` Christoph Hellwig
2018-06-21 12:54 ` Jann Horn
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=20180615165310.GF30522@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=axboe@kernel.dk \
--cc=dgilbert@interlog.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=jannh@google.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=security@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.