Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1585318

[PATCH 4.4 05/15] Fix missing sanity check in /dev/sg

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 05/15] Fix missing sanity check in /dev/sg
Date 2017-02-21 14:20 +0100
Message-ID <tdiwi-340-5@gated-at.bofh.it> (permalink)
References <tdimB-30G-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.4-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
@@ -1763,6 +1763,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);

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 00/15] 4.4.51-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:10 +0100
  [PATCH 4.4 11/15] printk: use rcuidle console tracepoint Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:10 +0100
  [PATCH 4.4 09/15] futex: Move futex_init() to core_initcall Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:10 +0100
  [PATCH 4.4 06/15] Input: elan_i2c - add ELAN0605 to the ACPI table Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:10 +0100
  [PATCH 4.4 12/15] NTB: ntb_transport: fix debugfs_remove_recursive Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:10 +0100
  [PATCH 4.4 10/15] ARM: 8658/1: uaccess: fix zeroing of 64-bit get_user() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:10 +0100
  [PATCH 4.4 02/15] [media] siano: make it work again with CONFIG_VMAP_STACK Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:20 +0100
    Re: [PATCH 4.4 02/15] [media] siano: make it work again with  CONFIG_VMAP_STACK Mauro Carvalho Chehab <mchehab@s-opensource.com> - 2017-02-22 22:40 +0100
    Re: [PATCH 4.4 02/15] [media] siano: make it work again with  CONFIG_VMAP_STACK Eddie Chapman <eddie@ehuk.net> - 2017-02-22 22:50 +0100
  [PATCH 4.4 05/15] Fix missing sanity check in /dev/sg Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:20 +0100
  [PATCH 4.4 04/15] scsi: dont BUG_ON() empty DMA transfers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:20 +0100
  [PATCH 4.4 03/15] fuse: fix use after free issue in fuse_dev_do_read() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:20 +0100
  [PATCH 4.4 14/15] bcache: Make gc wakeup sane, remove set_task_state() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:20 +0100
  [PATCH 4.4 15/15] mmc: core: fix multi-bit bus width without high-speed mode Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:20 +0100
  [PATCH 4.4 13/15] ntb_transport: Pick an unused queue Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:20 +0100
  [PATCH 4.4 08/15] drm/dp/mst: fix kernel oops when turning off secondary monitor Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-21 14:20 +0100
  Re: [PATCH 4.4 00/15] 4.4.51-stable review Guenter Roeck <linux@roeck-us.net> - 2017-02-21 17:20 +0100
  Re: [PATCH 4.4 00/15] 4.4.51-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-02-22 00:50 +0100

csiph-web