SCSI fixes for 7.4-rc3+
Subsystems (8)
James Bottomley
maintainerThe following changes since commit ca14cc05808f9c0115c38bec53573bf93e030435:
Merge branch '7.4/scsi-queue' into 7.4/scsi-fixes (2026-11-02 21:06:42 -0500)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git/ tags/scsi-fixes
for you to fetch changes up to e550f2b2b4aab4c5f12db89d04d8978ce4ed7b4e:
scsi: mpi3mr: Validate reply frame size bounds (2026-11-08 22:36:12 -0500)
----------------------------------------------------------------
Mostly driver fixes. The only core one is the bsg one to prevent copying of sense data after the task is cancelled (which could result in random memory writes from the kernel). ufs has the largest set of fixes, but they're also fairly mundane.
I was supposed to be sending this on Saturday, but managed to spend the weekend rushing around airports instead thanks to the FAA problem on returning from KVM forum.
----------------------------------------------------------------
Boyan Liu (1):
scsi: sd_zbc: Cap zone report count by buffer size
Ciro Iriarte (1):
scsi: target: core: Parse APTPL res_type and res_scope as hex
Dmitry Bogdanov (2):
scsi: Revert "scsi: target: iscsi: Fix hang for aborted WRITE_PENDING commands"
scsi: target: iscsi: Fix hanging WRITE_PENDING commands
Dongdong Hao (1):
scsi: leapraid: Fix init_cmd_priv error handling
James Houghton (1):
scsi: bsg: Don't copy sense data to user memory when canceled
Joonhoe Kim (1):
scsi: ufs: qcom: Reprogram ESI after a host controller reset
Kiwoong Kim (2):
scsi: ufs: core: Skip ABORT TASK for device management commands
scsi: ufs: mcq: Poll OCS after sq cleanup for device management commands
Milan P. Gandhi (1):
scsi: mpi3mr: Validate reply frame size bounds
Praneeth Balasubramanian (1):
scsi: target: iscsi: Check for existing sessions only after authentication
Shao Mingyin (3):
scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store()
scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition()
scsi: rdac: Keep the error status when controller lookup fails
Shawn Lin (1):
scsi: ufs: rockchip: Improve RX noise immunity
Stanley Jhu (6):
scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume
scsi: ufs: core: Restore jiffies conversion of device management timeouts
scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper
scsi: ufs: sysfs: Propagate runtime PM resume errors
scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails
scsi: ufs: hwmon, debugfs: Propagate runtime PM resume errors
drivers/scsi/device_handler/scsi_dh_rdac.c | 6 +-- drivers/scsi/leapraid/leapraid_os.c | 10 +---- drivers/scsi/mpi3mr/mpi3mr.h | 1 + drivers/scsi/mpi3mr/mpi3mr_fw.c | 18 ++++++++ drivers/scsi/scsi_bsg.c | 10 ++++- drivers/scsi/sd_zbc.c | 9 +++- drivers/target/iscsi/iscsi_target.c | 19 --------- drivers/target/iscsi/iscsi_target_erl1.c | 8 ---- drivers/target/iscsi/iscsi_target_nego.c | 6 +-- drivers/target/target_core_alua.c | 7 ++++ drivers/target/target_core_configfs.c | 16 +++++-- drivers/ufs/core/ufs-debugfs.c | 8 +++- drivers/ufs/core/ufs-hwmon.c | 12 +++++- drivers/ufs/core/ufs-mcq.c | 34 +++++++++++++++ drivers/ufs/core/ufs-sysfs.c | 67 +++++++++++++++++++++++------- drivers/ufs/core/ufs_bsg.c | 4 +- drivers/ufs/core/ufshcd-priv.h | 5 +++ drivers/ufs/core/ufshcd.c | 42 ++++++++++++------- drivers/ufs/host/ufs-qcom.c | 12 ++++-- drivers/ufs/host/ufs-qcom.h | 2 + drivers/ufs/host/ufs-rockchip.c | 1 + include/scsi/scsi_proto.h | 3 ++ 22 files changed, 217 insertions(+), 83 deletions(-)
With full diff below
Regards,
James
---
drivers/scsi/device_handler/scsi_dh_rdac.c +3 -3
@@ -450,14 +450,14 @@ static int initialize_controller(struct scsi_device *sdev,spin_lock (&list_lock); h->ctlr =get_controller (index, array_name, array_id, sdev); -if (!h->ctlr) +if (!h->ctlr) { err =SCSI_DH_RES_TEMP_UNAVAIL ; -else { + }else { h->sdev = sdev;list_add_rcu (&h->node, &h->ctlr->dh_list); + err =SCSI_DH_OK ; }spin_unlock (&list_lock); - err =SCSI_DH_OK ; }return err; }
drivers/scsi/leapraid/leapraid_os.c +2 -8
@@ -935,22 +935,16 @@ static int leapraid_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *scmd) {struct leapraid_adapter *adapter =shost_priv (shost); -struct leapraid_io_req_tracker *io_tracker; - io_tracker =scsi_cmd_priv (scmd); -leapraid_internal_init_cmd_priv (adapter, io_tracker); - -return 0 ; +return leapraid_internal_init_cmd_priv (adapter,scsi_cmd_priv (scmd)); }static int leapraid_exit_cmd_priv (struct Scsi_Host *shost,struct scsi_cmnd *scmd) {struct leapraid_adapter *adapter =shost_priv (shost); -struct leapraid_io_req_tracker *io_tracker; - io_tracker =scsi_cmd_priv (scmd); -leapraid_internal_exit_cmd_priv (adapter, io_tracker); +leapraid_internal_exit_cmd_priv (adapter,scsi_cmd_priv (scmd));return 0 ; }
drivers/scsi/mpi3mr/mpi3mr.h +1 -0
@@ -83,6 +83,7 @@ extern atomic64_t event_counter;#define MPI3MR_ADMIN_REPLY_Q_SIZE (8 * MPI3MR_PAGE_SIZE_4K)#define MPI3MR_ADMIN_REQ_FRAME_SZ 128#define MPI3MR_ADMIN_REPLY_FRAME_SZ 16 +#define MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS 16/* 64 bytes */ /* Operational queue management definitions */ #define MPI3MR_OP_REQ_Q_QD 512
drivers/scsi/mpi3mr/mpi3mr_fw.c +18 -0
@@ -3261,6 +3261,7 @@ static int mpi3mr_issue_iocfacts(struct mpi3mr_ioc *mrioc, struct mpi3_ioc_facts_data *facts_data) {struct mpi3_ioc_facts_request iocfacts_req; +u16 reply_frame_size;void *data =NULL ;dma_addr_t data_dma;u32 data_len =sizeof (*facts_data);
@@ -3318,6 +3319,23 @@ static int mpi3mr_issue_iocfacts(struct mpi3mr_ioc *mrioc, goto out_unlock; }memcpy (facts_data, (u8 *)data, data_len); + + reply_frame_size =le16_to_cpu (facts_data->reply_frame_size); +/* +* Validate reply_frame_size: +* - Must be at least 16 dwords (64 bytes) to accommodate fixed reply +* structures and avoid underflow/divide-by-zero in logdata sizing. +* - Must not exceed U16_MAX / 4 to prevent integer overflow. +*/ +if (reply_frame_size <MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS || + reply_frame_size > (U16_MAX /4 )) { +ioc_err (mrioc,"Invalid reply_frame_size %u (must be %u..%u dwords)\n" , + reply_frame_size,MPI3MR_MIN_REPLY_FRAME_SZ_DWORDS , + (unsigned int )(U16_MAX /4 )); + retval = -EINVAL ; + goto out_unlock; + } +mpi3mr_process_factsdata (mrioc, facts_data); out_unlock: mrioc->init_cmds.state =MPI3MR_CMD_NOTUSED ;
drivers/scsi/scsi_bsg.c +9 -1
@@ -43,9 +43,17 @@ static void scsi_bsg_uring_task_cb(struct io_tw_req tw_req, io_tw_token_t tw)if (pdu->bio) ret =blk_rq_unmap_user (pdu->bio); +/* +* If the request is being canceled, e.g. because the submitting task +* has exited, this may run from a kworker or in a different task, so +* don't copy the sense data to the submitter's address. +*/ +if (unlikely (tw.cancel)) + ret = -ECANCELED ; +if (scsi_status_is_check_condition (scmd->result)) { driver_status =DRIVER_SENSE ; -if (pdu->response_addr) +if (pdu->response_addr && !tw.cancel) sense_len_wr = min_t(unsigned int, pdu->max_response_len, scmd->sense_len); }
drivers/scsi/sd_zbc.c +7 -2
@@ -222,7 +222,7 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector, {struct scsi_disk *sdkp =scsi_disk (disk);sector_t lba =sectors_to_logical (sdkp->device, sector); -unsigned int nr, i; +unsigned int nr, i, max_in_buf;unsigned char *buf;u64 zone_length, start_lba;size_t offset, buflen =0 ;
@@ -241,13 +241,18 @@ int sd_zbc_report_zones(struct gendisk *disk, sector_t sector,if (!buf)return -ENOMEM ; + max_in_buf = (buflen -ZBC_REPORT_ZONES_HEADER_SIZE ) / +ZBC_ZONE_DESCRIPTOR_SIZE ; +while (zone_idx < nr_zones && lba < sdkp->capacity) { ret =sd_zbc_do_report_zones (sdkp, buf, buflen, lba, true);if (ret) goto out; offset =0 ; - nr =min (nr_zones,get_unaligned_be32 (&buf[0 ]) /64 ); + nr =min3 (nr_zones - zone_idx, +get_unaligned_be32 (&buf[0 ]) /ZBC_ZONE_DESCRIPTOR_SIZE , + max_in_buf);if (!nr)break ;
drivers/target/iscsi/iscsi_target.c +0 -19
@@ -1518,25 +1518,6 @@ __iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf,if (hdr->flags &ISCSI_FLAG_CMD_FINAL )iscsit_stop_dataout_timer (cmd); -return iscsit_dump_data_payload (conn, payload_length,1 ); - } - }else { -/* -* For the normal solicited data path: -* -* Check for a delayed TASK_ABORTED status and dump any -* incoming data out payload if one exists. Also, when the -* ISCSI_FLAG_CMD_FINAL is set to denote the end of the current -* data out sequence, we decrement outstanding_r2ts. Once -* outstanding_r2ts reaches zero, go ahead and send the delayed -* TASK_ABORTED status. -*/ -if (se_cmd->transport_state &CMD_T_ABORTED ) { -if (hdr->flags &ISCSI_FLAG_CMD_FINAL && - --cmd->outstanding_r2ts <1 ) { -iscsit_stop_dataout_timer (cmd); -target_complete_cmd (se_cmd,SAM_STAT_TASK_ABORTED ); - }return iscsit_dump_data_payload (conn, payload_length,1 ); }
drivers/target/iscsi/iscsi_target_erl1.c +0 -8
@@ -908,8 +908,6 @@ int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo)return 0 ; }spin_unlock_bh (&cmd->istate_lock); -if (cmd->se_cmd.transport_state &CMD_T_ABORTED ) -return 0 ;return transport_send_check_condition_and_sense (se_cmd, cmd->sense_reason,0 ); }
@@ -927,9 +925,6 @@ int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo)if (!(cmd->cmd_flags &ICF_NON_IMMEDIATE_UNSOLICITED_DATA )) { -if (cmd->se_cmd.transport_state &CMD_T_ABORTED ) -return 0 ; -iscsit_set_dataout_sequence_values (cmd); conn->conn_transport->iscsit_get_dataout (conn, cmd, false); }
@@ -942,9 +937,6 @@ int iscsit_execute_cmd(struct iscsit_cmd *cmd, int ooo)if ((cmd->data_direction ==DMA_TO_DEVICE ) && !(cmd->cmd_flags &ICF_NON_IMMEDIATE_UNSOLICITED_DATA )) { -if (cmd->se_cmd.transport_state &CMD_T_ABORTED ) -return 0 ; -iscsit_set_unsolicited_dataout (cmd); }return target_submit (&cmd->se_cmd);
drivers/target/iscsi/iscsi_target_nego.c +3 -3
@@ -982,9 +982,6 @@ static int iscsi_target_handle_csg_one(struct iscsit_conn *conn, struct iscsi_loif (iscsi_target_check_first_request (conn, login) <0 )return -1 ; -if (iscsi_target_check_for_existing_instances (conn, login) <0 ) -return -1 ; - ret = iscsi_encode_text_output( PHASE_OPERATIONAL|PHASE_DECLARATIVE, SENDER_TARGET,
@@ -1008,6 +1005,9 @@ static int iscsi_target_handle_csg_one(struct iscsit_conn *conn, struct iscsi_loreturn -1 ; } +if (iscsi_target_check_for_existing_instances (conn, login) <0 ) +return -1 ; +if (!iscsi_check_negotiated_keys (conn->param_list))if ((login_req->flags &ISCSI_FLAG_LOGIN_NEXT_STAGE3 ) && (login_req->flags &ISCSI_FLAG_LOGIN_TRANSIT ))
drivers/target/target_core_alua.c +7 -0
@@ -1081,8 +1081,15 @@ int core_alua_do_port_transition(return -EINVAL ; local_lu_gp_mem = l_dev->dev_alua_lu_gp_mem; +if (!local_lu_gp_mem) +return -ENODEV ; +spin_lock (&local_lu_gp_mem->lu_gp_mem_lock); lu_gp = local_lu_gp_mem->lu_gp; +if (!lu_gp) { +spin_unlock (&local_lu_gp_mem->lu_gp_mem_lock); +return -ENODEV ; + }atomic_inc (&lu_gp->lu_gp_ref_cnt);spin_unlock (&local_lu_gp_mem->lu_gp_mem_lock);/*
drivers/target/target_core_configfs.c +12 -4
@@ -2126,8 +2126,8 @@ static match_table_t tokens = { {Opt_initiator_sid, "initiator_sid=%s"}, {Opt_sa_res_key, "sa_res_key=%s"}, {Opt_res_holder, "res_holder=%d"}, - {Opt_res_type, "res_type=%d"}, - {Opt_res_scope, "res_scope=%d"}, + {Opt_res_type, "res_type=%x"}, + {Opt_res_scope, "res_scope=%x"}, {Opt_res_all_tg_pt, "res_all_tg_pt=%d"}, {Opt_mapped_lun, "mapped_lun=%u"}, {Opt_target_fabric, "target_fabric=%s"},
@@ -2229,13 +2229,13 @@ static ssize_t target_pr_res_aptpl_metadata_store(struct config_item *item, res_holder = arg;break ;case Opt_res_type: - ret =match_int (args, &arg); + ret =match_hex (args, &arg);if (ret) goto out; type = (u8 )arg;break ;case Opt_res_scope: - ret =match_int (args, &arg); + ret =match_hex (args, &arg);if (ret) goto out;break ;
@@ -2547,6 +2547,14 @@ static ssize_t target_dev_alua_lu_gp_store(struct config_item *item,spin_lock (&lu_gp_mem->lu_gp_mem_lock); lu_gp = lu_gp_mem->lu_gp; +if (!lu_gp && !lu_gp_new) { +/* +* The LU group association has already been cleared, so +* there is nothing left to do. +*/ +spin_unlock (&lu_gp_mem->lu_gp_mem_lock); +return count; + }if (lu_gp) {/* * Clearing an existing lu_gp association, and replacing
drivers/ufs/core/ufs-debugfs.c +7 -1
@@ -70,12 +70,18 @@ token_context_lock(ufs_debugfs);static int ufs_debugfs_get_user_access (struct ufs_hba *hba)__cond_acquires (0 , ufs_debugfs) { +int err; +down (&hba->host_sem);if (!ufshcd_is_user_access_allowed (hba)) {up (&hba->host_sem);return -EBUSY ; } -ufshcd_rpm_get_sync (hba); + err =ufshcd_rpm_resume_and_get (hba); +if (err) { +up (&hba->host_sem); +return err; + }__acquire (ufs_debugfs);return 0 ; }
drivers/ufs/core/ufs-hwmon.c +10 -2
@@ -61,7 +61,11 @@ static int ufs_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32return -EBUSY ; } -ufshcd_rpm_get_sync (hba); + err =ufshcd_rpm_resume_and_get (hba); +if (err) { +up (&hba->host_sem); +return err; + }switch (attr) {case hwmon_temp_enable:
@@ -113,7 +117,11 @@ static int ufs_hwmon_write(struct device *dev, enum hwmon_sensor_types type, u32return -EBUSY ; } -ufshcd_rpm_get_sync (hba); + err =ufshcd_rpm_resume_and_get (hba); +if (err) { +up (&hba->host_sem); +return err; + }if (val ==1 ) err =ufshcd_update_ee_usr_mask (hba,MASK_EE_URGENT_TEMP ,0 );
drivers/ufs/core/ufs-mcq.c +34 -0
@@ -554,6 +554,23 @@ static int ufshcd_mcq_sq_start(struct ufs_hba *hba, struct ufs_hw_queue *hwq)return err; } +/* +* Reap the CQ directly so that progress does not depend on interrupt +* delivery. ufshcd_compl_one_cqe() updates the OCS under cq_lock before +* calling scsi_done(). Holding cq_lock while reading the OCS makes sure that +* the completion has finished once the updated OCS is observed, even if the +* CQE was reaped by the interrupt handler. +*/ +static enum utp_ocs ufshcd_mcq_poll_ocs (struct ufs_hba *hba, +struct ufs_hw_queue *hwq, +struct ufshcd_lrb *lrbp) +{ +ufshcd_mcq_poll_cqe_lock (hba, hwq); + +guard (spinlock_irqsave)(&hwq->cq_lock); +return lrbp->utr_descriptor_ptr->header.ocs; +} +/** * ufshcd_mcq_sq_cleanup - Clean up submission queue resources * associated with the pending command.
@@ -613,6 +630,23 @@ int ufshcd_mcq_sq_cleanup(struct ufs_hba *hba, int task_tag) __func__, id, FIELD_GET(SQ_ICU_ERR_CODE_MASK, readl(reg))); +/* +* For device management commands, there is no order guaranteed between +* OCS update and CUS update, which is why we need to wait here. SCSI +* commands are excluded because the OCS in their UTRD is not updated +* from the CQE. +*/ +if (!err &&blk_mq_is_reserved_rq (rq)) { +enum utp_ocs ocs; + + err =read_poll_timeout (ufshcd_mcq_poll_ocs, ocs, + ocs !=OCS_INVALID_COMMAND_STATUS ,20 , +MCQ_POLL_US , false, hba, hwq, lrbp); +if (err) +dev_err (hba->dev,"%s: OCS not updated. hwq=%d, tag=%d err=%d\n" , + __func__, id, task_tag, err); + } +if (ufshcd_mcq_sq_start (hba, hwq)) err = -ETIMEDOUT ;
drivers/ufs/core/ufs-sysfs.c +53 -14
157 lines not on this page · raw message
drivers/ufs/core/ufs_bsg.c +3 -1
@@ -150,7 +150,9 @@ static int ufs_bsg_request(struct bsg_job *job) goto out_complete; } -ufshcd_rpm_get_sync (hba); + ret =ufshcd_rpm_resume_and_get (hba); +if (ret) + goto out_complete; msgcode = bsg_request->msgcode;switch (msgcode) {
drivers/ufs/core/ufshcd-priv.h +5 -0
@@ -388,6 +388,11 @@ static inline int ufshcd_rpm_get_sync(struct ufs_hba *hba)return pm_runtime_get_sync (&hba->ufs_device_wlun->sdev_gendev); } +static inline int ufshcd_rpm_resume_and_get (struct ufs_hba *hba) +{ +return pm_runtime_resume_and_get (&hba->ufs_device_wlun->sdev_gendev); +} +static inline int ufshcd_rpm_get_if_active (struct ufs_hba *hba) {return pm_runtime_get_if_active (&hba->ufs_device_wlun->sdev_gendev);
drivers/ufs/core/ufshcd.c +28 -14
90 lines not on this page · raw message
drivers/ufs/host/ufs-qcom.c +9 -3
@@ -2413,7 +2413,9 @@ static void ufs_qcom_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) {struct device *dev =msi_desc_to_dev (desc);struct ufs_hba *hba =dev_get_drvdata (dev); +struct ufs_qcom_host *host =ufshcd_get_variant (hba); + host->esi_msg = *msg;ufshcd_mcq_config_esi (hba, msg); }
@@ -2441,8 +2443,10 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba)struct ufs_qcom_irq *qi;int nr_irqs, ret; -if (host->esi_enabled) -return 0 ; +if (host->esi_enabled) { +ufshcd_mcq_config_esi (hba, &host->esi_msg); + goto enable; + }/* * 1. We only handle CQs as of now.
@@ -2480,12 +2484,14 @@ static int ufs_qcom_config_esi(struct ufs_hba *hba) } } + host->esi_enabled = true; + +enable:if (host->hw_ver.major >=6 ) {ufshcd_rmwl (hba,ESI_VEC_MASK ,FIELD_PREP (ESI_VEC_MASK ,MAX_ESI_VEC -1 ),REG_UFS_CFG3 ); }ufshcd_mcq_enable_esi (hba); - host->esi_enabled = true;return 0 ; }
drivers/ufs/host/ufs-qcom.h +2 -0
@@ -5,6 +5,7 @@#ifndef UFS_QCOM_H_ #define UFS_QCOM_H_ +#include <linux/msi.h> #include <linux/reset-controller.h> #include <linux/reset.h> #include <soc/qcom/ice.h>
@@ -360,6 +361,7 @@ struct ufs_qcom_host {u32 phy_gear;bool esi_enabled; +struct msi_msg esi_msg;u32 saved_tx_eq_g1_setting;u32 boot_spare_cfg;
drivers/ufs/host/ufs-rockchip.c +1 -0
@@ -82,6 +82,7 @@ static int ufs_rockchip_rk3576_phy_init(struct ufs_hba *hba)ufshcd_dme_set (hba,UIC_ARG_MIB_SEL (VND_RX_LINERESET_PVALUE2 ,SEL_RX_LANE0 + i),0x02 );ufshcd_dme_set (hba,UIC_ARG_MIB_SEL (VND_RX_LINERESET_OPTION ,SEL_RX_LANE0 + i),0xf6 );ufshcd_dme_set (hba,UIC_ARG_MIB_SEL (VND_RX_POWER_SAVING_CTRL ,SEL_RX_LANE0 + i),0x69 ); +ufshcd_dme_set (hba,UIC_ARG_MIB_SEL (VND_RX_SAVE_DET_CTRL ,SEL_RX_LANE0 + i),0x18 ); }/* disable the mphy DME_SET cfg */
include/scsi/scsi_proto.h +3 -0
@@ -371,6 +371,9 @@ enum zbc_zone_reporting_options {#define ZBC_REPORT_ZONE_PARTIAL 0x80 +#define ZBC_REPORT_ZONES_HEADER_SIZE 64 +#define ZBC_ZONE_DESCRIPTOR_SIZE 64 +/* Zone types of REPORT ZONES zone descriptors */ enum zbc_zone_type {ZBC_ZONE_TYPE_CONV =0x1 ,
The pull request you sent on Wed, 18 Nov 2026 12:03:37 -0500:
The pull request you sent on Wed, 18 Nov 2026 12:03:37 -0500:
Quoted 1 line
https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git/ tags/scsi-fixes
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/27e694b84eca6c7fa0878662764567a3cc396fc2
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html