Skip to content

Commit 2a6edd8

Browse files
committed
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "Fixes only in drivers (ufs, mvsas, qla2xxx, target) that came in just before or during the merge window. The most important one is the qla2xxx which reverts a conversion to fix flexible array member warnings, that went up in this merge window but which turned out on further testing to be causing data corruption" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: ufs: core: Include UTP error in INT_FATAL_ERRORS scsi: ufs: sysfs: Make HID attributes visible scsi: mvsas: Fix use-after-free bugs in mvs_work_queue scsi: ufs: core: Fix PM QoS mutex initialization scsi: ufs: core: Fix runtime suspend error deadlock Revert "scsi: qla2xxx: Fix memcpy() field-spanning write issue" scsi: target: target_core_configfs: Add length check to avoid buffer overflow
2 parents 9591fdb + 558ae45 commit 2a6edd8

File tree

10 files changed

+36
-25
lines changed

10 files changed

+36
-25
lines changed

drivers/scsi/mvsas/mv_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static void mvs_free(struct mvs_info *mvi)
124124
if (mvi->shost)
125125
scsi_host_put(mvi->shost);
126126
list_for_each_entry(mwq, &mvi->wq_list, entry)
127-
cancel_delayed_work(&mwq->work_q);
127+
cancel_delayed_work_sync(&mwq->work_q);
128128
kfree(mvi->rsvd_tags);
129129
kfree(mvi);
130130
}

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4890,7 +4890,9 @@ struct purex_item {
48904890
struct purex_item *pkt);
48914891
atomic_t in_use;
48924892
uint16_t size;
4893-
uint8_t iocb[] __counted_by(size);
4893+
struct {
4894+
uint8_t iocb[64];
4895+
} iocb;
48944896
};
48954897

48964898
#include "qla_edif.h"
@@ -5099,6 +5101,7 @@ typedef struct scsi_qla_host {
50995101
struct list_head head;
51005102
spinlock_t lock;
51015103
} purex_list;
5104+
struct purex_item default_item;
51025105

51035106
struct name_list_extended gnl;
51045107
/* Count of active session/fcport */
@@ -5127,11 +5130,6 @@ typedef struct scsi_qla_host {
51275130
#define DPORT_DIAG_IN_PROGRESS BIT_0
51285131
#define DPORT_DIAG_CHIP_RESET_IN_PROGRESS BIT_1
51295132
uint16_t dport_status;
5130-
5131-
/* Must be last --ends in a flexible-array member. */
5132-
TRAILING_OVERLAP(struct purex_item, default_item, iocb,
5133-
uint8_t __default_item_iocb[QLA_DEFAULT_PAYLOAD_SIZE];
5134-
);
51355133
} scsi_qla_host_t;
51365134

