Commit ab2f0608 authored by Sumit.Saxena@avagotech.com's avatar Sumit.Saxena@avagotech.com Committed by Christoph Hellwig

megaraid_sas: fix the problem of non-existing VD exposed to host

This patch will address the issue of SCSI device created at OS level for
non existing VD. ldTgtIdtoLd[] array has size 256 for Extended VD firmware
and 128 for legacy firmware. Accessing indices beyond array size (OS will
send TUR, INQUIRY.. commands upto device index 255), may return valid LD
value and that particular SCSI command will be SUCCESS and creating SCSI
device for non existing target(VD).

For legacy firmware (64 VD firmware), invalidates LD (by setting LD value
to 0xff) in LdTgtIdtoLd[] array for device index beyond 127, so that
invalid LD(0xff) value should be returned beyond device index beyond 127.

Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarKashyap Desai <kashyap.desai@avagotech.com>
Signed-off-by: default avatarSumit Saxena <sumit.saxena@avagotech.com>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 7497cde8
...@@ -212,6 +212,9 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance) ...@@ -212,6 +212,9 @@ void MR_PopulateDrvRaidMap(struct megasas_instance *instance)
for (i = 0; i < MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS; i++) for (i = 0; i < MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS; i++)
pDrvRaidMap->ldTgtIdToLd[i] = pDrvRaidMap->ldTgtIdToLd[i] =
(u8)pFwRaidMap->ldTgtIdToLd[i]; (u8)pFwRaidMap->ldTgtIdToLd[i];
for (i = (MAX_RAIDMAP_LOGICAL_DRIVES + MAX_RAIDMAP_VIEWS);
i < MAX_LOGICAL_DRIVES_EXT; i++)
pDrvRaidMap->ldTgtIdToLd[i] = 0xff;
for (i = 0; i < ld_count; i++) { for (i = 0; i < ld_count; i++) {
pDrvRaidMap->ldSpanMap[i] = pFwRaidMap->ldSpanMap[i]; pDrvRaidMap->ldSpanMap[i] = pFwRaidMap->ldSpanMap[i];
#if VD_EXT_DEBUG #if VD_EXT_DEBUG
......
...@@ -1725,9 +1725,19 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance, ...@@ -1725,9 +1725,19 @@ megasas_build_dcdb_fusion(struct megasas_instance *instance,
if (scmd->device->channel < MEGASAS_MAX_PD_CHANNELS) if (scmd->device->channel < MEGASAS_MAX_PD_CHANNELS)
goto NonFastPath; goto NonFastPath;
/*
* For older firmware, Driver should not access ldTgtIdToLd
* beyond index 127 and for Extended VD firmware, ldTgtIdToLd
* should not go beyond 255.
*/
if ((!fusion->fast_path_io) ||
(device_id >= instance->fw_supported_vd_count))
goto NonFastPath;
ld = MR_TargetIdToLdGet(device_id, local_map_ptr); ld = MR_TargetIdToLdGet(device_id, local_map_ptr);
if ((ld >= instance->fw_supported_vd_count) ||
(!fusion->fast_path_io)) if (ld >= instance->fw_supported_vd_count)
goto NonFastPath; goto NonFastPath;
raid = MR_LdRaidGet(ld, local_map_ptr); raid = MR_LdRaidGet(ld, local_map_ptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment