linux-stable/drivers
Kees Cook 7ab734fc75 scsi: aacraid: Allocate cmd_priv with scsicmd
The aac_priv() helper assumes that the private cmd area immediately follows
struct scsi_cmnd. Allocate this space as part of scsicmd, else there is a
risk of heap overflow. Seen with GCC 13:

../drivers/scsi/aacraid/aachba.c: In function 'aac_probe_container':
../drivers/scsi/aacraid/aachba.c:841:26: warning: array subscript 16 is outside array bounds of 'void[392]' [-Warray-bounds=]
  841 |         status = cmd_priv->status;
      |                          ^~
In file included from ../include/linux/resource_ext.h:11,
                 from ../include/linux/pci.h:40,
                 from ../drivers/scsi/aacraid/aachba.c:22:
In function 'kmalloc',
    inlined from 'kzalloc' at ../include/linux/slab.h:720:9,
    inlined from 'aac_probe_container' at ../drivers/scsi/aacraid/aachba.c:821:30:
../include/linux/slab.h:580:24: note: at offset 392 into object of size 392 allocated by 'kmalloc_trace'
  580 |                 return kmalloc_trace(
      |                        ^~~~~~~~~~~~~~
  581 |                                 kmalloc_caches[kmalloc_type(flags)][index],
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  582 |                                 flags, size);
      |                                 ~~~~~~~~~~~~

