Skip to content

Commit da3cc67

Browse files
Rajashekhara, MaheshJames Bottomley
authored andcommitted
[SCSI] aacraid: prohibit access to array container space
Problem description: -------------------- The issue reported by one of the customer was able to read LBA beyond the array reported size with "sg_read" utility. If N is the last block address reported, then should not be able to read past N, i.e. N+1. But in their case, reported last LBA=143134719. So should not have been able to read with LBA=143134720, but it is read without failure, which means reported size to the OS is not correct and is less than the actual last block address. Solution: --------- Firmware layer exposes lesser container capacity than the actual one. It exposes [Actual size - Spitfire space(10MB)] to the OS, IO's to the 10MB should be prohibited from the Linux driver. Driver checks LBA boundary, if its greater than the array reported size then sets sensekey to HARDWARE_ERROR and sends the notification to the MID layer. Signed-off-by: Mahesh Rajashekhara <aacraid@adaptec.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 1fc8010 commit da3cc67

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

‎drivers/scsi/aacraid/aachba.c‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,6 +1608,7 @@ static int aac_read(struct scsi_cmnd * scsicmd)
16081608
int status;
16091609
struct aac_dev *dev;
16101610
struct fib * cmd_fibcontext;
1611+
int cid;
16111612

16121613
dev = (struct aac_dev *)scsicmd->device->host->hostdata;
16131614
/*
@@ -1657,6 +1658,22 @@ static int aac_read(struct scsi_cmnd * scsicmd)
16571658
count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
16581659
break;
16591660
}
1661+
1662+
if ((lba + count) > (dev->fsa_dev[scmd_id(scsicmd)].size)) {
1663+
cid = scmd_id(scsicmd);
1664+
dprintk((KERN_DEBUG "aacraid: Illegal lba\n"));
1665+
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 |
1666+
SAM_STAT_CHECK_CONDITION;
1667+
set_sense(&dev->fsa_dev[cid].sense_data,
1668+
HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE,
1669+
ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0);
1670+
memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1671+
min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1672+
SCSI_SENSE_BUFFERSIZE));
1673+
scsicmd->scsi_done(scsicmd);
1674+
return 1;
1675+
}
1676+
16601677
dprintk((KERN_DEBUG "aac_read[cpu %d]: lba = %llu, t = %ld.\n",
16611678
smp_processor_id(), (unsigned long long)lba, jiffies));
16621679
if (aac_adapter_bounds(dev,scsicmd,lba))
@@ -1698,6 +1715,7 @@ static int aac_write(struct scsi_cmnd * scsicmd)
16981715
int status;
16991716
struct aac_dev *dev;
17001717
struct fib * cmd_fibcontext;
1718+
int cid;
17011719

17021720
dev = (struct aac_dev *)scsicmd->device->host->hostdata;
17031721
/*
@@ -1737,6 +1755,22 @@ static int aac_write(struct scsi_cmnd * scsicmd)
17371755
count = (scsicmd->cmnd[7] << 8) | scsicmd->cmnd[8];
17381756
fua = scsicmd->cmnd[1] & 0x8;
17391757
}
1758+
1759+
if ((lba + count) > (dev->fsa_dev[scmd_id(scsicmd)].size)) {
1760+
cid = scmd_id(scsicmd);
1761+
dprintk((KERN_DEBUG "aacraid: Illegal lba\n"));
1762+
scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 |
1763+
SAM_STAT_CHECK_CONDITION;
1764+
set_sense(&dev->fsa_dev[cid].sense_data,
1765+
HARDWARE_ERROR, SENCODE_INTERNAL_TARGET_FAILURE,
1766+
ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0);
1767+
memcpy(scsicmd->sense_buffer, &dev->fsa_dev[cid].sense_data,
1768+
min_t(size_t, sizeof(dev->fsa_dev[cid].sense_data),
1769+
SCSI_SENSE_BUFFERSIZE));
1770+
scsicmd->scsi_done(scsicmd);
1771+
return 1;
1772+
}
1773+
17401774
dprintk((KERN_DEBUG "aac_write[cpu %d]: lba = %llu, t = %ld.\n",
17411775
smp_processor_id(), (unsigned long long)lba, jiffies));
17421776
if (aac_adapter_bounds(dev,scsicmd,lba))

0 commit comments

Comments
 (0)