Skip to content

Commit ab4319f

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: "The most important fix is the sg one because the regression it fixes (spurious warning and use after final put) is already backported to stable. The next biggest impact is the target fix for wrong credentials used to load a module because it's affecting new kernels installed on selinux based distributions. The other three fixes are an obvious off by one and SATA protocol issues" * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: qla2xxx: Fix off by one in qla_edif_app_getstats() scsi: hisi_sas: Modify the deadline for ata_wait_after_reset() scsi: hisi_sas: Handle the NCQ error returned by D2H frame scsi: target: Fix SELinux error when systemd-modules loads the target module scsi: sg: Avoid race in error handling & drop bogus warn
2 parents 5de6b46 + 4406e41 commit ab4319f

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

drivers/scsi/hisi_sas/hisi_sas_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ static int hisi_sas_debug_I_T_nexus_reset(struct domain_device *device)
17971797
if (dev_is_sata(device)) {
17981798
struct ata_link *link = &device->sata_dev.ap->link;
17991799

1800-
rc = ata_wait_after_reset(link, HISI_SAS_WAIT_PHYUP_TIMEOUT,
1800+
rc = ata_wait_after_reset(link, jiffies + HISI_SAS_WAIT_PHYUP_TIMEOUT,
18011801
smp_ata_check_ready_type);
18021802
} else {
18031803
msleep(2000);

drivers/scsi/hisi_sas/hisi_sas_v3_hw.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,15 @@ slot_err_v3_hw(struct hisi_hba *hisi_hba, struct sas_task *task,
22442244
case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP:
22452245
if ((dw0 & CMPLT_HDR_RSPNS_XFRD_MSK) &&
22462246
(sipc_rx_err_type & RX_FIS_STATUS_ERR_MSK)) {
2247-
ts->stat = SAS_PROTO_RESPONSE;
2247+
if (task->ata_task.use_ncq) {
2248+
struct domain_device *device = task->dev;
2249+
struct hisi_sas_device *sas_dev = device->lldd_dev;
2250+
2251+
sas_dev->dev_status = HISI_SAS_DEV_NCQ_ERR;
2252+
slot->abort = 1;
2253+
} else {
2254+
ts->stat = SAS_PROTO_RESPONSE;
2255+
}
22482256
} else if (dma_rx_err_type & RX_DATA_LEN_UNDERFLOW_MSK) {
22492257
ts->residual = trans_tx_fail_type;
22502258
ts->stat = SAS_DATA_UNDERRUN;

drivers/scsi/qla2xxx/qla_edif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ qla_edif_app_getstats(scsi_qla_host_t *vha, struct bsg_job *bsg_job)
11001100

11011101
list_for_each_entry_safe(fcport, tf, &vha->vp_fcports, list) {
11021102
if (fcport->edif.enable) {
1103-
if (pcnt > app_req.num_ports)
1103+
if (pcnt >= app_req.num_ports)
11041104
break;
11051105

11061106
app_reply->elem[pcnt].rekey_count =

drivers/scsi/sg.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ sg_open(struct inode *inode, struct file *filp)
285285
int dev = iminor(inode);
286286
int flags = filp->f_flags;
287287
struct request_queue *q;
288+
struct scsi_device *device;
288289
Sg_device *sdp;
289290
Sg_fd *sfp;
290291
int retval;
@@ -301,19 +302,20 @@ sg_open(struct inode *inode, struct file *filp)
301302

302303
/* This driver's module count bumped by fops_get in <linux/fs.h> */
303304
/* Prevent the device driver from vanishing while we sleep */
304-
retval = scsi_device_get(sdp->device);
305+
device = sdp->device;
306+
retval = scsi_device_get(device);
305307
if (retval)
306308
goto sg_put;
307309

308-
retval = scsi_autopm_get_device(sdp->device);
310+
retval = scsi_autopm_get_device(device);
309311
if (retval)
310312
goto sdp_put;
311313

312314
/* scsi_block_when_processing_errors() may block so bypass
313315
* check if O_NONBLOCK. Permits SCSI commands to be issued
314316
* during error recovery. Tread carefully. */
315317
if (!((flags & O_NONBLOCK) ||
316-
scsi_block_when_processing_errors(sdp->device))) {
318+
scsi_block_when_processing_errors(device))) {
317319
retval = -ENXIO;
318320
/* we are in error recovery for this device */
319321
goto error_out;
@@ -344,7 +346,7 @@ sg_open(struct inode *inode, struct file *filp)
344346

345347
if (sdp->open_cnt < 1) { /* no existing opens */
346348
sdp->sgdebug = 0;
347-
q = sdp->device->request_queue;
349+
q = device->request_queue;
348350
sdp->sg_tablesize = queue_max_segments(q);
349351
}
350352
sfp = sg_add_sfp(sdp);
@@ -370,10 +372,11 @@ sg_open(struct inode *inode, struct file *filp)
370372
error_mutex_locked:
371373
mutex_unlock(&sdp->open_rel_lock);
372374
error_out:
373-
scsi_autopm_put_device(sdp->device);
375+
scsi_autopm_put_device(device);
374376
sdp_put:
375-
scsi_device_put(sdp->device);
376-
goto sg_put;
377+
kref_put(&sdp->d_ref, sg_device_destroy);
378+
scsi_device_put(device);
379+
return retval;
377380
}
378381

379382
/* Release resources associated with a successful sg_open()
@@ -2233,7 +2236,6 @@ sg_remove_sfp_usercontext(struct work_struct *work)
22332236
"sg_remove_sfp: sfp=0x%p\n", sfp));
22342237
kfree(sfp);
22352238

2236-
WARN_ON_ONCE(kref_read(&sdp->d_ref) != 1);
22372239
kref_put(&sdp->d_ref, sg_device_destroy);
22382240
scsi_device_put(device);
22392241
module_put(THIS_MODULE);

drivers/target/target_core_configfs.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3672,6 +3672,8 @@ static int __init target_core_init_configfs(void)
36723672
{
36733673
struct configfs_subsystem *subsys = &target_core_fabrics;
36743674
struct t10_alua_lu_gp *lu_gp;
3675+
struct cred *kern_cred;
3676+
const struct cred *old_cred;
36753677
int ret;
36763678

36773679
pr_debug("TARGET_CORE[0]: Loading Generic Kernel Storage"
@@ -3748,11 +3750,21 @@ static int __init target_core_init_configfs(void)
37483750
if (ret < 0)
37493751
goto out;
37503752

3753+
/* We use the kernel credentials to access the target directory */
3754+
kern_cred = prepare_kernel_cred(&init_task);
3755+
if (!kern_cred) {
3756+
ret = -ENOMEM;
3757+
goto out;
3758+
}
3759+
old_cred = override_creds(kern_cred);
37513760
target_init_dbroot();
3761+
revert_creds(old_cred);
3762+
put_cred(kern_cred);
37523763

37533764
return 0;
37543765

37553766
out:
3767+
target_xcopy_release_pt();
37563768
configfs_unregister_subsystem(subsys);
37573769
core_dev_release_virtual_lun0();
37583770
rd_module_exit();

0 commit comments

Comments
 (0)