<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-stable.git/drivers/scsi, branch v3.18.46</title>
<subtitle>Linux kernel stable tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/'/>
<entry>
<title>scsi: arcmsr: Buffer overflow in arcmsr_iop_message_xfer()</title>
<updated>2016-12-23T15:39:29+00:00</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2016-12-14T12:24:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=6371e0cdc5be8671461f136dc1df9a36bdb5292a'/>
<id>6371e0cdc5be8671461f136dc1df9a36bdb5292a</id>
<content type='text'>
[ Upstream commit 7bc2b55a5c030685b399bb65b6baa9ccc3d1f167 ]

We need to put an upper bound on "user_len" so the memcpy() doesn't
overflow.

Cc: &lt;stable@vger.kernel.org&gt;
Reported-by: Marco Grassi &lt;marco.gra@gmail.com&gt;
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 7bc2b55a5c030685b399bb65b6baa9ccc3d1f167 ]

We need to put an upper bound on "user_len" so the memcpy() doesn't
overflow.

Cc: &lt;stable@vger.kernel.org&gt;
Reported-by: Marco Grassi &lt;marco.gra@gmail.com&gt;
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Reviewed-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: megaraid_sas: fix macro MEGASAS_IS_LOGICAL to avoid regression</title>
<updated>2016-12-02T15:17:05+00:00</updated>
<author>
<name>Sumit Saxena</name>
<email>sumit.saxena@broadcom.com</email>
</author>
<published>2016-11-09T10:59:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=41a83f7482d6281db0c47430235343c2cf024d59'/>
<id>41a83f7482d6281db0c47430235343c2cf024d59</id>
<content type='text'>
[ Upstream commit 5e5ec1759dd663a1d5a2f10930224dd009e500e8 ]

This patch will fix regression caused by commit 1e793f6fc0db ("scsi:
megaraid_sas: Fix data integrity failure for JBOD (passthrough)
devices").

The problem was that the MEGASAS_IS_LOGICAL macro did not have braces
and as a result the driver ended up exposing a lot of non-existing SCSI
devices (all SCSI commands to channels 1,2,3 were returned as
SUCCESS-DID_OK by driver).

[mkp: clarified patch description]

Fixes: 1e793f6fc0db920400574211c48f9157a37e3945
Reported-by: Jens Axboe &lt;axboe@kernel.dk&gt;
CC: stable@vger.kernel.org
Signed-off-by: Kashyap Desai &lt;kashyap.desai@broadcom.com&gt;
Signed-off-by: Sumit Saxena &lt;sumit.saxena@broadcom.com&gt;
Tested-by: Sumit Saxena &lt;sumit.saxena@broadcom.com&gt;
Reviewed-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Tested-by: Jens Axboe &lt;axboe@fb.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 5e5ec1759dd663a1d5a2f10930224dd009e500e8 ]

This patch will fix regression caused by commit 1e793f6fc0db ("scsi:
megaraid_sas: Fix data integrity failure for JBOD (passthrough)
devices").

The problem was that the MEGASAS_IS_LOGICAL macro did not have braces
and as a result the driver ended up exposing a lot of non-existing SCSI
devices (all SCSI commands to channels 1,2,3 were returned as
SUCCESS-DID_OK by driver).

[mkp: clarified patch description]

Fixes: 1e793f6fc0db920400574211c48f9157a37e3945
Reported-by: Jens Axboe &lt;axboe@kernel.dk&gt;
CC: stable@vger.kernel.org
Signed-off-by: Kashyap Desai &lt;kashyap.desai@broadcom.com&gt;
Signed-off-by: Sumit Saxena &lt;sumit.saxena@broadcom.com&gt;
Tested-by: Sumit Saxena &lt;sumit.saxena@broadcom.com&gt;
Reviewed-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Tested-by: Jens Axboe &lt;axboe@fb.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: arcmsr: Send SYNCHRONIZE_CACHE command to firmware</title>
<updated>2016-11-24T04:05:37+00:00</updated>
<author>
<name>Ching Huang</name>
<email>ching2048@areca.com.tw</email>
</author>
<published>2016-10-19T09:50:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=98d446ef289ddce78684965745d34a28b05cfb34'/>
<id>98d446ef289ddce78684965745d34a28b05cfb34</id>
<content type='text'>
[ Upstream commit 2bf7dc8443e113844d078fd6541b7f4aa544f92f ]

The arcmsr driver failed to pass SYNCHRONIZE CACHE to controller
firmware. Depending on how drive caches are handled internally by
controller firmware this could potentially lead to data integrity
problems.

Ensure that cache flushes are passed to the controller.

[mkp: applied by hand and removed unused vars]

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Ching Huang &lt;ching2048@areca.com.tw&gt;
Reported-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 2bf7dc8443e113844d078fd6541b7f4aa544f92f ]

