linux_dsm_epyc7002/drivers
Benjamin Block dac37e15b7 scsi: zfcp: fix use-after-"free" in FC ingress path after TMF
When SCSI EH invokes zFCP's callbacks for eh_device_reset_handler() and
eh_target_reset_handler(), it expects us to relent the ownership over
the given scsi_cmnd and all other scsi_cmnds within the same scope - LUN
or target - when returning with SUCCESS from the callback ('release'
them).  SCSI EH can then reuse those commands.

We did not follow this rule to release commands upon SUCCESS; and if
later a reply arrived for one of those supposed to be released commands,
we would still make use of the scsi_cmnd in our ingress tasklet. This
will at least result in undefined behavior or a kernel panic because of
a wrong kernel pointer dereference.

To fix this, we NULLify all pointers to scsi_cmnds (struct zfcp_fsf_req
*)->data in the matching scope if a TMF was successful. This is done
under the locks (struct zfcp_adapter *)->abort_lock and (struct
zfcp_reqlist *)->lock to prevent the requests from being removed from
the request-hashtable, and the ingress tasklet from making use of the
scsi_cmnd-pointer in zfcp_fsf_fcp_cmnd_handler().

For cases where a reply arrives during SCSI EH, but before we get a
chance to NULLify the pointer - but before we return from the callback
-, we assume that the code is protected from races via the CAS operation
in blk_complete_request() that is called in scsi_done().

The following stacktrace shows an example for a crash resulting from the
previous behavior:

