Skip to content

Commit eff7be6

Browse files
committed
scsi: mpi3mr: Fix NVMe ioctl handling for non-PCIe devices
The driver incorrectly allows NVMe ioctls on SAS/SATA devices because it accesses dev_spec.pcie_inf.dev_info without first checking dev_type. For SAS/SATA devices, the dev_spec union contains sas_sata_inf data, but the driver reads it as pcie_inf, misinterpreting the data and potentially matching the NVMe type check, causing NVME_IOCTL_ID to incorrectly return 1 (SUCCESS) instead of -EINVAL. The only place Jeff is able to reproduce this is M60 Active controller where sedutil-cli --scan were showing NVMe identify error for SAS disks on 9600 HBA. Add a dev_type check to ensure only PCIe devices proceed with NVMe ioctl handling. Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
1 parent ebc45eb commit eff7be6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5584,6 +5584,9 @@ static int mpi3mr_scsih_ioctl(struct scsi_device *sdev, unsigned int cmd, void _
55845584
struct mpi3mr_tgt_dev *tgt_dev = mpi3mr_get_tgtdev_by_handle(mrioc,
55855585
sas_target_priv_data->dev_handle);
55865586

5587+
if (!tgt_dev || tgt_dev->dev_type != MPI3_DEVICE_DEVFORM_PCIE)
5588+
return (-EINVAL);
5589+
55875590
if ((tgt_dev->dev_spec.pcie_inf.dev_info &
55885591
MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_MASK) !=
55895592
MPI3_DEVICE0_PCIE_DEVICE_INFO_TYPE_NVME_DEVICE) {

0 commit comments

Comments
 (0)