From: Al Viro <viro@ZenIV.linux.org.uk>
To: James Bottomley <jejb@linux.vnet.ibm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
Johannes Thumshirn <jthumshirn@suse.de>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi <linux-scsi@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
syzkaller <syzkaller@googlegroups.com>,
Hannes Reinecke <hare@suse.de>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: scsi: BUG in scsi_init_io
Date: Sun, 19 Feb 2017 07:15:27 +0000 [thread overview]
Message-ID: <20170219071522.GI29622@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1485877311.3199.4.camel@linux.vnet.ibm.com>
On Tue, Jan 31, 2017 at 07:41:51AM -0800, James Bottomley wrote:
> > Please-please-please, let's not use WARN for something that is not a
> > kernel bug and is user-triggerable.
>
> It is a kernel bug and it should not be user triggerable, so it should
> have a warn_on or bug_on. It means something called a data setup
> function with no data. There's actually a root cause that patches like
> this won't fix, can we find it?
The root cause is unfixable without access to TARDIS and dose of
antipsychotics sufficient to prevent /dev/sg API creation.
What happens is that write to /dev/sg is given a request with non-zero
->iovec_count combined with zero ->dxfer_len. Or with ->dxferp pointing
to an array full of empty iovecs.
AFAICS, the minimal fix would be something like this:
YAMissingSanityCheck in /dev/sg
write permission to /dev/sg shouldn't be equivalent to the ability to trigger
BUG_ON() while holding spinlocks...
Cc: stable@vger.kernel.org
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index dbe5b4b95df0..121de0aaa6ad 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1753,6 +1753,10 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
return res;
iov_iter_truncate(&i, hp->dxfer_len);
+ if (!iov_iter_count(&i)) {
+ kfree(iov);
+ return -EINVAL;
+ }
res = blk_rq_map_user_iov(q, rq, md, &i, GFP_ATOMIC);
kfree(iov);
next prev parent reply other threads:[~2017-02-19 7:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-31 8:55 scsi: BUG in scsi_init_io Dmitry Vyukov
2017-01-31 9:20 ` Johannes Thumshirn
2017-01-31 9:50 ` Dmitry Vyukov
2017-01-31 9:58 ` Johannes Thumshirn
2017-01-31 10:06 ` Dmitry Vyukov
2017-01-31 15:41 ` James Bottomley
2017-02-19 7:15 ` Al Viro [this message]
2017-02-19 17:25 ` Christoph Hellwig
2017-02-19 17:56 ` Linus Torvalds
2017-02-19 17:38 ` Linus Torvalds
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=20170219071522.GI29622@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=dvyukov@google.com \
--cc=hare@suse.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=jthumshirn@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=syzkaller@googlegroups.com \
--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