The arcmsr driver failed to pass SYNCHRONIZE CACHE to controller
firmware. Depending on how drive caches are handled internally by
controller firmware this could potentially lead to data integrity
problems.

Ensure that cache flushes are passed to the controller.

[mkp: applied by hand and removed unused vars]

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Ching Huang &lt;ching2048@areca.com.tw&gt;
Reported-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: scsi_debug: Fix memory leak if LBP enabled and module is unloaded</title>
<updated>2016-11-24T04:05:32+00:00</updated>
<author>
<name>Ewan D. Milne</name>
<email>emilne@redhat.com</email>
</author>
<published>2016-10-26T15:22:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=103432f0b54a920c211f9d6c013f9ef7e0366d20'/>
<id>103432f0b54a920c211f9d6c013f9ef7e0366d20</id>
<content type='text'>
[ Upstream commit 4d2b496f19f3c2cfaca1e8fa0710688b5ff3811d ]

map_storep was not being vfree()'d in the module_exit call.

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Reviewed-by: Laurence Oberman &lt;loberman@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 4d2b496f19f3c2cfaca1e8fa0710688b5ff3811d ]

map_storep was not being vfree()'d in the module_exit call.

Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Reviewed-by: Laurence Oberman &lt;loberman@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: megaraid_sas: Fix data integrity failure for JBOD (passthrough) devices</title>
<updated>2016-11-24T04:02:15+00:00</updated>
<author>
<name>Kashyap Desai</name>
<email>kashyap.desai@broadcom.com</email>
</author>
<published>2016-10-21T13:33:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=24542192519d21719377d89f14654b3afd993a61'/>
<id>24542192519d21719377d89f14654b3afd993a61</id>
<content type='text'>
[ Upstream commit 1e793f6fc0db920400574211c48f9157a37e3945 ]

Commit 02b01e010afe ("megaraid_sas: return sync cache call with
success") modified the driver to successfully complete SYNCHRONIZE_CACHE
commands without passing them to the controller. Disk drive caches are
only explicitly managed by controller firmware when operating in RAID
mode. So this commit effectively disabled writeback cache flushing for
any drives used in JBOD mode, leading to data integrity failures.

[mkp: clarified patch description]

Fixes: 02b01e010afeeb49328d35650d70721d2ca3fd59
CC: stable@vger.kernel.org
Signed-off-by: Kashyap Desai &lt;kashyap.desai@broadcom.com&gt;
Signed-off-by: Sumit Saxena &lt;sumit.saxena@broadcom.com&gt;
Reviewed-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Reviewed-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 1e793f6fc0db920400574211c48f9157a37e3945 ]

