1
0
Fork 0
alistair23-linux/drivers/scsi/fnic
Arnd Bergmann 86ee2a91cb scsi: fnic: fix invalid stack access
commit 42ec15ceae upstream.

gcc -O3 warns that some local variables are not properly initialized:

drivers/scsi/fnic/vnic_dev.c: In function 'fnic_dev_hang_notify':
drivers/scsi/fnic/vnic_dev.c:511:16: error: 'a0' is used uninitialized in this function [-Werror=uninitialized]
  vdev->args[0] = *a0;
  ~~~~~~~~~~~~~~^~~~~
drivers/scsi/fnic/vnic_dev.c:691:6: note: 'a0' was declared here
  u64 a0, a1;
      ^~
drivers/scsi/fnic/vnic_dev.c:512:16: error: 'a1' is used uninitialized in this function [-Werror=uninitialized]
  vdev->args[1] = *a1;
  ~~~~~~~~~~~~~~^~~~~
drivers/scsi/fnic/vnic_dev.c:691:10: note: 'a1' was declared here
  u64 a0, a1;
          ^~
drivers/scsi/fnic/vnic_dev.c: In function 'fnic_dev_mac_addr':
drivers/scsi/fnic/vnic_dev.c:512:16: error: 'a1' is used uninitialized in this function [-Werror=uninitialized]
  vdev->args[1] = *a1;
  ~~~~~~~~~~~~~~^~~~~
drivers/scsi/fnic/vnic_dev.c:698:10: note: 'a1' was declared here
  u64 a0, a1;
          ^~

Apparently the code relies on the local variables occupying adjacent memory
locations in the same order, but this is of course not guaranteed.

Use an array of two u64 variables where needed to make it work correctly.

I suspect there is also an endianness bug here, but have not digged in deep
enough to be sure.

Fixes: 5df6d737dd ("[SCSI] fnic: Add new Cisco PCI-Express FCoE HBA")
Fixes: mmtom ("init/Kconfig: enable -O3 for all arches")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200107201602.4096790-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-23 08:22:35 +01:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cq_desc.h
cq_enet_desc.h
cq_exch_desc.h
fcpio.h
fnic.h scsi: fnic: Update fnic driver version to 1.6.0.47 2019-01-22 21:18:35 -05:00
fnic_attrs.c
fnic_debugfs.c scsi: fnic: remove redundant assignment of variable rc 2019-08-19 21:51:00 -04:00
fnic_fcs.c scsi: fnic: print port speed only at driver init or speed change 2019-08-30 03:32:35 -04:00
fnic_fip.h
fnic_io.h scsi: fnic: support to display 20G port speed 2019-01-22 21:18:33 -05:00
fnic_isr.c scsi: fnic: fix msix interrupt allocation 2019-09-07 15:29:12 -04:00
fnic_main.c scsi: fnic: no need to check return value of debugfs_create functions 2019-01-29 00:40:53 -05:00
fnic_res.c
fnic_res.h
fnic_scsi.c scsi: fnic: Warn when calling done for IO not issued to fw 2019-01-22 21:18:34 -05:00
fnic_stats.h scsi: fnic: no need to check return value of debugfs_create functions 2019-01-29 00:40:53 -05:00
fnic_trace.c scsi: fnic: print port speed only at driver init or speed change 2019-08-30 03:32:35 -04:00
fnic_trace.h scsi: fnic: no need to check return value of debugfs_create functions 2019-01-29 00:40:53 -05:00
rq_enet_desc.h
vnic_cq.c
vnic_cq.h
vnic_cq_copy.h
vnic_dev.c scsi: fnic: fix invalid stack access 2020-01-23 08:22:35 +01:00
vnic_dev.h scsi: fnic: Enable fnic devcmd2 interface 2019-01-22 21:18:35 -05:00
vnic_devcmd.h scsi: fnic: fnic devcmd2 interface definitions 2019-01-22 21:18:34 -05:00
vnic_intr.c
vnic_intr.h
vnic_nic.h
vnic_resource.h scsi: fnic: fnic devcmd2 interface definitions 2019-01-22 21:18:34 -05:00
vnic_rq.c scsi: fnic: Remove set but not used variable 'vdev' 2019-01-29 01:16:09 -05:00
vnic_rq.h
vnic_scsi.h
vnic_stats.h
vnic_wq.c scsi: fnic: Remove set but not used variable 'vdev' 2019-01-29 01:16:09 -05:00
vnic_wq.h scsi: fnic: Add devcmd2 initialization helpers 2019-01-22 21:18:34 -05:00
vnic_wq_copy.c
vnic_wq_copy.h
wq_enet_desc.h