Fixes: 76a3451b64 ("scsi: aacraid: Move the SCSI pointer to private command data")
Link: https://lore.kernel.org/r/20230128000409.never.976-kees@kernel.org
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: Adaptec OEM Raid Solutions <aacraid@microsemi.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Vegard Nossum <vegard.nossum@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-02-08 18:49:48 -05:00
..
accel Fix mismerge due to devnode now taking a 'const *' device 2022-12-16 13:04:15 -06:00
accessibility
acpi treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
amba ARM updates for 6.2 2022-12-13 15:22:14 -08:00
android
ata scsi: ata: libata-scsi: Convert to scsi_execute_cmd() 2023-01-13 21:34:08 -05:00
atm treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
auxdisplay
base Kbuild updates for v6.2 2022-12-19 12:33:32 -06:00
bcma
block treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
bluetooth treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
bus Char/Misc driver changes for 6.2-rc1 2022-12-16 03:49:24 -08:00
cdrom
char random: do not include <asm/archrandom.h> from random.h 2022-12-20 03:13:45 +01:00
clk A pile of clk driver updates with a small tracepoint patch to the clk core this 2022-12-13 13:46:07 -08:00
clocksource Updates for timers, timekeeping and drivers: 2022-12-12 12:52:02 -08:00
comedi
connector
counter
cpufreq linux-kselftest-next-6.2-rc1 2022-12-12 16:39:38 -08:00
cpuidle powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
crypto powerpc updates for 6.2 2022-12-19 07:13:33 -06:00
cxl cxl/region: Fix memdev reuse check 2022-12-08 13:03:47 -08:00
dax
dca
devfreq
dio
dma dmaengine updates for v6.2 2022-12-19 08:54:17 -06:00
dma-buf Driver Core changes for 6.2-rc1 2022-12-16 03:54:54 -08:00
edac Merge branches 'edac-ghes' and 'edac-misc' into edac-updates-for-v6.2 2022-12-12 15:40:03 +01:00
eisa
extcon Char/Misc driver changes for 6.2-rc1 2022-12-16 03:49:24 -08:00
firewire
firmware remoteproc updates for v6.2 2022-12-21 09:37:14 -08:00
fpga Char/Misc driver changes for 6.2-rc1 2022-12-16 03:49:24 -08:00
fsi
gnss
gpio pwm: Changes for v6.2-rc1 2022-12-21 09:41:28 -08:00
gpu treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
greybus
hid treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
hsi
hte
hv Networking changes for 6.2. 2022-12-13 15:47:48 -08:00
hwmon scsi: hwmon: drivetemp: Convert to scsi_execute_cmd() 2023-01-13 21:34:08 -05:00
hwspinlock
hwtracing
i2c Core got a new helper 'i2c_client_get_device_id', designware got some 2022-12-15 14:47:10 -08:00
i3c i3c: export SETDASA method 2022-12-11 21:25:58 +01:00
idle
iio Char/Misc driver changes for 6.2-rc1 2022-12-16 03:49:24 -08:00
infiniband v6.2 merge window 2nd pull request 2022-12-17 08:23:42 -06:00
input treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
interconnect
iommu IOMMU Updates for Linux v6.2 2022-12-19 08:34:39 -06:00
ipack
irqchip RISC-V Patches for the 6.2 Merge Window, Part 1 2022-12-14 15:23:49 -08:00
isdn treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
leds treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
macintosh
mailbox - qcom: enable sc8280xp, sm8550 and sm4250 support 2022-12-21 09:31:18 -08:00
mcb
md - Fix use-after-free races due to missing resource cleanup during DM 2022-12-13 10:58:09 -08:00
media treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
memory ARM updates for 6.2 2022-12-13 15:22:14 -08:00
memstick memstick/mspro_block: Convert to use sysfs_emit()/sysfs_emit_at() APIs 2022-12-09 10:29:58 +01:00
message
mfd - New Drivers 2022-12-21 09:19:24 -08:00
misc kernel hardening fixes for v6.2-rc1 2022-12-23 12:00:24 -08:00
mmc MMC core: 2022-12-13 13:41:26 -08:00
most
mtd MTD core changes: 2022-12-13 12:32:07 -08:00
mux
net treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
nfc treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
ntb
nubus
nvdimm
nvme SCSI misc on 20221222 2022-12-22 11:22:31 -08:00
nvmem Char/Misc driver changes for 6.2-rc1 2022-12-16 03:49:24 -08:00
of Devicetree updates for v6.2, part 2: 2022-12-20 08:48:24 -06:00
opp
parisc parisc: led: Fix potential null-ptr-deref in start_task() 2022-12-17 23:19:38 +01:00
parport
pci phy-for-6.2 2022-12-19 08:40:58 -06:00
pcmcia treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
peci
perf RISC-V Patches for the 6.2 Merge Window, Part 1 2022-12-14 15:23:49 -08:00
phy phy-for-6.2 2022-12-19 08:40:58 -06:00
pinctrl Pin control changes for the v6.2 kernel cycle: 2022-12-13 13:03:06 -08:00
platform USB/Thunderbolt driver changes for 6.2-rc1 2022-12-16 03:22:53 -08:00
pnp
power power supply and reset changes for the v6.2 series 2022-12-17 08:39:31 -06:00
powercap
pps
ps3
ptp Networking changes for 6.2. 2022-12-13 15:47:48 -08:00
pwm pwm: Changes for v6.2-rc1 2022-12-21 09:41:28 -08:00
rapidio rapidio: devices: fix missing put_device in mport_cdev_open 2022-12-11 19:30:20 -08:00
ras
regulator regulator: Fixes for v6.2 2022-12-23 14:38:00 -08:00
remoteproc remoteproc: core: Do pm_relax when in RPROC_OFFLINE state 2022-12-07 11:20:55 -07:00
reset
rpmsg
rtc - New Drivers 2022-12-21 09:19:24 -08:00
s390 Driver Core changes for 6.2-rc1 2022-12-16 03:54:54 -08:00
sbus
scsi scsi: aacraid: Allocate cmd_priv with scsicmd 2023-02-08 18:49:48 -05:00
sh
siox
slimbus
soc ARM: SoC fixes for 6.2 2022-12-19 16:07:59 -06:00
soundwire soundwire updates for 6.2 2022-12-19 08:47:33 -06:00
spi spi: Fix for v6.2 2022-12-23 14:44:08 -08:00
spmi
ssb
staging treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
target scsi: target: target_core_pscsi: Convert to scsi_execute_cmd() 2023-01-13 21:34:09 -05:00
tc
tee SoC driver updates for 6.2 2022-12-12 10:17:08 -08:00
thermal More thermal control updates for 6.2-rc1 2022-12-15 10:16:04 -08:00
thunderbolt
tty treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
ufs scsi: ufs: ufs-qcom: Clear qunipro_g4_sel for HW version major 5 2023-02-08 18:05:22 -05:00
uio
usb treewide: Convert del_timer*() to timer_shutdown*() 2022-12-25 13:38:09 -08:00
vdpa
vfio Driver Core changes for 6.2-rc1 2022-12-16 03:54:54 -08:00
vhost
video - Fix-ups 2022-12-21 09:24:39 -08:00
virt Char/Misc driver changes for 6.2-rc1 2022-12-16 03:49:24 -08:00
virtio
vlynq
w1
watchdog linux-watchdog 6.2-rc1 tag 2022-12-17 08:34:01 -06:00
xen drm for 6.2: 2022-12-13 11:59:58 -08:00
zorro
Kconfig
Makefile