Commit 02b01e010afe ("megaraid_sas: return sync cache call with
success") modified the driver to successfully complete SYNCHRONIZE_CACHE
commands without passing them to the controller. Disk drive caches are
only explicitly managed by controller firmware when operating in RAID
mode. So this commit effectively disabled writeback cache flushing for
any drives used in JBOD mode, leading to data integrity failures.

[mkp: clarified patch description]

Fixes: 02b01e010afeeb49328d35650d70721d2ca3fd59
CC: stable@vger.kernel.org
Signed-off-by: Kashyap Desai &lt;kashyap.desai@broadcom.com&gt;
Signed-off-by: Sumit Saxena &lt;sumit.saxena@broadcom.com&gt;
Reviewed-by: Tomas Henzl &lt;thenzl@redhat.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Reviewed-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>scsi: Fix use-after-free</title>
<updated>2016-11-24T02:28:31+00:00</updated>
<author>
<name>Ming Lei</name>
<email>tom.leiming@gmail.com</email>
</author>
<published>2016-10-09T05:23:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=37f487e02e46b1e12bd06adfb6edb3a9a1605a64'/>
<id>37f487e02e46b1e12bd06adfb6edb3a9a1605a64</id>
<content type='text'>
[ Upstream commit bcd8f2e94808fcddf6ef3af5f060a36820dcc432 ]

This patch fixes one use-after-free report[1] by KASAN.

In __scsi_scan_target(), when a type 31 device is probed,
SCSI_SCAN_TARGET_PRESENT is returned and the target will be scanned
again.

Inside the following scsi_report_lun_scan(), one new scsi_device
instance is allocated, and scsi_probe_and_add_lun() is called again to
probe the target and still see type 31 device, finally
__scsi_remove_device() is called to remove &amp; free the device at the end
of scsi_probe_and_add_lun(), so cause use-after-free in
scsi_report_lun_scan().

And the following SCSI log can be observed:

	scsi 0:0:2:0: scsi scan: INQUIRY pass 1 length 36
	scsi 0:0:2:0: scsi scan: INQUIRY successful with code 0x0
	scsi 0:0:2:0: scsi scan: peripheral device type of 31, no device added
	scsi 0:0:2:0: scsi scan: Sending REPORT LUNS to (try 0)
	scsi 0:0:2:0: scsi scan: REPORT LUNS successful (try 0) result 0x0
	scsi 0:0:2:0: scsi scan: REPORT LUN scan
	scsi 0:0:2:0: scsi scan: INQUIRY pass 1 length 36
	scsi 0:0:2:0: scsi scan: INQUIRY successful with code 0x0
	scsi 0:0:2:0: scsi scan: peripheral device type of 31, no device added
	BUG: KASAN: use-after-free in __scsi_scan_target+0xbf8/0xe40 at addr ffff88007b44a104

This patch fixes the issue by moving the putting reference at
the end of scsi_report_lun_scan().

[1] KASAN report
==================================================================
[    3.274597] PM: Adding info for serio:serio1
[    3.275127] BUG: KASAN: use-after-free in __scsi_scan_target+0xd87/0xdf0 at addr ffff880254d8c304
[    3.275653] Read of size 4 by task kworker/u10:0/27
[    3.275903] CPU: 3 PID: 27 Comm: kworker/u10:0 Not tainted 4.8.0 #2121
[    3.276258] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
[    3.276797] Workqueue: events_unbound async_run_entry_fn
[    3.277083]  ffff880254d8c380 ffff880259a37870 ffffffff94bbc6c1 ffff880078402d80
[    3.277532]  ffff880254d8bb80 ffff880259a37898 ffffffff9459fec1 ffff880259a37930
[    3.277989]  ffff880254d8bb80 ffff880078402d80 ffff880259a37920 ffffffff945a0165
[    3.278436] Call Trace:
[    3.278528]  [&lt;ffffffff94bbc6c1&gt;] dump_stack+0x65/0x84
[    3.278797]  [&lt;ffffffff9459fec1&gt;] kasan_object_err+0x21/0x70
[    3.279063] device: 'psaux': device_add
[    3.279616]  [&lt;ffffffff945a0165&gt;] kasan_report_error+0x205/0x500
[    3.279651] PM: Adding info for No Bus:psaux
[    3.280202]  [&lt;ffffffff944ecd22&gt;] ? kfree_const+0x22/0x30
[    3.280486]  [&lt;ffffffff94bc2dc9&gt;] ? kobject_release+0x119/0x370
[    3.280805]  [&lt;ffffffff945a0543&gt;] __asan_report_load4_noabort+0x43/0x50
[    3.281170]  [&lt;ffffffff9507e1f7&gt;] ? __scsi_scan_target+0xd87/0xdf0
[    3.281506]  [&lt;ffffffff9507e1f7&gt;] __scsi_scan_target+0xd87/0xdf0
[    3.281848]  [&lt;ffffffff9507d470&gt;] ? scsi_add_device+0x30/0x30
[    3.282156]  [&lt;ffffffff94f7f660&gt;] ? pm_runtime_autosuspend_expiration+0x60/0x60
[    3.282570]  [&lt;ffffffff956ddb07&gt;] ? _raw_spin_lock+0x17/0x40
[    3.282880]  [&lt;ffffffff9507e505&gt;] scsi_scan_channel+0x105/0x160
[    3.283200]  [&lt;ffffffff9507e8a2&gt;] scsi_scan_host_selected+0x212/0x2f0
[    3.283563]  [&lt;ffffffff9507eb3c&gt;] do_scsi_scan_host+0x1bc/0x250
[    3.283882]  [&lt;ffffffff9507efc1&gt;] do_scan_async+0x41/0x450
[    3.284173]  [&lt;ffffffff941c1fee&gt;] async_run_entry_fn+0xfe/0x610
[    3.284492]  [&lt;ffffffff941a8954&gt;] ? pwq_dec_nr_in_flight+0x124/0x2a0
[    3.284876]  [&lt;ffffffff941d1770&gt;] ? preempt_count_add+0x130/0x160
[    3.285207]  [&lt;ffffffff941a9a84&gt;] process_one_work+0x544/0x12d0
[    3.285526]  [&lt;ffffffff941aa8e9&gt;] worker_thread+0xd9/0x12f0
[    3.285844]  [&lt;ffffffff941aa810&gt;] ? process_one_work+0x12d0/0x12d0
[    3.286182]  [&lt;ffffffff941bb365&gt;] kthread+0x1c5/0x260
[    3.286443]  [&lt;ffffffff940855cd&gt;] ? __switch_to+0x88d/0x1430
[    3.286745]  [&lt;ffffffff941bb1a0&gt;] ? kthread_worker_fn+0x5a0/0x5a0
[    3.287085]  [&lt;ffffffff956dde9f&gt;] ret_from_fork+0x1f/0x40
[    3.287368]  [&lt;ffffffff941bb1a0&gt;] ? kthread_worker_fn+0x5a0/0x5a0
[    3.287697] Object at ffff880254d8bb80, in cache kmalloc-2048 size: 2048
[    3.288064] Allocated:
[    3.288147] PID = 27
[    3.288218]  [&lt;ffffffff940b27ab&gt;] save_stack_trace+0x2b/0x50
[    3.288531]  [&lt;ffffffff9459f246&gt;] save_stack+0x46/0xd0
[    3.288806]  [&lt;ffffffff9459f4bd&gt;] kasan_kmalloc+0xad/0xe0
[    3.289098]  [&lt;ffffffff9459c07e&gt;] __kmalloc+0x13e/0x250
[    3.289378]  [&lt;ffffffff95078e5a&gt;] scsi_alloc_sdev+0xea/0xcf0
[    3.289701]  [&lt;ffffffff9507de76&gt;] __scsi_scan_target+0xa06/0xdf0
[    3.290034]  [&lt;ffffffff9507e505&gt;] scsi_scan_channel+0x105/0x160
[    3.290362]  [&lt;ffffffff9507e8a2&gt;] scsi_scan_host_selected+0x212/0x2f0
[    3.290724]  [&lt;ffffffff9507eb3c&gt;] do_scsi_scan_host+0x1bc/0x250
[    3.291055]  [&lt;ffffffff9507efc1&gt;] do_scan_async+0x41/0x450
[    3.291354]  [&lt;ffffffff941c1fee&gt;] async_run_entry_fn+0xfe/0x610
[    3.291695]  [&lt;ffffffff941a9a84&gt;] process_one_work+0x544/0x12d0
[    3.292022]  [&lt;ffffffff941aa8e9&gt;] worker_thread+0xd9/0x12f0
[    3.292325]  [&lt;ffffffff941bb365&gt;] kthread+0x1c5/0x260
[    3.292594]  [&lt;ffffffff956dde9f&gt;] ret_from_fork+0x1f/0x40
[    3.292886] Freed:
[    3.292945] PID = 27
[    3.293016]  [&lt;ffffffff940b27ab&gt;] save_stack_trace+0x2b/0x50
[    3.293327]  [&lt;ffffffff9459f246&gt;] save_stack+0x46/0xd0
[    3.293600]  [&lt;ffffffff9459fa61&gt;] kasan_slab_free+0x71/0xb0
[    3.293916]  [&lt;ffffffff9459bac2&gt;] kfree+0xa2/0x1f0
[    3.294168]  [&lt;ffffffff9508158a&gt;] scsi_device_dev_release_usercontext+0x50a/0x730
[    3.294598]  [&lt;ffffffff941ace9a&gt;] execute_in_process_context+0xda/0x130
[    3.294974]  [&lt;ffffffff9508107c&gt;] scsi_device_dev_release+0x1c/0x20
[    3.295322]  [&lt;ffffffff94f566f6&gt;] device_release+0x76/0x1e0
[    3.295626]  [&lt;ffffffff94bc2db7&gt;] kobject_release+0x107/0x370
[    3.295942]  [&lt;ffffffff94bc29ce&gt;] kobject_put+0x4e/0xa0
[    3.296222]  [&lt;ffffffff94f56e17&gt;] put_device+0x17/0x20
[    3.296497]  [&lt;ffffffff9505201c&gt;] scsi_device_put+0x7c/0xa0
[    3.296801]  [&lt;ffffffff9507e1bc&gt;] __scsi_scan_target+0xd4c/0xdf0
[    3.297132]  [&lt;ffffffff9507e505&gt;] scsi_scan_channel+0x105/0x160
[    3.297458]  [&lt;ffffffff9507e8a2&gt;] scsi_scan_host_selected+0x212/0x2f0
[    3.297829]  [&lt;ffffffff9507eb3c&gt;] do_scsi_scan_host+0x1bc/0x250
[    3.298156]  [&lt;ffffffff9507efc1&gt;] do_scan_async+0x41/0x450
[    3.298453]  [&lt;ffffffff941c1fee&gt;] async_run_entry_fn+0xfe/0x610
[    3.298777]  [&lt;ffffffff941a9a84&gt;] process_one_work+0x544/0x12d0
[    3.299105]  [&lt;ffffffff941aa8e9&gt;] worker_thread+0xd9/0x12f0
[    3.299408]  [&lt;ffffffff941bb365&gt;] kthread+0x1c5/0x260
[    3.299676]  [&lt;ffffffff956dde9f&gt;] ret_from_fork+0x1f/0x40
[    3.299967] Memory state around the buggy address:
[    3.300209]  ffff880254d8c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[    3.300608]  ffff880254d8c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[    3.300986] &gt;ffff880254d8c300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[    3.301408]                    ^
[    3.301550]  ffff880254d8c380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[    3.301987]  ffff880254d8c400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    3.302396]
==================================================================

Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Ming Lei &lt;tom.leiming@gmail.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit bcd8f2e94808fcddf6ef3af5f060a36820dcc432 ]

