stable.vger.kernel.org archive mirror
 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, Al Viro <viro@zeniv.linux.org.uk>,
	Dmitry Vyukov <dvyukov@google.com>,
	Christoph Hellwig <hch@lst.de>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 4.9 08/22] Fix missing sanity check in /dev/sg
Date: Tue, 21 Feb 2017 14:03:22 +0100	[thread overview]
Message-ID: <20170221130219.239471443@linuxfoundation.org> (raw)
In-Reply-To: <20170221130218.888428471@linuxfoundation.org>

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

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

From: Al Viro <viro@ZenIV.linux.org.uk>

commit 137d01df511b3afe1f05499aea05f3bafc0fb221 upstream.

What happens is that a 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.

Having write permission to /dev/sg shouldn't be equivalent to the
ability to trigger BUG_ON() while holding spinlocks...

Found by Dmitry Vyukov and syzkaller.

[ The BUG_ON() got changed to a WARN_ON_ONCE(), but this fixes the
  underlying issue.  - Linus ]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/scsi/sg.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1753,6 +1753,10 @@ sg_start_req(Sg_request *srp, unsigned c
 			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);

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

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 13:03 [PATCH 4.9 00/22] 4.9.12-stable review Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 01/22] vfs: fix uninitialized flags in splice_to_pipe() Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 02/22] [media] siano: make it work again with CONFIG_VMAP_STACK Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 03/22] fuse: fix use after free issue in fuse_dev_do_read() Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 04/22] fuse: fix uninitialized flags in pipe_buffer Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 05/22] mmc: core: fix multi-bit bus width without high-speed mode Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 06/22] powerpc/64: Disable use of radix under a hypervisor Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 07/22] scsi: dont BUG_ON() empty DMA transfers Greg Kroah-Hartman
2017-02-21 13:03 ` Greg Kroah-Hartman [this message]
2017-02-21 13:03 ` [PATCH 4.9 09/22] Input: elan_i2c - add ELAN0605 to the ACPI table Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 11/22] drm/dp/mst: fix kernel oops when turning off secondary monitor Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 12/22] futex: Move futex_init() to core_initcall Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 13/22] ARM: 8658/1: uaccess: fix zeroing of 64-bit get_user() Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 14/22] Revert "i2c: designware: detect when dynamic tar update is possible" Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 15/22] PCI/PME: Restore pcie_pme_driver.remove Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 16/22] printk: use rcuidle console tracepoint Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 17/22] timekeeping: Use deferred printk() in debug code Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 18/22] NTB: ntb_transport: fix debugfs_remove_recursive Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 19/22] ntb: ntb_perf missing dmaengine_unmap_put Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 20/22] ntb_transport: Pick an unused queue Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 21/22] bcache: Make gc wakeup sane, remove set_task_state() Greg Kroah-Hartman
2017-02-21 13:03 ` [PATCH 4.9 22/22] [media] videodev2.h: go back to limited range YCbCr for SRGB and, ADOBERGB Greg Kroah-Hartman
2017-02-21 16:16 ` [PATCH 4.9 00/22] 4.9.12-stable review Guenter Roeck
2017-02-23 16:53   ` Greg Kroah-Hartman
2017-02-21 23:40 ` Shuah Khan
2017-02-23 16:53   ` Greg Kroah-Hartman
     [not found] ` <58ac905b.0d212e0a.6fb29.ac9c@mx.google.com>
2017-02-23 16:53   ` Greg Kroah-Hartman

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=20170221130219.239471443@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dvyukov@google.com \
    --cc=hch@lst.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 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).