51375135
struct qla27xx_image_status {

drivers/scsi/qla2xxx/qla_isr.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,17 +1077,17 @@ static struct purex_item *
10771077
qla24xx_alloc_purex_item(scsi_qla_host_t *vha, uint16_t size)
10781078
{
10791079
struct purex_item *item = NULL;
1080+
uint8_t item_hdr_size = sizeof(*item);
10801081

10811082
if (size > QLA_DEFAULT_PAYLOAD_SIZE) {
1082-
item = kzalloc(struct_size(item, iocb, size), GFP_ATOMIC);
1083+
item = kzalloc(item_hdr_size +
1084+
(size - QLA_DEFAULT_PAYLOAD_SIZE), GFP_ATOMIC);
10831085
} else {
10841086
if (atomic_inc_return(&vha->default_item.in_use) == 1) {
10851087
item = &vha->default_item;
10861088
goto initialize_purex_header;
10871089
} else {
1088-
item = kzalloc(
1089-
struct_size(item, iocb, QLA_DEFAULT_PAYLOAD_SIZE),
1090-
GFP_ATOMIC);
1090+
item = kzalloc(item_hdr_size, GFP_ATOMIC);
10911091
}
10921092
}
10931093
if (!item) {
@@ -1127,16 +1127,17 @@ qla24xx_queue_purex_item(scsi_qla_host_t *vha, struct purex_item *pkt,
11271127
* @vha: SCSI driver HA context
11281128
* @pkt: ELS packet
11291129
*/
1130-
static struct purex_item *
1131-
qla24xx_copy_std_pkt(struct scsi_qla_host *vha, void *pkt)
1130+
static struct purex_item
1131+
*qla24xx_copy_std_pkt(struct scsi_qla_host *vha, void *pkt)
11321132
{
11331133
struct purex_item *item;
11341134

1135-
item = qla24xx_alloc_purex_item(vha, QLA_DEFAULT_PAYLOAD_SIZE);
1135+
item = qla24xx_alloc_purex_item(vha,
1136+
QLA_DEFAULT_PAYLOAD_SIZE);
11361137
if (!item)
11371138
return item;
11381139

1139-
memcpy(&item->iocb, pkt, QLA_DEFAULT_PAYLOAD_SIZE);
1140+
memcpy(&item->iocb, pkt, sizeof(item->iocb));
11401141
return item;
11411142
}
11421143

drivers/scsi/qla2xxx/qla_nvme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ void qla2xxx_process_purls_iocb(void **pkt, struct rsp_que **rsp)
13081308

13091309
ql_dbg(ql_dbg_unsol, vha, 0x2121,
13101310
"PURLS OP[%01x] size %d xchg addr 0x%x portid %06x\n",
1311-
item->iocb[3], item->size, uctx->exchange_address,
1311+
item->iocb.iocb[3], item->size, uctx->exchange_address,
13121312
fcport->d_id.b24);
13131313
/* +48 0 1 2 3 4 5 6 7 8 9 A B C D E F
13141314
* ----- -----------------------------------------------

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6459,10 +6459,9 @@ void qla24xx_process_purex_rdp(struct scsi_qla_host *vha,
64596459
void
64606460
qla24xx_free_purex_item(struct purex_item *item)
64616461
{
6462-
if (item == &item->vha->default_item) {
6462+
if (item == &item->vha->default_item)
64636463
memset(&item->vha->default_item, 0, sizeof(struct purex_item));
6464-
memset(&item->vha->__default_item_iocb, 0, QLA_DEFAULT_PAYLOAD_SIZE);
6465-
} else
6464+
else
64666465
kfree(item);
64676466
}
64686467

drivers/target/target_core_configfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2774,7 +2774,7 @@ static ssize_t target_lu_gp_members_show(struct config_item *item, char *page)
27742774
config_item_name(&dev->dev_group.cg_item));
27752775
cur_len++; /* Extra byte for NULL terminator */
27762776

2777-
if ((cur_len + len) > PAGE_SIZE) {
2777+
if ((cur_len + len) > PAGE_SIZE || cur_len > LU_GROUP_NAME_BUF) {
27782778
pr_warn("Ran out of lu_gp_show_attr"
27792779
"_members buffer\n");
27802780
break;

drivers/ufs/core/ufs-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,7 @@ static umode_t ufs_sysfs_hid_is_visible(struct kobject *kobj,
19491949
return hba->dev_info.hid_sup ? attr->mode : 0;
19501950
}
19511951

1952-
static const struct attribute_group ufs_sysfs_hid_group = {
1952+
const struct attribute_group ufs_sysfs_hid_group = {
19531953
.name = "hid",
19541954
.attrs = ufs_sysfs_hid,
19551955
.is_visible = ufs_sysfs_hid_is_visible,

drivers/ufs/core/ufs-sysfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ void ufs_sysfs_remove_nodes(struct device *dev);
1414

1515
extern const struct attribute_group ufs_sysfs_unit_descriptor_group;
1616
extern const struct attribute_group ufs_sysfs_lun_attributes_group;
17+
extern const struct attribute_group ufs_sysfs_hid_group;
1718

1819
#endif

drivers/ufs/core/ufshcd.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6684,6 +6684,14 @@ static void ufshcd_err_handler(struct work_struct *work)
66846684
}
66856685
spin_unlock_irqrestore(hba->host->host_lock, flags);
66866686

6687+
ufshcd_rpm_get_noresume(hba);
6688+
if (hba->pm_op_in_progress) {
6689+
ufshcd_link_recovery(hba);
6690+
ufshcd_rpm_put(hba);
6691+
return;
6692+
}
6693+
ufshcd_rpm_put(hba);
6694+
66876695
ufshcd_err_handling_prepare(hba);
66886696

66896697
spin_lock_irqsave(hba->host->host_lock, flags);
@@ -8489,6 +8497,8 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
84898497
DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP) &
84908498
UFS_DEV_HID_SUPPORT;
84918499

8500+
sysfs_update_group(&hba->dev->kobj, &ufs_sysfs_hid_group);
8501+
84928502
model_index = desc_buf[DEVICE_DESC_PARAM_PRDCT_NAME];
84938503

84948504
err = ufshcd_read_string_desc(hba, model_index,
@@ -10677,6 +10687,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1067710687
*/
1067810688
spin_lock_init(&hba->clk_gating.lock);
1067910689

10690+
/* Initialize mutex for PM QoS request synchronization */
10691+
mutex_init(&hba->pm_qos_mutex);
10692+
1068010693
/*
1068110694
* Set the default power management level for runtime and system PM.
1068210695
* Host controller drivers can override them in their
@@ -10765,9 +10778,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1076510778

1076610779
mutex_init(&hba->wb_mutex);
1076710780

10768-
/* Initialize mutex for PM QoS request synchronization */
10769-
mutex_init(&hba->pm_qos_mutex);
10770-
1077110781
init_rwsem(&hba->clk_scaling_lock);
1077210782

1077310783
ufshcd_init_clk_gating(hba);

include/ufs/ufshci.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ static inline u32 ufshci_version(u32 major, u32 minor)
180180
#define UTP_TASK_REQ_COMPL 0x200
181181
#define UIC_COMMAND_COMPL 0x400
182182
#define DEVICE_FATAL_ERROR 0x800
183+
#define UTP_ERROR 0x1000
183184
#define CONTROLLER_FATAL_ERROR 0x10000
184185
#define SYSTEM_BUS_FATAL_ERROR 0x20000
185186
#define CRYPTO_ENGINE_FATAL_ERROR 0x40000
@@ -199,7 +200,8 @@ static inline u32 ufshci_version(u32 major, u32 minor)
199200
CONTROLLER_FATAL_ERROR |\
200201
SYSTEM_BUS_FATAL_ERROR |\
201202
CRYPTO_ENGINE_FATAL_ERROR |\
202-
UIC_LINK_LOST)
203+
UIC_LINK_LOST |\
204+
UTP_ERROR)
203205

204206
/* HCS - Host Controller Status 30h */
205207
#define DEVICE_PRESENT 0x1

0 commit comments

Comments
 (0)