This patch fixes one use-after-free report[1] by KASAN.

In __scsi_scan_target(), when a type 31 device is probed,
SCSI_SCAN_TARGET_PRESENT is returned and the target will be scanned
again.

Inside the following scsi_report_lun_scan(), one new scsi_device
instance is allocated, and scsi_probe_and_add_lun() is called again to
probe the target and still see type 31 device, finally
__scsi_remove_device() is called to remove &amp; free the device at the end
of scsi_probe_and_add_lun(), so cause use-after-free in
scsi_report_lun_scan().

And the following SCSI log can be observed:

	scsi 0:0:2:0: scsi scan: INQUIRY pass 1 length 36
	scsi 0:0:2:0: scsi scan: INQUIRY successful with code 0x0
	scsi 0:0:2:0: scsi scan: peripheral device type of 31, no device added
	scsi 0:0:2:0: scsi scan: Sending REPORT LUNS to (try 0)
	scsi 0:0:2:0: scsi scan: REPORT LUNS successful (try 0) result 0x0
	scsi 0:0:2:0: scsi scan: REPORT LUN scan
	scsi 0:0:2:0: scsi scan: INQUIRY pass 1 length 36
	scsi 0:0:2:0: scsi scan: INQUIRY successful with code 0x0
	scsi 0:0:2:0: scsi scan: peripheral device type of 31, no device added
	BUG: KASAN: use-after-free in __scsi_scan_target+0xbf8/0xe40 at addr ffff88007b44a104

