Skip to content

Commit 820bf5c

Browse files
committed
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "This is a set of five small fixes: one is a null deref fix which is pretty critical for the fc transport class and one fixes a potential security issue of sg leaking kernel information" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: sg: fixup infoleak when using SG_GET_REQUEST_TABLE scsi: sg: factor out sg_fill_request_table() scsi: sd: Remove unnecessary condition in sd_read_block_limits() scsi: acornscsi: fix build error scsi: scsi_transport_fc: fix NULL pointer dereference in fc_bsg_job_timeout
2 parents b8350cd + 3e00974 commit 820bf5c

File tree

4 files changed

+40
-34
lines changed

4 files changed

+40
-34
lines changed

drivers/scsi/arm/acornscsi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,9 +2725,9 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt)
27252725
* Params : SCpnt - command causing reset
27262726
* Returns : one of SCSI_RESET_ macros
27272727
*/
2728-
int acornscsi_host_reset(struct Scsi_Host *shpnt)
2728+
int acornscsi_host_reset(struct scsi_cmnd *SCpnt)
27292729
{
2730-
AS_Host *host = (AS_Host *)shpnt->hostdata;
2730+
AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata;
27312731
struct scsi_cmnd *SCptr;
27322732

27332733
host->stats.resets += 1;
@@ -2741,7 +2741,7 @@ int acornscsi_host_reset(struct Scsi_Host *shpnt)
27412741

27422742
printk(KERN_WARNING "acornscsi_reset: ");
27432743
print_sbic_status(asr, ssr, host->scsi.phase);
2744-
for (devidx = 0; devidx < 9; devidx ++) {
2744+
for (devidx = 0; devidx < 9; devidx++)
27452745
acornscsi_dumplog(host, devidx);
27462746
}
27472747
#endif

drivers/scsi/scsi_transport_fc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3571,7 +3571,7 @@ fc_vport_sched_delete(struct work_struct *work)
35713571
static enum blk_eh_timer_return
35723572
fc_bsg_job_timeout(struct request *req)
35733573
{
3574-
struct bsg_job *job = (void *) req->special;
3574+
struct bsg_job *job = blk_mq_rq_to_pdu(req);
35753575
struct Scsi_Host *shost = fc_bsg_to_shost(job);
35763576
struct fc_rport *rport = fc_bsg_to_rport(job);
35773577
struct fc_internal *i = to_fc_internal(shost->transportt);

drivers/scsi/sd.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,8 +2915,6 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
29152915
sd_config_discard(sdkp, SD_LBP_WS16);
29162916
else if (sdkp->lbpws10)
29172917
sd_config_discard(sdkp, SD_LBP_WS10);
2918-
else if (sdkp->lbpu && sdkp->max_unmap_blocks)
2919-
sd_config_discard(sdkp, SD_LBP_UNMAP);
29202918
else
29212919
sd_config_discard(sdkp, SD_LBP_DISABLE);
29222920
}

drivers/scsi/sg.c

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,39 @@ static int max_sectors_bytes(struct request_queue *q)
828828
return max_sectors << 9;
829829
}
830830

831+
static void
832+
sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo)
833+
{
834+
Sg_request *srp;
835+
int val;
836+
unsigned int ms;
837+
838+
val = 0;
839+
list_for_each_entry(srp, &sfp->rq_list, entry) {
840+
if (val > SG_MAX_QUEUE)
841+
break;
842+
rinfo[val].req_state = srp->done + 1;
843+
rinfo[val].problem =
844+
srp->header.masked_status &
845+
srp->header.host_status &
846+
srp->header.driver_status;
847+
if (srp->done)
848+
rinfo[val].duration =
849+
srp->header.duration;
850+
else {
851+
ms = jiffies_to_msecs(jiffies);
852+
rinfo[val].duration =
853+
(ms > srp->header.duration) ?
854+
(ms - srp->header.duration) : 0;
855+
}
856+
rinfo[val].orphan = srp->orphan;
857+
rinfo[val].sg_io_owned = srp->sg_io_owned;
858+
rinfo[val].pack_id = srp->header.pack_id;
859+
rinfo[val].usr_ptr = srp->header.usr_ptr;
860+
val++;
861+
}
862+
}
863+
831864
static long
832865
sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
833866
{
@@ -1012,38 +1045,13 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
10121045
return -EFAULT;
10131046
else {
10141047
sg_req_info_t *rinfo;
1015-
unsigned int ms;
10161048

1017-
rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
1018-
GFP_KERNEL);
1049+
rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
1050+
GFP_KERNEL);
10191051
if (!rinfo)
10201052
return -ENOMEM;
10211053
read_lock_irqsave(&sfp->rq_list_lock, iflags);
1022-
val = 0;
1023-
list_for_each_entry(srp, &sfp->rq_list, entry) {
1024-
if (val >= SG_MAX_QUEUE)
1025-
break;
1026-
memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
1027-
rinfo[val].req_state = srp->done + 1;
1028-
rinfo[val].problem =
1029-
srp->header.masked_status &
1030-
srp->header.host_status &
1031-
srp->header.driver_status;
1032-
if (srp->done)
1033-
rinfo[val].duration =
1034-
srp->header.duration;
1035-
else {
1036-
ms = jiffies_to_msecs(jiffies);
1037-
rinfo[val].duration =
1038-
(ms > srp->header.duration) ?
1039-
(ms - srp->header.duration) : 0;
1040-
}
1041-
rinfo[val].orphan = srp->orphan;
1042-
rinfo[val].sg_io_owned = srp->sg_io_owned;
1043-
rinfo[val].pack_id = srp->header.pack_id;
1044-
rinfo[val].usr_ptr = srp->header.usr_ptr;
1045-
val++;
1046-
}
1054+
sg_fill_request_table(sfp, rinfo);
10471055
read_unlock_irqrestore(&sfp->rq_list_lock, iflags);
10481056
result = __copy_to_user(p, rinfo,
10491057
SZ_SG_REQ_INFO * SG_MAX_QUEUE);

0 commit comments

Comments
 (0)