Unable to handle kernel pointer dereference at virtual kernel address fffffee17a672000
Oops: 0038 [#1] SMP
CPU: 2 PID: 0 Comm: swapper/2 Not tainted
task: 00000003f7ff5be0 ti: 00000003f3d38000 task.ti: 00000003f3d38000
Krnl PSW : 0404d00180000000 00000000001156b0 (smp_vcpu_scheduled+0x18/0x40)
           R:0 T:1 IO:0 EX:0 Key:0 M:1 W:0 P:0 AS:3 CC:1 PM:0 EA:3
Krnl GPRS: 000000200000007e 0000000000000000 fffffee17a671fd8 0000000300000015
           ffffffff80000000 00000000005dfde8 07000003f7f80e00 000000004fa4e800
           000000036ce8d8f8 000000036ce8d9c0 00000003ece8fe00 ffffffff969c9e93
           00000003fffffffd 000000036ce8da10 00000000003bf134 00000003f3b07918
Krnl Code: 00000000001156a2: a7190000        lghi    %r1,0
           00000000001156a6: a7380015        lhi    %r3,21
          #00000000001156aa: e32050000008    ag    %r2,0(%r5)
          >00000000001156b0: 482022b0        lh    %r2,688(%r2)
           00000000001156b4: ae123000        sigp    %r1,%r2,0(%r3)
           00000000001156b8: b2220020        ipm    %r2
           00000000001156bc: 8820001c        srl    %r2,28
           00000000001156c0: c02700000001    xilf    %r2,1
Call Trace:
([<0000000000000000>] 0x0)
 [<000003ff807bdb8e>] zfcp_fsf_fcp_cmnd_handler+0x3de/0x490 [zfcp]
 [<000003ff807be30a>] zfcp_fsf_req_complete+0x252/0x800 [zfcp]
 [<000003ff807c0a48>] zfcp_fsf_reqid_check+0xe8/0x190 [zfcp]
 [<000003ff807c194e>] zfcp_qdio_int_resp+0x66/0x188 [zfcp]
 [<000003ff80440c64>] qdio_kick_handler+0xdc/0x310 [qdio]
 [<000003ff804463d0>] __tiqdio_inbound_processing+0xf8/0xcd8 [qdio]
 [<0000000000141fd4>] tasklet_action+0x9c/0x170
 [<0000000000141550>] __do_softirq+0xe8/0x258
 [<000000000010ce0a>] do_softirq+0xba/0xc0
 [<000000000014187c>] irq_exit+0xc4/0xe8
 [<000000000046b526>] do_IRQ+0x146/0x1d8
 [<00000000005d6a3c>] io_return+0x0/0x8
 [<00000000005d6422>] vtime_stop_cpu+0x4a/0xa0
([<0000000000000000>] 0x0)
 [<0000000000103d8a>] arch_cpu_idle+0xa2/0xb0
 [<0000000000197f94>] cpu_startup_entry+0x13c/0x1f8
 [<0000000000114782>] smp_start_secondary+0xda/0xe8
 [<00000000005d6efe>] restart_int_handler+0x56/0x6c
 [<0000000000000000>] 0x0
Last Breaking-Event-Address:
 [<00000000003bf12e>] arch_spin_lock_wait+0x56/0xb0

Suggested-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Fixes: ea127f9754 ("[PATCH] s390 (7/7): zfcp host adapter.") (tglx/history.git)
Cc: <stable@vger.kernel.org> #2.6.32+
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-12-14 15:14:04 -05:00
..
accessibility
acpi ACPI material for v4.10-rc1 2016-12-13 11:06:21 -08:00
amba
android
ata Merge branch 'for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata 2016-12-13 15:30:50 -08:00
atm Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-12-06 21:33:19 -05:00
auxdisplay auxdisplay: ht16k33: select framebuffer helper modules 2016-11-30 13:04:31 +01:00
base Driver core patches for 4.10-rc1 2016-12-13 11:42:18 -08:00
bcma bcma: add Dell Inspiron 3148 2016-11-29 17:35:14 +02:00
block SCSI misc on 20161213 2016-12-14 10:49:33 -08:00
bluetooth Bluetooth: btmrvl: drop duplicate header slab.h 2016-12-08 07:44:56 +01:00
bus
cdrom
char xen: features and fixes for 4.10 rc0 2016-12-13 16:07:55 -08:00
clk clk: bcm: Fix 'maybe-uninitialized' warning in bcm2835_clock_choose_div_and_prate() 2016-12-12 11:25:40 -08:00
clocksource
connector
cpufreq Power management material for v4.10-rc1 2016-12-13 10:41:53 -08:00
cpuidle cpuidle: Add a kerneldoc comment to cpuidle_use_deepest_state() 2016-12-06 02:25:03 +01:00
crypto Merge branch 'x86-fpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-12 14:27:49 -08:00
dax device-dax: fix private mapping restriction, permit read-only 2016-12-06 17:42:37 -08:00
dca
devfreq devfreq: rk3399_dmc: Don't use OPP structures outside of RCU locks 2016-12-08 01:46:07 +01:00
dio
dma remoteproc updates for v4.10 2016-12-13 08:49:12 -08:00
dma-buf
edac EDAC, amd64: Fix improper return value 2016-12-04 10:51:42 +01:00
eisa
extcon
firewire
firmware arm64 updates for 4.10: 2016-12-13 16:39:21 -08:00
fmc
fpga fpga: Clarify how write_init works streaming modes 2016-11-29 15:51:49 -06:00
gpio Bulk GPIO changes for the v4.10 kernel cycle: 2016-12-13 07:54:57 -08:00
gpu Main pull request for drm for 4.10 kernel 2016-12-13 09:35:09 -08:00
hid HID: hid-sensor-hub: clear memory to avoid random data 2016-11-23 17:54:58 +01:00
hsi
hv uio-hv-generic: new userspace i/o driver for VMBus 2016-12-06 11:52:49 +01:00
hwmon hwmon: (g762) Fix overflows and crash seen when writing limit attributes 2016-12-12 11:33:44 -08:00
hwspinlock
hwtracing coresight: perf: Add a missing call to etm_free_aux 2016-11-29 20:05:32 +01:00
i2c Revert "i2c: octeon: thunderx: Limit register access retries" 2016-11-29 20:04:21 +01:00
ide
idle Power management material for v4.10-rc1 2016-12-13 10:41:53 -08:00
iio iio: magnetometer: separate the values of attributes based on their usage type for HID compass sensor 2016-11-24 20:41:30 +00:00
infiniband
input xen: features and fixes for 4.10 rc0 2016-12-13 16:07:55 -08:00
iommu Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-12 19:25:04 -08:00
ipack
irqchip arm64 updates for 4.10: 2016-12-13 16:39:21 -08:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-12-10 16:21:55 -05:00
leds leds: pca955x: Add ACPI support 2016-12-02 09:31:50 +01:00
lguest
lightnvm Char/Misc driver patches for 4.10-rc1 2016-12-13 12:11:01 -08:00
macintosh
mailbox
mcb
md . various fixes and improvements to request-based DM and DM multipath 2016-12-14 11:01:00 -08:00
media USB/PHY patches for 4.10-rc1 2016-12-13 11:10:36 -08:00
memory
memstick Merge branch 'for-4.10/block' of git://git.kernel.dk/linux-block 2016-12-13 10:19:16 -08:00
message SCSI misc on 20161213 2016-12-14 10:49:33 -08:00
mfd Staging/IIO patches for 4.10-rc1 2016-12-13 11:35:00 -08:00
misc Char/Misc driver patches for 4.10-rc1 2016-12-13 12:11:01 -08:00
mmc MMC core: 2016-12-14 10:55:56 -08:00
mtd
net scsi: cxgb4i: libcxgbi: cxgb4: add T6 iSCSI completion feature 2016-12-14 15:09:13 -05:00
nfc
ntb
nubus
nvdimm These are the documentation changes for 4.10. 2016-12-12 21:58:13 -08:00
nvme Just one simple change from Andrzej to drop the pointless return value 2016-12-14 10:31:25 -08:00
nvmem
of Char/Misc driver patches for 4.10-rc1 2016-12-13 12:11:01 -08:00
oprofile oprofile/nmi timer: Convert to hotplug state machine 2016-12-02 00:52:34 +01:00
parisc
parport
pci Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2016-12-13 16:33:33 -08:00
pcmcia drivers/pcmcia/m32r_pcc.c: check return from add_pcc_socket 2016-12-12 18:55:06 -08:00
perf
phy SCSI misc on 20161213 2016-12-14 10:49:33 -08:00
pinctrl Bulk pin control changes for the v4.10 kernel cycle: 2016-12-13 07:59:10 -08:00
platform Char/Misc driver patches for 4.10-rc1 2016-12-13 12:11:01 -08:00
pnp
power
powercap powercap / RAPL: Add Knights Mill CPUID 2016-11-30 23:41:33 +01:00
pps
ps3
ptp Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-12 19:56:15 -08:00
pwm pwm: Fix device reference leak 2016-11-29 16:43:24 +01:00
rapidio
ras
regulator Merge remote-tracking branches 'regulator/topic/tps65086' and 'regulator/topic/twl' into regulator-next 2016-12-12 12:17:31 +00:00
remoteproc remoteproc: qcom_adsp_pil: select qcom_scm 2016-12-09 16:16:56 -08:00
reset
rpmsg rpmsg updates for v4.10 2016-12-13 08:52:45 -08:00
rtc Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-12 19:56:15 -08:00
s390 scsi: zfcp: fix use-after-"free" in FC ingress path after TMF 2016-12-14 15:14:04 -05:00
sbus
scsi scsi: libcxgbi: return error if interface is not up 2016-12-14 15:11:53 -05:00
sfi
sh lib: radix-tree: check accounting of existing slot replacement users 2016-12-12 18:55:08 -08:00
sn
soc This is a fairly quiet release. We don't have any patches to the core 2016-12-13 08:54:27 -08:00
spi Merge remote-tracking branches 'spi/topic/spidev', 'spi/topic/sunxi', 'spi/topic/ti-qspi', 'spi/topic/topcliff-pch' and 'spi/topic/xlp' into spi-next 2016-12-12 15:54:20 +00:00
spmi
ssb
staging Staging/IIO patches for 4.10-rc1 2016-12-13 11:35:00 -08:00
target SCSI misc on 20161213 2016-12-14 10:49:33 -08:00
tc
thermal Power management material for v4.10-rc1 2016-12-13 10:41:53 -08:00
thunderbolt Char/Misc driver patches for 4.10-rc1 2016-12-13 12:11:01 -08:00
tty Merge branch 'for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq 2016-12-13 12:59:57 -08:00
uio uio-hv-generic: store physical addresses instead of virtual 2016-12-10 14:57:58 +01:00
usb Just one simple change from Andrzej to drop the pointless return value 2016-12-14 10:31:25 -08:00
uwb
vfio vfio iommu type1: Fix size argument to vfio_find_dma() in pin_pages/unpin_pages 2016-12-06 12:35:53 -07:00
vhost Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2016-12-12 10:48:02 -08:00
video xen: features and fixes for 4.10 rc0 2016-12-13 16:07:55 -08:00
virt
virtio
vlynq
vme
w1
watchdog Char/Misc driver patches for 4.10-rc1 2016-12-13 12:11:01 -08:00
xen xen: features and fixes for 4.10 rc0 2016-12-13 16:07:55 -08:00
zorro
Kconfig
Makefile