This patch fixes the issue by moving the putting reference at
the end of scsi_report_lun_scan().

[1] KASAN report
==================================================================
[    3.274597] PM: Adding info for serio:serio1
[    3.275127] BUG: KASAN: use-after-free in __scsi_scan_target+0xd87/0xdf0 at addr ffff880254d8c304
[    3.275653] Read of size 4 by task kworker/u10:0/27
[    3.275903] CPU: 3 PID: 27 Comm: kworker/u10:0 Not tainted 4.8.0 #2121
[    3.276258] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
[    3.276797] Workqueue: events_unbound async_run_entry_fn
[    3.277083]  ffff880254d8c380 ffff880259a37870 ffffffff94bbc6c1 ffff880078402d80
[    3.277532]  ffff880254d8bb80 ffff880259a37898 ffffffff9459fec1 ffff880259a37930
[    3.277989]  ffff880254d8bb80 ffff880078402d80 ffff880259a37920 ffffffff945a0165
[    3.278436] Call Trace:
[    3.278528]  [&lt;ffffffff94bbc6c1&gt;] dump_stack+0x65/0x84
[    3.278797]  [&lt;ffffffff9459fec1&gt;] kasan_object_err+0x21/0x70
[    3.279063] device: 'psaux': device_add
[    3.279616]  [&lt;ffffffff945a0165&gt;] kasan_report_error+0x205/0x500
[    3.279651] PM: Adding info for No Bus:psaux
[    3.280202]  [&lt;ffffffff944ecd22&gt;] ? kfree_const+0x22/0x30
[    3.280486]  [&lt;ffffffff94bc2dc9&gt;] ? kobject_release+0x119/0x370
[    3.280805]  [&lt;ffffffff945a0543&gt;] __asan_report_load4_noabort+0x43/0x50
[    3.281170]  [&lt;ffffffff9507e1f7&gt;] ? __scsi_scan_target+0xd87/0xdf0
[    3.281506]  [&lt;ffffffff9507e1f7&gt;] __scsi_scan_target+0xd87/0xdf0
[    3.281848]  [&lt;ffffffff9507d470&gt;] ? scsi_add_device+0x30/0x30
[    3.282156]  [&lt;ffffffff94f7f660&gt;] ? pm_runtime_autosuspend_expiration+0x60/0x60
[    3.282570]  [&lt;ffffffff956ddb07&gt;] ? _raw_spin_lock+0x17/0x40
[    3.282880]  [&lt;ffffffff9507e505&gt;] scsi_scan_channel+0x105/0x160
[    3.283200]  [&lt;ffffffff9507e8a2&gt;] scsi_scan_host_selected+0x212/0x2f0
[    3.283563]  [&lt;ffffffff9507eb3c&gt;] do_scsi_scan_host+0x1bc/0x250
[    3.283882]  [&lt;ffffffff9507efc1&gt;] do_scan_async+0x41/0x450
[    3.284173]  [&lt;ffffffff941c1fee&gt;] async_run_entry_fn+0xfe/0x610
[    3.284492]  [&lt;ffffffff941a8954&gt;] ? pwq_dec_nr_in_flight+0x124/0x2a0
[    3.284876]  [&lt;ffffffff941d1770&gt;] ? preempt_count_add+0x130/0x160
[    3.285207]  [&lt;ffffffff941a9a84&gt;] process_one_work+0x544/0x12d0
[    3.285526]  [&lt;ffffffff941aa8e9&gt;] worker_thread+0xd9/0x12f0
[    3.285844]  [&lt;ffffffff941aa810&gt;] ? process_one_work+0x12d0/0x12d0
[    3.286182]  [&lt;ffffffff941bb365&gt;] kthread+0x1c5/0x260
[    3.286443]  [&lt;ffffffff940855cd&gt;] ? __switch_to+0x88d/0x1430
[    3.286745]  [&lt;ffffffff941bb1a0&gt;] ? kthread_worker_fn+0x5a0/0x5a0
[    3.287085]  [&lt;ffffffff956dde9f&gt;] ret_from_fork+0x1f/0x40
[    3.287368]  [&lt;ffffffff941bb1a0&gt;] ? kthread_worker_fn+0x5a0/0x5a0
[    3.287697] Object at ffff880254d8bb80, in cache kmalloc-2048 size: 2048
[    3.288064] Allocated:
[    3.288147] PID = 27
[    3.288218]  [&lt;ffffffff940b27ab&gt;] save_stack_trace+0x2b/0x50
[    3.288531]  [&lt;ffffffff9459f246&gt;] save_stack+0x46/0xd0
[    3.288806]  [&lt;ffffffff9459f4bd&gt;] kasan_kmalloc+0xad/0xe0
[    3.289098]  [&lt;ffffffff9459c07e&gt;] __kmalloc+0x13e/0x250
[    3.289378]  [&lt;ffffffff95078e5a&gt;] scsi_alloc_sdev+0xea/0xcf0
[    3.289701]  [&lt;ffffffff9507de76&gt;] __scsi_scan_target+0xa06/0xdf0
[    3.290034]  [&lt;ffffffff9507e505&gt;] scsi_scan_channel+0x105/0x160
[    3.290362]  [&lt;ffffffff9507e8a2&gt;] scsi_scan_host_selected+0x212/0x2f0
[    3.290724]  [&lt;ffffffff9507eb3c&gt;] do_scsi_scan_host+0x1bc/0x250
[    3.291055]  [&lt;ffffffff9507efc1&gt;] do_scan_async+0x41/0x450
[    3.291354]  [&lt;ffffffff941c1fee&gt;] async_run_entry_fn+0xfe/0x610
[    3.291695]  [&lt;ffffffff941a9a84&gt;] process_one_work+0x544/0x12d0
[    3.292022]  [&lt;ffffffff941aa8e9&gt;] worker_thread+0xd9/0x12f0
[    3.292325]  [&lt;ffffffff941bb365&gt;] kthread+0x1c5/0x260
[    3.292594]  [&lt;ffffffff956dde9f&gt;] ret_from_fork+0x1f/0x40
[    3.292886] Freed:
[    3.292945] PID = 27
[    3.293016]  [&lt;ffffffff940b27ab&gt;] save_stack_trace+0x2b/0x50
[    3.293327]  [&lt;ffffffff9459f246&gt;] save_stack+0x46/0xd0
[    3.293600]  [&lt;ffffffff9459fa61&gt;] kasan_slab_free+0x71/0xb0
[    3.293916]  [&lt;ffffffff9459bac2&gt;] kfree+0xa2/0x1f0
[    3.294168]  [&lt;ffffffff9508158a&gt;] scsi_device_dev_release_usercontext+0x50a/0x730
[    3.294598]  [&lt;ffffffff941ace9a&gt;] execute_in_process_context+0xda/0x130
[    3.294974]  [&lt;ffffffff9508107c&gt;] scsi_device_dev_release+0x1c/0x20
[    3.295322]  [&lt;ffffffff94f566f6&gt;] device_release+0x76/0x1e0
[    3.295626]  [&lt;ffffffff94bc2db7&gt;] kobject_release+0x107/0x370
[    3.295942]  [&lt;ffffffff94bc29ce&gt;] kobject_put+0x4e/0xa0
[    3.296222]  [&lt;ffffffff94f56e17&gt;] put_device+0x17/0x20
[    3.296497]  [&lt;ffffffff9505201c&gt;] scsi_device_put+0x7c/0xa0
[    3.296801]  [&lt;ffffffff9507e1bc&gt;] __scsi_scan_target+0xd4c/0xdf0
[    3.297132]  [&lt;ffffffff9507e505&gt;] scsi_scan_channel+0x105/0x160
[    3.297458]  [&lt;ffffffff9507e8a2&gt;] scsi_scan_host_selected+0x212/0x2f0
[    3.297829]  [&lt;ffffffff9507eb3c&gt;] do_scsi_scan_host+0x1bc/0x250
[    3.298156]  [&lt;ffffffff9507efc1&gt;] do_scan_async+0x41/0x450
[    3.298453]  [&lt;ffffffff941c1fee&gt;] async_run_entry_fn+0xfe/0x610
[    3.298777]  [&lt;ffffffff941a9a84&gt;] process_one_work+0x544/0x12d0
[    3.299105]  [&lt;ffffffff941aa8e9&gt;] worker_thread+0xd9/0x12f0
[    3.299408]  [&lt;ffffffff941bb365&gt;] kthread+0x1c5/0x260
[    3.299676]  [&lt;ffffffff956dde9f&gt;] ret_from_fork+0x1f/0x40
[    3.299967] Memory state around the buggy address:
[    3.300209]  ffff880254d8c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[    3.300608]  ffff880254d8c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[    3.300986] &gt;ffff880254d8c300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[    3.301408]                    ^
[    3.301550]  ffff880254d8c380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[    3.301987]  ffff880254d8c400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
[    3.302396]
==================================================================

Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Ming Lei &lt;tom.leiming@gmail.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>aacraid: Check size values after double-fetch from user</title>
<updated>2016-08-31T23:26:17+00:00</updated>
<author>
<name>Dave Carroll</name>
<email>david.carroll@microsemi.com</email>
</author>
<published>2016-08-05T19:44:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=30c2bbd8a7b7ff3b6849d6ce1a69d4db9e40183b'/>
<id>30c2bbd8a7b7ff3b6849d6ce1a69d4db9e40183b</id>
<content type='text'>
[ Upstream commit fa00c437eef8dc2e7b25f8cd868cfa405fcc2bb3 ]

