public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <jejb@linux.vnet.ibm.com>
To: Dmitry Vyukov <dvyukov@google.com>,
	Johannes Thumshirn <jthumshirn@suse.de>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	syzkaller <syzkaller@googlegroups.com>,
	Hannes Reinecke <hare@suse.de>
Subject: Re: scsi: BUG in scsi_init_io
Date: Tue, 31 Jan 2017 07:41:51 -0800	[thread overview]
Message-ID: <1485877311.3199.4.camel@linux.vnet.ibm.com> (raw)
In-Reply-To: <CACT4Y+Y0Yi43kN+sAOd=pu4FTnW4wPeGwiDHEU45s6DTXs_JmQ@mail.gmail.com>

On Tue, 2017-01-31 at 10:50 +0100, Dmitry Vyukov wrote:
> On Tue, Jan 31, 2017 at 10:20 AM, Johannes Thumshirn <
> jthumshirn@suse.de> wrote:
> > On Tue, Jan 31, 2017 at 09:55:52AM +0100, Dmitry Vyukov wrote:
> > > Hello,
> > > 
> > > The following program triggers BUG in scsi_init_io:
> > 
> > Well crashing a machine just because of an empty dma transfer is a
> > bit harsh,
> > isn't it?
> > 
> > From 86e6fa5f618fe588b98e923e032f33e075fcd4f4 Mon Sep 17 00:00:00
> > 2001
> > From: Johannes Thumshirn <jthumshirn@suse.de>
> > Date: Tue, 31 Jan 2017 10:16:00 +0100
> > Subject: [PATCH] scsi: don't BUG_ON() empty DMA transfers
> > 
> > Don't crash the machine just because of an empty transfer. Use
> > WARN_ON()
> > combined with returning an error.
> > 
> > Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> > ---
> >  drivers/scsi/scsi_lib.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> > index e9e1e14..414588a 100644
> > --- a/drivers/scsi/scsi_lib.c
> > +++ b/drivers/scsi/scsi_lib.c
> > @@ -1040,7 +1040,8 @@ int scsi_init_io(struct scsi_cmnd *cmd)
> >         bool is_mq = (rq->mq_ctx != NULL);
> >         int error;
> > 
> > -       BUG_ON(!blk_rq_nr_phys_segments(rq));
> > +       if (WARN_ON(!blk_rq_nr_phys_segments(rq)))
> > +               return -EINVAL;
> 
> 
> 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?

James

  parent reply	other threads:[~2017-01-31 15:42 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 [this message]
2017-02-19  7:15       ` Al Viro
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=1485877311.3199.4.camel@linux.vnet.ibm.com \
    --to=jejb@linux.vnet.ibm.com \
    --cc=dvyukov@google.com \
    --cc=hare@suse.de \
    --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=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