All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Johannes Thumshirn <jthumshirn@suse.de>,
	Dmitry Vyukov <dvyukov@google.com>,
	James Bottomley <jejb@linux.vnet.ibm.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 4.4 04/15] scsi: dont BUG_ON() empty DMA transfers
Date: Tue, 21 Feb 2017 14:02:01 +0100	[thread overview]
Message-ID: <20170221130140.031297019@linuxfoundation.org> (raw)
In-Reply-To: <20170221130139.845694876@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johannes Thumshirn <jthumshirn@suse.de>

commit fd3fc0b4d7305fa7246622dcc0dec69c42443f45 upstream.

Don't crash the machine just because of an empty transfer. Use WARN_ON()
combined with returning an error.

Found by Dmitry Vyukov and syzkaller.

[ Changed to "WARN_ON_ONCE()". Al has a patch that should fix the root
  cause, but a BUG_ON() is not acceptable in any case, and a WARN_ON()
  might still be a cause of excessive log spamming.

  NOTE! If this warning ever triggers, we may end up leaking resources,
  since this doesn't bother to try to clean the command up. So this
  WARN_ON_ONCE() triggering does imply real problems. But BUG_ON() is
  much worse.

  People really need to stop using BUG_ON() for "this shouldn't ever
  happen". It makes pretty much any bug worse.     - Linus ]

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: James Bottomley <jejb@linux.vnet.ibm.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/scsi_lib.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1120,7 +1120,8 @@ int scsi_init_io(struct scsi_cmnd *cmd)
 	bool is_mq = (rq->mq_ctx != NULL);
 	int error;
 
-	BUG_ON(!rq->nr_phys_segments);
+	if (WARN_ON_ONCE(!rq->nr_phys_segments))
+		return -EINVAL;
 
 	error = scsi_init_sgtable(rq, &cmd->sdb);
 	if (error)

  parent reply	other threads:[~2017-02-21 13:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 13:01 [PATCH 4.4 00/15] 4.4.51-stable review Greg Kroah-Hartman
2017-02-21 13:01 ` [PATCH 4.4 01/15] vfs: fix uninitialized flags in splice_to_pipe() Greg Kroah-Hartman
2017-02-21 13:01 ` [PATCH 4.4 02/15] [media] siano: make it work again with CONFIG_VMAP_STACK Greg Kroah-Hartman
2017-02-22 21:07   ` Eddie Chapman
2017-02-22 21:20     ` Mauro Carvalho Chehab
2017-02-21 13:02 ` [PATCH 4.4 03/15] fuse: fix use after free issue in fuse_dev_do_read() Greg Kroah-Hartman
2017-02-21 13:02 ` Greg Kroah-Hartman [this message]
2017-02-21 13:02 ` [PATCH 4.4 05/15] Fix missing sanity check in /dev/sg Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 06/15] Input: elan_i2c - add ELAN0605 to the ACPI table Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 08/15] drm/dp/mst: fix kernel oops when turning off secondary monitor Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 09/15] futex: Move futex_init() to core_initcall Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 10/15] ARM: 8658/1: uaccess: fix zeroing of 64-bit get_user() Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 11/15] printk: use rcuidle console tracepoint Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 12/15] NTB: ntb_transport: fix debugfs_remove_recursive Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 13/15] ntb_transport: Pick an unused queue Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 14/15] bcache: Make gc wakeup sane, remove set_task_state() Greg Kroah-Hartman
2017-02-21 13:02 ` [PATCH 4.4 15/15] mmc: core: fix multi-bit bus width without high-speed mode Greg Kroah-Hartman
2017-02-21 16:15 ` [PATCH 4.4 00/15] 4.4.51-stable review Guenter Roeck
2017-02-21 23:40 ` Shuah Khan

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=20170221130140.031297019@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dvyukov@google.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jthumshirn@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@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 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.