In aacraid's ioctl_send_fib() we do two fetches from userspace, one the
get the fib header's size and one for the fib itself. Later we use the
size field from the second fetch to further process the fib. If for some
reason the size from the second fetch is different than from the first
fix, we may encounter an out-of- bounds access in aac_fib_send(). We
also check the sender size to insure it is not out of bounds. This was
reported in https://bugzilla.kernel.org/show_bug.cgi?id=116751 and was
assigned CVE-2016-6480.

Reported-by: Pengfei Wang &lt;wpengfeinudt@gmail.com&gt;
Fixes: 7c00ffa31 '[SCSI] 2.6 aacraid: Variable FIB size (updated patch)'
Cc: stable@vger.kernel.org
Signed-off-by: Dave Carroll &lt;david.carroll@microsemi.com&gt;
Reviewed-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit fa00c437eef8dc2e7b25f8cd868cfa405fcc2bb3 ]

In aacraid's ioctl_send_fib() we do two fetches from userspace, one the
get the fib header's size and one for the fib itself. Later we use the
size field from the second fetch to further process the fib. If for some
reason the size from the second fetch is different than from the first
fix, we may encounter an out-of- bounds access in aac_fib_send(). We
also check the sender size to insure it is not out of bounds. This was
reported in https://bugzilla.kernel.org/show_bug.cgi?id=116751 and was
assigned CVE-2016-6480.

Reported-by: Pengfei Wang &lt;wpengfeinudt@gmail.com&gt;
Fixes: 7c00ffa31 '[SCSI] 2.6 aacraid: Variable FIB size (updated patch)'
Cc: stable@vger.kernel.org
Signed-off-by: Dave Carroll &lt;david.carroll@microsemi.com&gt;
Reviewed-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>ipr: Clear interrupt on croc/crocodile when running with LSI</title>
<updated>2016-07-19T22:20:07+00:00</updated>
<author>
<name>Brian King</name>
<email>brking@linux.vnet.ibm.com</email>
</author>
<published>2016-06-27T14:09:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=9f0a4f41de5d93907d09c6c18bc782d623b255ab'/>
<id>9f0a4f41de5d93907d09c6c18bc782d623b255ab</id>
<content type='text'>
[ Upstream commit 54e430bbd490e18ab116afa4cd90dcc45787b3df ]

If we fall back to using LSI on the Croc or Crocodile chip we need to
clear the interrupt so we don't hang the system.

Cc: &lt;stable@vger.kernel.org&gt;
Tested-by: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Signed-off-by: Brian King &lt;brking@linux.vnet.ibm.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 54e430bbd490e18ab116afa4cd90dcc45787b3df ]

If we fall back to using LSI on the Croc or Crocodile chip we need to
clear the interrupt so we don't hang the system.

Cc: &lt;stable@vger.kernel.org&gt;
Tested-by: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
Signed-off-by: Brian King &lt;brking@linux.vnet.ibm.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>lpfc: fix misleading indentation</title>
<updated>2016-07-12T12:48:03+00:00</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2016-03-14T14:29:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=7934ff912c6ec1f29bc2ce30f7bda06f3fd6f6f9'/>
<id>7934ff912c6ec1f29bc2ce30f7bda06f3fd6f6f9</id>
<content type='text'>
[ Upstream commit aeb6641f8ebdd61939f462a8255b316f9bfab707 ]

gcc-6 complains about the indentation of the lpfc_destroy_vport_work_array()
call in lpfc_online(), which clearly doesn't look right:

drivers/scsi/lpfc/lpfc_init.c: In function 'lpfc_online':
drivers/scsi/lpfc/lpfc_init.c:2880:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
   lpfc_destroy_vport_work_array(phba, vports);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/lpfc/lpfc_init.c:2863:2: note: ...this 'if' clause, but it is not
  if (vports != NULL)
  ^~

Looking at the patch that introduced this code, it's clear that the
behavior is correct and the indentation is wrong.

This fixes the indentation and adds curly braces around the previous
if() block for clarity, as that is most likely what caused the code
to be misindented in the first place.

Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Fixes: 549e55cd2a1b ("[SCSI] lpfc 8.2.2 : Fix locking around HBA's port_list")
Reviewed-by: Sebastian Herbszt &lt;herbszt@gmx.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Reviewed-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit aeb6641f8ebdd61939f462a8255b316f9bfab707 ]

gcc-6 complains about the indentation of the lpfc_destroy_vport_work_array()
call in lpfc_online(), which clearly doesn't look right:

drivers/scsi/lpfc/lpfc_init.c: In function 'lpfc_online':
drivers/scsi/lpfc/lpfc_init.c:2880:3: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
   lpfc_destroy_vport_work_array(phba, vports);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/lpfc/lpfc_init.c:2863:2: note: ...this 'if' clause, but it is not
  if (vports != NULL)
  ^~

Looking at the patch that introduced this code, it's clear that the
behavior is correct and the indentation is wrong.

This fixes the indentation and adds curly braces around the previous
if() block for clarity, as that is most likely what caused the code
to be misindented in the first place.

Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Fixes: 549e55cd2a1b ("[SCSI] lpfc 8.2.2 : Fix locking around HBA's port_list")
Reviewed-by: Sebastian Herbszt &lt;herbszt@gmx.de&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Reviewed-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>megaraid_sas: add missing curly braces in ioctl handler</title>
<updated>2016-07-12T12:47:59+00:00</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2016-03-14T14:29:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux-stable.git/commit/?id=d804e5ecb92a93baba6b2cd665ca76957973e09d'/>
<id>d804e5ecb92a93baba6b2cd665ca76957973e09d</id>
<content type='text'>
[ Upstream commit 3deb9438d34a09f6796639b652a01d110aca9f75 ]

gcc-6 found a dubious indentation in the megasas_mgmt_fw_ioctl
function:

drivers/scsi/megaraid/megaraid_sas_base.c: In function 'megasas_mgmt_fw_ioctl':
drivers/scsi/megaraid/megaraid_sas_base.c:6658:4: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
    kbuff_arr[i] = NULL;
    ^~~~~~~~~
drivers/scsi/megaraid/megaraid_sas_base.c:6653:3: note: ...this 'if' clause, but it is not
   if (kbuff_arr[i])
   ^~

The code is actually correct, as there is no downside in clearing a NULL
pointer again.

This clarifies the code and avoids the warning by adding extra curly
braces.

Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Fixes: 90dc9d98f01b ("megaraid_sas : MFI MPT linked list corruption fix")
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Acked-by: Sumit Saxena &lt;sumit.saxena@broadcom.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[ Upstream commit 3deb9438d34a09f6796639b652a01d110aca9f75 ]

gcc-6 found a dubious indentation in the megasas_mgmt_fw_ioctl
function:

drivers/scsi/megaraid/megaraid_sas_base.c: In function 'megasas_mgmt_fw_ioctl':
drivers/scsi/megaraid/megaraid_sas_base.c:6658:4: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
    kbuff_arr[i] = NULL;
    ^~~~~~~~~
drivers/scsi/megaraid/megaraid_sas_base.c:6653:3: note: ...this 'if' clause, but it is not
   if (kbuff_arr[i])
   ^~

The code is actually correct, as there is no downside in clearing a NULL
pointer again.

This clarifies the code and avoids the warning by adding extra curly
braces.

Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Fixes: 90dc9d98f01b ("megaraid_sas : MFI MPT linked list corruption fix")
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Acked-by: Sumit Saxena &lt;sumit.saxena@broadcom.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
