commit 9f9e0b1e5399045982788a954d3461de894e40c7 Author: Changyul Lee Date: Mon Nov 9 11:06:51 2026 -0500 scsi: ch: Remove the minor from ch_index_idr after device_destroy() ch_remove() removes the minor from ch_index_idr before device_destroy() removes the "sch" device. A changer probed in between can get the same minor, and its device_create() fails: sysfs: cannot create duplicate filename '/class/scsi_changer/sch0' ... ch 1:0:0:0: ch0: device_create failed The new changer is then not attached. Replace the IDR entry with NULL instead, so that ch_open() still fails with -ENXIO for the changer being removed, and remove the minor after device_destroy(). Fixes: da707c54c342 ("[SCSI] ch: fix device minor number management bug") Signed-off-by: Changyul Lee Reviewed-by: Laurence Oberman Link: https://patch.msgid.link/20261109160651.986356-1-lcy8047@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit dd6ff53a2706628cdd08edb202e36153de22fec9 Author: Laurence Oberman Date: Fri Nov 13 09:50:46 2026 -0500 scsi: mpt3sas: Fix off-by-one in NVMe PRP list transfer size limit Commit 04631f55afc5 ("scsi: mpt3sas: Limit NVMe request size to 2 MiB") capped max_hw_sectors at 2 MiB on the basis that the 4 KiB PRP list buffer holds 512 entries. That does not account for how base_make_prp_nvme() fills the buffer: - PRP1 is placed in the main message frame and covers the first, possibly partial, page of the transfer. - When the list reaches the last 8-byte slot of the page, that slot is used for a chain pointer, so only 511 data PRPs fit. A transfer of length L starting at page offset O needs DIV_ROUND_UP(L - (4096 - O), 4096) list entries. A page aligned 2 MiB transfer needs 511 and fits. A transfer that starts at a non-zero page offset, which O_DIRECT permits with 512 byte logical blocks, can need 512: the chain pointer is written to slot 511 and the next PRP to slot 512, one entry past the end of the per-command PCIe SGL buffer. This is not limited to exactly 2 MiB; under the 2 MiB cap, any transfer of 2 MiB - 3 KiB or more starting at offset 3584 overruns, and likewise for other offsets. This was hit with the 2 MiB cap applied, on a Grace (arm64, SMMUv3 in translated mode) system with a SAS3816 and an NVMe drive, running xfs_repair from fstests on a KASAN kernel: sd 0:2:0:0: [sda] tag#2682 page boundary curr_buff: 0x00000000e986a684 BUG: KASAN: vmalloc-out-of-bounds in _base_build_sg_scmd_ieee+0x115c/0x1508 [mpt3sas] Write of size 8 at addr ffff80008cc8a000 by task xfs_repair/210713 ... The buggy address belongs to a 0-page vmalloc region starting at 0xffff80008cc89000 allocated at dma_common_pages_remap+0x30/0x88 ... Unable to handle kernel paging request at virtual address ffff80008cc8a000 Internal error: Oops: 0000000096000047 [#1] SMP pc : _base_build_sg_scmd_ieee+0x380/0x1508 [mpt3sas] Call trace: _base_build_sg_scmd_ieee+0x380/0x1508 [mpt3sas] (P) scsih_qcmd+0xdc8/0x15c8 [mpt3sas] scsi_dispatch_cmd+0x1f8/0x578 scsi_queue_rq+0x528/0x12f0 ... __blkdev_direct_IO+0x760/0xd40 blkdev_direct_IO+0x338/0x4a0 blkdev_read_iter+0x1e4/0x370 With the IOMMU remapping the coherent pool page, the overrun faults on the guard page. Without that remap it silently corrupts 8 bytes of the adjacent physical page. Limit the transfer to 511 NVMe pages (2 MiB - 4 KiB), which fits the PRP list for any starting offset. With this limit the list never reaches the last slot of the page, so the "page boundary curr_buff" message, which is only printed on the overrun path, can no longer trigger. Fixes: 04631f55afc5 ("scsi: mpt3sas: Limit NVMe request size to 2 MiB") Cc: stable@vger.kernel.org Tested-by: Laurence Oberman Signed-off-by: Laurence Oberman Link: https://patch.msgid.link/20261113145047.623807-1-loberman@redhat.com Signed-off-by: Martin K. Petersen (Oracle) commit a410375a249c4f9e1eb3d7f2c864d3f4ef4b8365 Author: Laurence Oberman Date: Mon Nov 9 15:11:20 2026 -0500 scsi: scsi_dh_alua: Set handler_data before alua_initialize() Since commit 50759b881e1d ("scsi: device_handler: alua: Call scsi_device_put() from non-atomic context"), alua_rtpg_queue() only queues an RTPG when sdev->handler_data points at an alua_dh_data whose port group matches: struct alua_dh_data *h = sdev->handler_data; ... if (h && rcu_dereference(h->pg) == pg) { However alua_bus_attach() only assigns sdev->handler_data after alua_initialize() returns, and alua_initialize() -> alua_check_vpd() is where the initial RTPG is queued. At that point handler_data is still NULL, so the initial RTPG is silently dropped: no RTPG is sent, nothing is logged, and sdev->access_state keeps its zeroed default of active/optimized for every path. With dm-multipath this goes unnoticed, as pg_init calls scsi_dh_activate() once the map is loaded, which queues an RTPG after handler_data is set, and multipathd's alua prioritizer issues its own RTPG from userspace. Anything relying on sdev->access_state without a subsequent activate (sysfs access_state/preferred_path, native SCSI multipath path selection) sees every path as active/optimized until a Unit Attention or rescan triggers an RTPG. Seen on an HP P2000 G3 FC array (implicit ALUA, two port groups, four paths per LUN) with dm-multipath not in use: sg_rtpg reports port group 0 active/non-optimized and port group 1 active/optimized, but /sys/class/scsi_device/H:C:T:L/device/access_state reads active/optimized on all four paths after boot, and no "alua: port group XX state ..." message is logged. Writing "activate" to dh_state sends the RTPG and corrects access_state. Kernels without commit 50759b881e1d queue the attach-time RTPG unconditionally and are not affected. Fix by assigning sdev->handler_data before calling alua_initialize(), and clearing it again on failure. sdev->handler is only set once scsi_dh_handler_attach() sees ->attach() succeed, so no handler callback can observe the partially initialised alua_dh_data. On the failure paths of alua_initialize(), h has not been added to a port group and no RTPG has been queued, so freeing it is unchanged. Fixes: 50759b881e1d ("scsi: device_handler: alua: Call scsi_device_put() from non-atomic context") Cc: stable@vger.kernel.org Signed-off-by: Laurence Oberman Reviewed-by: Martin Wilck Link: https://patch.msgid.link/20261109201120.1067815-1-loberman@redhat.com Signed-off-by: Martin K. Petersen (Oracle) commit 7470a1f2a84d68d177560b78388e640771b6b94a Author: Kyle Mahlkuch Date: Wed Nov 11 11:47:41 2026 -0600 scsi: lpfc: Fix race conditions in ELS retry handling This patch addresses a race condition in the lpfc driver's ELS retry event handling that can lead to a use-after-free in the lpfc_cancel_retry_delay_tmo(), where the NLP_DELAY_TMO flag is cleared before acquiring the lock to check if the retry event is queued. This creates a window where the timer can be rescheduled and fire, causing both the cancel path and the worker thread to release the same reference, resulting in a double-put and use-after-free. Moved capture ndlp and clear evt_arg1 under hbalock while dequeuing LPFC_EVT_ELS_RETRY in lpfc_work_list_done(). Signed-off-by: Kyle Mahlkuch Fixes: e47c9093531d ("[SCSI] lpfc 8.2.5 : Correct ndlp referencing issues") Reviewed-by: Hannes Reinecke Reviewed-by: Paul Ely Link: https://patch.msgid.link/dcea48dd-f76c-4bb0-9275-c12ef9bd78a2@linux.ibm.com Signed-off-by: Martin K. Petersen (Oracle) commit 947d8e9a4d1ea6cc71427e7f701e5c2cf35391c9 Author: Stanley Jhu Date: Wed Nov 11 16:48:53 2026 +0800 scsi: ufs: ufs-pci: Check hba->vops in system PM callbacks ufshcd_pci_tbl[] defines the Samsung 0xC00C and AMD 0x1B29 PCI IDs with .driver_data set to 0, so ufshcd_pci_probe() leaves hba->vops NULL. Both ufshcd_pci_suspend_prepare() and ufshcd_pci_resume_complete() dereference hba->vops->name without checking hba->vops: 1. System suspend on an AMD 0x1B29 or Samsung 0xC00C host enters the PM prepare phase and calls ufshcd_pci_suspend_prepare(). 2. ufshcd_pci_suspend_prepare() evaluates strcmp(hba->vops->name, "intel-pci"), dereferences NULL, and triggers a kernel oops in the suspending task. Check that hba->vops is non-NULL before reading hba->vops->name in both callbacks so hosts without variant operations use the generic ufshcd_suspend_prepare() and ufshcd_resume_complete() paths. Fixes: bb44826c3bdb ("scsi: ufs: ufs-pci: Fix S0ix/S3 for Intel controllers") Cc: stable@vger.kernel.org Signed-off-by: Stanley Jhu Reviewed-by: Adrian Hunter Link: https://patch.msgid.link/20261111084853.3530107-1-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit cbd9818ebed38fd8ddd6af7335d60908aceb93f4 Author: Weidong Wang Date: Sun Nov 8 03:01:08 2026 -0600 scsi: libfc: Fix rport kref leak in fc_rport_enter_ready() fc_rport_enter_ready() takes a reference on the rport unconditionally, but only queues event_work, whose handler drops that reference, when no event is pending. If rdata->event is already set, the && short-circuits past both queue_work() and the compensating kref_put(), so the reference is leaked and the fc_rport_priv is never freed. This is reachable from the wire: a PLOGI from a well-known address goes straight to fc_rport_enter_ready(), and a second PLOGI for the same S_ID while RPORT_EV_READY is still pending enters it again. After the rport is logged out, kmemleak reports: unreferenced object 0xffff888... (size 512): backtrace: __kmalloc_noprof fc_rport_create fc_rport_recv_req fc_lport_recv_els_req fc_lport_recv fcoe_receive_work Commit 823a65409c89 ("scsi: libfc: Skip additional kref updating work event") fixed the same pattern in fc_rport_enter_delete(). Do the same here: only take the reference when no event is pending, i.e. when the work is actually going to be queued. The issue was found with an LLM-based bug-finding tool; the reproducer, fix and changelog were drafted with AI assistance (Claude), then reviewed and tested by the submitter. Fixes: 4d2095cc42a2 ("scsi: libfc: Revisit kref handling") Cc: stable@vger.kernel.org Signed-off-by: Weidong Wang Reviewed-by: Hannes Reinecke Link: https://patch.msgid.link/20261108-h123-send-v1-1-b7672ff849f0@illinois.edu Signed-off-by: Martin K. Petersen (Oracle) commit 040d27029306f59a78c3af32f665693590244043 Author: Niklas Cassel Date: Tue Nov 17 13:29:53 2026 +0100 scsi: scsi_ioctl: Require write access for the depopulation commands scsi_cmd_allowed() lets anybody who can open a SCSI device, even read-only, send any SERVICE ACTION IN(16) command. Besides READ CAPACITY(16) and the other read-only service actions, that opcode also carries the storage element depopulation commands of SBC-4: REMOVE ELEMENT AND TRUNCATE, RESTORE ELEMENTS AND REBUILD and REMOVE ELEMENT AND MODIFY ZONES. These change the capacity of the device, and after REMOVE ELEMENT AND TRUNCATE the data on the device is most likely gone. SCSI devices that support depopulation execute these commands directly, and libata translates them to the equivalent ATA commands, so a user with read-only access to the device node can truncate the device through SG_IO, SCSI_IOCTL_SEND_COMMAND or bsg. Treat these service actions like FORMAT UNIT and ERASE, which also destroy data, and only allow them if the device is opened for writing. The other SERVICE ACTION IN(16) service actions remain allowed for everybody who can open the device. Cc: stable@vger.kernel.org # 2a0adbb80a2f: scsi: define depopulation capabilities related service actions Reviewed-by: Damien Le Moal Signed-off-by: Niklas Cassel Fixes: db496721cb0d ("ata: libata-scsi: add support for the REMOVE ELEMENT AND TRUNCATE command") Fixes: 1e307ca61a9c ("ata: libata-scsi: add support for the RESTORE ELEMENTS AND REBUILD command") Fixes: b448bb42bd10 ("ata: libata-scsi: add support for the REMOVE ELEMENT AND MODIFY ZONES command") Link: https://patch.msgid.link/20261117122952.3451870-2-cassel@kernel.org Signed-off-by: Martin K. Petersen (Oracle) commit b1de2bd5a4d64d190156aa442c5295ce635f9992 Author: Stanley Jhu Date: Thu Nov 12 08:41:12 2026 +0800 scsi: ufs: rpmb: Drop the unregistered ufs_rpmb bus ufs_rpmb_probe() assigns ufs_rpmb_bus_type to dev.bus without ever calling bus_register(). Since commit 36f35b8df697 ("driver core: reject devices with unregistered buses"), device_register() rejects unregistered buses with -EINVAL and UFS RPMB region registration fails. ufs_rpmb_bus_type defines no callbacks and has no drivers, and consumers look up regions through /sys/class/rpmb. Drop ufs_rpmb_bus_type and leave dev.bus unset. Fixes: b06b8c421485 ("scsi: ufs: core: Add OP-TEE based RPMB driver for UFS devices") Cc: stable@vger.kernel.org Reviewed-by: Bean Huo Signed-off-by: Stanley Jhu Tested-by: Alexey Charkov Link: https://patch.msgid.link/20261112004112.3059801-4-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit 7bc9b854cd68ed2d06949540ca18a44368569c64 Author: Stanley Jhu Date: Thu Nov 12 08:41:11 2026 +0800 scsi: ufs: rpmb: Decouple device lifecycle from devres to avoid UAF Region device lifetime in ufs-rpmb fails on host removal in three ways: 1. ufs_rpmb_probe() allocates struct ufs_rpmb_dev with devm_kzalloc() on the host device even though it embeds a reference-counted struct device, so devres frees the memory on host unbind regardless of live references. 2. Probe takes no reference on hba->ufs_rpmb_wlun, so scsi_remove_host() frees the scsi_device while an RPMB request is still in flight. 3. Child rpmb_dev holds a parent reference on ufs_rpmb->dev until rpmb_dev_unregister() runs, which sits inside ufs_rpmb_device_release() and therefore never runs on unbind. Allocate struct ufs_rpmb_dev with kzalloc_obj() and free it in ufs_rpmb_device_release(), hold a get_device() reference on the WLUN across the region lifetime, call rpmb_dev_unregister() explicitly during removal and probe unwind, and reject requests when the WLUN is offline. Fixes: b06b8c421485 ("scsi: ufs: core: Add OP-TEE based RPMB driver for UFS devices") Cc: stable@vger.kernel.org Signed-off-by: Stanley Jhu Link: https://patch.msgid.link/20261112004112.3059801-3-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit e0696bf65006d888c713ff54269c7fd32bbe62a7 Author: Stanley Jhu Date: Thu Nov 12 08:41:10 2026 +0800 scsi: rpmb: core: Guard frame requests and teardown with mutex rpmb_route_frames() invokes the provider callback without serialization, which causes two races: 1. Concurrent callers on the same rpmb_dev interleave multi-frame authenticated sequences on the region's single result register and receive each other's responses without error. 2. rpmb_dev_unregister() calls device_del() and allows the parent provider device to be freed while an in-flight rpmb_route_frames() call still dereferences rdev->dev.parent, causing a use-after-free. Serialize rpmb_route_frames() and rpmb_dev_unregister() with a mutex in struct rpmb_dev and clear descr.route_frames on unregistration so new requests fail with -ENODEV. Also update the stale kerneldoc note advising providers to unregister from their parent release callback, which cannot run while the child rpmb_dev still holds a parent reference. Fixes: 1e9046e3a154 ("rpmb: add Replay Protected Memory Block (RPMB) subsystem") Cc: stable@vger.kernel.org Signed-off-by: Stanley Jhu Tested-by: Alexey Charkov Link: https://patch.msgid.link/20261112004112.3059801-2-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit e550f2b2b4aab4c5f12db89d04d8978ce4ed7b4e Author: Milan P. Gandhi Date: Thu Nov 5 17:54:01 2026 +0530 scsi: mpi3mr: Validate reply frame size bounds Firmware provides reply_frame_size in dwords, which the driver multiplies by 4 to compute facts.reply_sz (u16). If the reported size exceeds U16_MAX / 4, the multiplication overflows u16 before assignment, causing under-allocated DMA reply buffers. Furthermore, several paths assume a minimal reply frame size: - logdata_entry_sz calculations underflow or hit zero when reply_sz <= 20 bytes, leading to zero-size allocations and divide-by-zero crashes. - Unsolicited status descriptors and fixed replies (such as struct mpi3_iounit_control_reply, 64 bytes) require at least 16 dwords. Validate reply_frame_size in mpi3mr_issue_iocfacts() to ensure it is within [16, U16_MAX / 4] dwords before processing facts data. Fixes: 824a156633df ("scsi: mpi3mr: Base driver code") Cc: stable@vger.kernel.org Signed-off-by: Milan P. Gandhi Link: https://patch.msgid.link/20261105122401.266559-1-mgandhi@redhat.com Signed-off-by: Martin K. Petersen (Oracle) commit 0fc91e802801819a0c51d30b6eecac63ab4f85d2 Author: Shao Mingyin Date: Thu Nov 5 19:33:53 2026 +0800 scsi: target: core: Drop the dead kmap_local_page() NULL check kmap_local_page() never returns NULL; drop the wrapper and always zero the segment. No functional change. Signed-off-by: Shao Mingyin Link: https://patch.msgid.link/20261105193353023NXQ1VSNCIijJ53XmDJc1y@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) commit 63d67440dc9f103aad38b14f409d6d6e54396746 Author: Shao Mingyin Date: Thu Nov 5 19:33:51 2026 +0800 scsi: target: iblock: Drop the dead kmap() NULL check kmap() never returns NULL, so the check after it is dead code. No functional change. Signed-off-by: Shao Mingyin Reviewed-by: Laurence Oberman Link: https://patch.msgid.link/20261105193351820CRZfBnzFE8zZm2DrNx0T_@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) commit 08f08a6d49efc422258edba802faa4fc7677309e Author: Ciro Iriarte Date: Sat Oct 31 22:21:39 2026 -0300 scsi: target: core: Parse APTPL res_type and res_scope as hex core_scsi3_update_aptpl_buf() saves the reservation holder's type and scope to the APTPL metadata file as zero-padded hex ("res_type=%02x", "res_scope=%02x"), but target_pr_res_aptpl_metadata_store() reads them back with "%d" tokens and match_int(), which parse with base 0. A leading zero selects octal, so match_token() parses only the "0" of "res_type=08", the trailing "8" makes the token not match, and the field is ignored as unknown. An Exclusive Access - All Registrants holder (type 0x8) is left with type 0 and the write fails with -EINVAL and Illegal PR type: 0x00 for reservation holder Userspace that restores APTPL state by writing the saved records back to pr/res_aptpl_metadata (rtslib-fb does this when it recreates a storage object) therefore loses every type 8 reservation across a target restart, and with rtslib the storage object creation fails. The other valid types (1, 3, 5, 6, 7) and scope 0 only work because their octal and decimal values coincide. Keep the on-disk format and parse both fields as hex. The valid type and scope values have the same hex and decimal representation, so records written in decimal by hand keep working. Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6") Cc: stable@vger.kernel.org Signed-off-by: Ciro Iriarte Link: https://patch.msgid.link/ea903e6c-09b5-4a11-80e8-6e1387f39ef5@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit db1fe578b7eabc7f218b84fc18a626d07f377a69 Author: Shao Mingyin Date: Sat Oct 31 22:22:43 2026 +0800 scsi: scsi_transport_fc: Reject truncated FPIN payloads fc_host_fpin_rcv() computes the length of the TLV area as: bytes_remain = fpin_len - offsetof(struct fc_els_fpin, fpin_desc); without checking that the payload is at least as large as the fixed FC-ELS header. For fpin_len smaller than the header size the subtraction underflows to a huge u32, and the min_t() on the next line also reads fpin->desc_len at offset 4, which is outside the payload when fpin_len is 4 or less. The TLV walker then parses memory that is not part of the FPIN. Reject payloads that cannot hold the header: there is no descriptor list to parse and no statistics to update. This is not only defensive: qla2xxx forwards the firmware-provided frame size minus the 24-byte PURX ELS header, so a frame of exactly that size reaches this helper with a zero length. fpin_len is supplied by the LLDD and the helper is exported, so it should not assume a minimum. Fixes: 3dcfe0de5a97 ("scsi: fc: Parse FPIN packets and update statistics") Signed-off-by: Shao Mingyin Link: https://patch.msgid.link/20261031222243820vSs-SXTIpNSHpWeC2dJ38@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) commit 787fd1429b3603fdc69ebba864165478c4e73544 Author: Shao Mingyin Date: Sat Oct 31 22:21:33 2026 +0800 scsi: scsi_devinfo: Return an error when the proc write fails proc_scsi_devinfo_write() calls scsi_dev_info_list_add_str() but ignores its return value, so a write to /proc/scsi/device_info always reports success, even when the string is malformed and no entry was added. Users and scripts then believe that the quirk is in effect. scsi_init_devinfo() already checks the return value of the same function and fails the initialization. Return the parser error, but keep returning the number of bytes written on success: a proc write handler that returns zero for a non-empty write would look like a short write to the caller. Signed-off-by: Shao Mingyin Reviewed-by: Laurence Oberman Link: https://patch.msgid.link/20261031222133489hI-BEIDpFMxrtlntnLiFb@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) commit dd86dc1d86c892c75592d45e000499dfb20d2c62 Author: Jesse Taube Date: Thu Oct 29 12:04:43 2026 -0400 scsi: qedf: Remove unesseary function call The result of `skb_transport_header()` was unused. Calling this function warned when `skb_transport_header_was_set()` returned false causing a panic on debug kernels. Signed-off-by: Jesse Taube Reviewed-by: Laurence Oberman Reviewed-by: John Meneghini Reviewed-by: Nilesh Javali Link: https://patch.msgid.link/20261029160443.904468-1-jtaubepe@redhat.com Signed-off-by: Martin K. Petersen (Oracle) commit dc7ba60d45b105b91d4e2e9567b355fb4a043def Author: Brian Bunker Date: Fri Oct 30 10:57:20 2026 -0700 scsi: core: Restart the queue when unblocking a device set running A device that its transport blocks has its queue stopped. If the SCSI error handler then gives up on the device, it moves it from SDEV_BLOCK to SDEV_OFFLINE and leaves the queue stopped. When userspace later writes "running" to the device's state attribute, store_state_field() moves it to SDEV_RUNNING, still with the queue stopped, and rescans it. The rescan takes the device lock and waits for I/O that can never be dispatched. When the transport then unblocks the device, scsi_internal_device_unblock_nowait() rejects a device in SDEV_RUNNING with -EINVAL before it reaches scsi_start_queue(), so nothing ever restarts the queue. The task that wrote "running" hangs forever holding the device lock, and anything else that takes it hangs behind it. The -EINVAL also makes scsi_host_unblock() stop at this device and leave the rest of the host blocked, and keeps the device in SDEV_RUNNING when the transport asked for SDEV_TRANSPORT_OFFLINE. This shows up with iSCSI when a session drops again just after recovering. iscsid onlines the session's devices after a relogin by writing "running" to every device it finds offline: 1. The session is blocked, which blocks the device and stops its queue. 2. The error handler cannot recover the device and moves it from SDEV_BLOCK to SDEV_OFFLINE. The queue stays stopped. 3. iscsid writes "running": SDEV_OFFLINE -> SDEV_RUNNING with the queue still stopped, then the rescan sends an INQUIRY that sits unsent while holding the device lock. 4. The session recovery timeout calls scsi_target_unblock(). The other devices go from SDEV_BLOCK to SDEV_TRANSPORT_OFFLINE and get their queues restarted, but this one is skipped because it is already running. A vmcore from such a hang shows the device in SDEV_RUNNING with queue_stopped set and the queue's quiesce_depth at 1, the rescan's INQUIRY never started (MQ_RQ_IDLE, no start time or deadline), and iscsid owning the device lock while other tasks wait for it. Handle this in scsi_internal_device_unblock_nowait(), which already restarts the queue of an SDEV_OFFLINE device: accept an SDEV_RUNNING device whose queue is still stopped, move it to the requested state and restart the queue. A running device whose queue is not stopped was never blocked and is still rejected. Do not restart the queue from store_state_field() instead. The device is still blocked by its transport at that point, and some transports and drivers rely on the stopped queue to keep commands away while they reconnect or reset the adapter. Fixes: f0f82e2476f6 ("scsi: core: Fix capacity set to zero after offlinining device") Signed-off-by: Brian Bunker Link: https://patch.msgid.link/20261030175721.24379-2-brian@purestorage.com Signed-off-by: Martin K. Petersen (Oracle) commit 48d3b732e5ad3fffe74e033d9a3cf47ebaa314b0 Author: Praneeth Balasubramanian Date: Thu Oct 29 13:54:56 2026 -0700 scsi: target: iscsi: Check for existing sessions only after authentication In the operational-negotiation path (CSG=1), iscsi_target_handle_csg_one() calls iscsi_target_check_for_existing_instances() before iscsi_conn_authenticated(). An initiator can therefore send a first Login PDU with CSG=1, TSIH=0 and no CHAP exchange, carrying the InitiatorName and ISID of an existing session. The target reinstates that session, which tears down the legitimate initiator's connection. Only afterwards does it reject the login with AUTH_FAILED. iscsi_check_for_session_reinstatement() matches on ISID, InitiatorName and SessionType only. The InitiatorName is not secret, and open-iscsi ISIDs are a fixed OUI followed by a small session counter. A remote peer with no credentials can thus repeatedly disconnect a CHAP-authenticated session and keep its I/O failing. The comment above iscsi_target_check_for_existing_instances() already states the intended invariant: NOTE: We check for existing sessions or connections AFTER the initiator has been successfully authenticated in order to protect against faked ISID/TSIH combinations. The security-negotiation path (CSG=0) honours this, calling the check only once authentication completes. Move the CSG=1 call below the authentication check so both paths behave the same. When authentication is not required, iscsi_conn_authenticated() returns true and behaviour is unchanged. Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian Link: https://patch.msgid.link/20261029205456.1211532-1-praneethb2002@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit 6054ce4233dbc692f50da5517ad459fae1b14ac6 Author: Brian Bunker Date: Wed Oct 28 17:25:31 2026 -0700 scsi: core: Match ULDs to logical units in the ALUA unavailable state scsi_bus_match() only matches devices with peripheral qualifier 000b, so a LU that is in the ALUA unavailable state on a target port when the host scans it never gets an upper-level driver on that path. When the target port becomes available again, nothing binds sd and the path stays unusable until the device is deleted and rescanned. A host that was already running when the path became unavailable keeps sd bound, so the result depends on when the host scanned. Peripheral qualifier 001b cannot be matched on its own: an unmapped LUN reports it as well, and some targets report every possible LUN in REPORT LUNS. Binding sd to all of those would create disks with no backing LU. The SCSI core now reads the access state of a device that supports target port groups with REPORT TARGET PORT GROUPS before the device is registered, and an unmapped LUN fails that command. SPC-4 requires a LU in the unavailable state to report PQ 001b, and the command shows that the LU is mapped, so record in the device whether it reported PQ 001b and its access state could be read, and match such a device. sd then binds to the unavailable path like it does to a standby path, the path stays in the multipath map as a failed path, and the existing UNIT ATTENTION handling brings it back when the target port becomes available. The decision is made once, at scan time, and not from access_state when the match is made. access_state follows the ALUA state, but the peripheral qualifier it relates to does not change after the scan. If the match depended on access_state, a device scanned in the unavailable state would stop matching as soon as its path became available, e.g. when the upper-level driver module is loaded later, or the driver is rebound, or the ALUA device handler updates access_state before the driver is probed. It also does not depend on the state that the command returns, which can already be available if the path recovered between the INQUIRY and the command. This is the same situation as a path in the standby state, to which sd already binds: SPC-4 requires READ CAPACITY in neither state. The unavailable state does not require MODE SENSE either, which the standby state does. The cached INQUIRY data in sysfs keeps the peripheral qualifier reported at scan time, like the rest of the INQUIRY data; access_state shows the current ALUA state. Co-developed-by: Krishna Kant Signed-off-by: Krishna Kant Signed-off-by: Brian Bunker Reviewed-by: Hannes Reinecke Link: https://patch.msgid.link/20261029002531.82824-4-brian@purestorage.com Signed-off-by: Martin K. Petersen (Oracle) commit e085b1d6b6aabd6a7dcd9f02135f9376ff39e95a Author: Brian Bunker Date: Wed Oct 28 17:25:30 2026 -0700 scsi: core: Read the ALUA access state when a device is scanned sdev->access_state is only set by a device handler, and the ALUA device handler reads the state with an RTPG that runs after the device has been registered and matched to a driver. The SCSI core therefore has no ALUA state for a device while it decides whether to bind an upper-level driver to it. For a device that reports TPGS support, send REPORT TARGET PORT GROUPS from scsi_add_lun(), after the VPD pages have been read, and set sdev->access_state from the descriptor of the target port group of this path. UNIT ATTENTIONs, which a target typically reports first after a login or an ALUA state change, are retried, and the command is resent without the extended header if the target rejects it. If the command fails, e.g. with LOGICAL UNIT NOT SUPPORTED because no LU is mapped at the LUN, sdev->access_state is left as it is. The command uses the same timeout as the INQUIRY of the scan. The ALUA device handler keeps updating sdev->access_state afterwards as before. Suggested-by: Hannes Reinecke Co-developed-by: Krishna Kant Signed-off-by: Krishna Kant Signed-off-by: Brian Bunker Reviewed-by: Hannes Reinecke Link: https://patch.msgid.link/20261029002531.82824-3-brian@purestorage.com Signed-off-by: Martin K. Petersen (Oracle) commit 746aa1d936b17679361e8d787c6480ccb7c21240 Author: Brian Bunker Date: Wed Oct 28 17:25:29 2026 -0700 scsi: core: Move REPORT TARGET PORT GROUPS into the SCSI core ALUA is a standard SCSI feature, independent of multipathing, but only the ALUA device handler can currently send REPORT TARGET PORT GROUPS. Move submit_rtpg() into the SCSI core as scsi_report_tpgs(), together with the resubmission with a larger buffer that alua_rtpg() did when the parameter data did not fit, so that the core can read the ALUA state of a device itself. The parameter data format definitions move to scsi_proto.h with it. scsi_dh_alua calls scsi_report_tpgs() with the same timeout, retries and parameter data format as before. No functional change. Suggested-by: Hannes Reinecke Co-developed-by: Krishna Kant Signed-off-by: Krishna Kant Signed-off-by: Brian Bunker Reviewed-by: Hannes Reinecke Link: https://patch.msgid.link/20261029002531.82824-2-brian@purestorage.com Signed-off-by: Martin K. Petersen (Oracle) commit 612293fb469c81408829e6325bae25725968986f Author: Boyan Liu Date: Wed Oct 28 14:16:51 2026 +0800 scsi: sd_zbc: Cap zone report count by buffer size sd_zbc_report_zones() limits descriptor parsing to the requested zone count and the device-reported ZONE LIST LENGTH, but not to the number of descriptors that fit in the allocated report buffer. A malicious or malfunctioning device can report an oversized length and cause out-of-bounds reads while the descriptors are parsed: BUG: KASAN: slab-out-of-bounds in sd_zbc_report_zones (drivers/scsi/sd_zbc.c:256) Read of size 8 at addr ffff88802c8d2610 by task kworker/u8:2/37 Call Trace: sd_zbc_report_zones (drivers/scsi/sd_zbc.c:256) blk_revalidate_disk_zones (block/blk-zoned.c:2354) sd_zbc_revalidate_zones (drivers/scsi/sd_zbc.c:566) sd_revalidate_disk (drivers/scsi/sd.c:3898) sd_probe (drivers/scsi/sd.c:4101) Cap the descriptor count with min3() over the remaining requested zones, the device-reported count, and max_in_buf derived from buflen. This matches nvme_ns_report_zones() and preserves iteration over reports that require multiple commands. Use shared constants for the REPORT ZONES header and zone descriptor sizes. [mkp: define constants] Fixes: d41003513e61 ("block: rework zone reporting") Cc: stable@vger.kernel.org Reported-by: co+4a4f9998e2b4b490@bugs.sh Signed-off-by: Boyan Liu Link: https://patch.msgid.link/20261028061651.110435-1-yymhvert@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit 46846939d5f33c9333612662c52475f92e753407 Author: Shao Mingyin Date: Mon Oct 26 19:54:09 2026 +0800 scsi: rdac: Keep the error status when controller lookup fails initialize_controller() records SCSI_DH_RES_TEMP_UNAVAIL when get_controller() fails, but then overwrites it with SCSI_DH_OK unconditionally. It therefore reports success with h->ctlr == NULL and rdac_bus_attach() continues with check_ownership(), which dereferences h->ctlr: BUG: kernel NULL pointer dereference, address: 0000000000000000 ... check_ownership rdac_bus_attach get_controller() only fails when its GFP_ATOMIC allocation fails, so the crash happens exactly when memory is already scarce. Only report success after the controller was found and the device was added to its list. Fixes: 327825574132 ("scsi_dh_rdac: switch to scsi_execute_req_flags()") Signed-off-by: Shao Mingyin Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261026195409354OWEI2b6HO7swSphvv1FOc@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) commit c0bb6614132c64205a3c40c32dc1494c1bfeffe1 Author: Shao Mingyin Date: Mon Oct 26 19:51:33 2026 +0800 scsi: target: Fix NULL pointer dereference in core_alua_do_port_transition() core_alua_do_port_transition() assumes that the device has an ALUA LU group member and that the member is associated with an LU group. Neither is guaranteed: internal-use HBAs never allocate dev_alua_lu_gp_mem, and the association with an LU group is dropped when "NULL" is written to the device's alua_lu_gp attribute. The configfs path can reach the second case. After clearing the LU group association, writing the implicit ALUA access state of a target port group calls core_alua_do_port_transition(), which dereferences the NULL lu_gp in atomic_inc(&lu_gp->lu_gp_ref_cnt). Return -ENODEV when the device has no LU group association instead. Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6") Signed-off-by: Shao Mingyin Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261026195133237y2UxJLoV1FK6aD1zrFbIU@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) commit fe5988e8708e1d42cb844bd9ac8f0a51388061fc Author: Shao Mingyin Date: Mon Oct 26 19:49:55 2026 +0800 scsi: target: Fix NULL pointer dereference in target_dev_alua_lu_gp_store() Writing "NULL" to the alua_lu_gp attribute clears the ALUA LU group association of a device. The attribute can be written again after the association has already been cleared. In that case lu_gp_mem->lu_gp and lu_gp_new are both NULL, but the code still calls __core_alua_attach_lu_gp_mem(), which dereferences the NULL lu_gp pointer: BUG: kernel NULL pointer dereference, address: 0000000000000000 ... __core_alua_attach_lu_gp_mem target_dev_alua_lu_gp_store Clearing an already cleared association is a no-op, so return early when there is no association left to clear. Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6") Signed-off-by: Shao Mingyin Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261026194955694FnXGoQ352dstLk5HPBqCG@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) commit e1a17bf98f513a77e5e6903315c49f56ee009886 Author: Denis Ahrens Date: Mon Oct 26 10:51:54 2026 +0100 scsi: mvme16x: Enable 53c710 burst-8 hardware transfer mode The shared 53c700.c backend runs the 53c710 with burst mode disabled when hostdata->burst_length is left unset: NCR_700_chip_setup() falls through to BURST_DISABLE in CTEST7 and a 1-byte burst length in DMODE_710_REG, so the chip delivers one byte per transfer period. The other 53c710 hosts in-tree already use it: sim710 and lasi700 pick burst 8, sni_53c710 burst 4. A/B verified on an MVME177 (53c710 rev 2, ZuluSCSI drives): raw reads 16 MiB @64k 4.7/4.8/5.1 -> 5.8/6.1/6.7 MB/s (+23..26%) 4 MiB @16k 3.4 -> 4.4 MB/s 4 MiB @4k 3.2 -> 3.9 MB/s 4 MiB @512B 2.1 -> 2.2 MB/s (small-buffer case is SCSI command-count bound; burst only raises bytes per command, not commands) writes unchanged (filesystem-bound, not ASIC-bound) Integrity: a 16 MiB /dev/urandom payload round-trips bit-exact on a cold read (sync + drop_caches, md5 verified write vs read); dmesg clean with no timeouts, sense errors, retries or resets. Signed-off-by: Denis Ahrens Link: https://patch.msgid.link/733CA975-51A9-4687-BBD5-1FB4171FA3FE@h3q.com Signed-off-by: Martin K. Petersen (Oracle) commit b3da73f09499b34faf5c43c50e1d09e4286226de Author: Joonhoe Kim <26rote@gmail.com> Date: Fri Oct 23 01:50:06 2026 +0900 scsi: ufs: qcom: Reprogram ESI after a host controller reset ufs_qcom_config_esi() returns early once the ESI interrupts are set up. ufshcd_config_mcq() also calls it after every host controller reset, which clears the ESI base address, the vector mask and ESI enable. After the error handler has reset the controller, the completions then arrive only on the legacy interrupt while mcq_esi_enabled stays set. Allocate the MSIs and request their interrupts only once, but program the ESI registers on every call. The MSI message is not cached for platform MSIs, so keep the one written at allocation. Fixes: 519b6274a777 ("scsi: ufs: qcom: Add MCQ ESI config vendor specific ops") Signed-off-by: Joonhoe Kim <26rote@gmail.com> Link: https://patch.msgid.link/20261022165006.1275-1-26rote@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit ae8ecbc1e28633bdb23cfb61d8048c4e8f52052d Author: Torra Sowmya Date: Sun Nov 8 12:16:26 2026 +0530 scsi: sd: Remove unused zone append tracepoints Commit 1846f308d66f ("scsi: sd: Use the block layer zone append emulation") removed the calls to scsi_prepare_zone_append and scsi_zone_wp_update, but left their definitions in sd_trace.h. Consequently, sd_zbc.c still generates code and data for events that have no remaining callers. Remove sd_trace.h, which contains only these two events, and remove its include and CREATE_TRACE_POINTS definition from sd_zbc.c. Fixes: 1846f308d66f ("scsi: sd: Use the block layer zone append emulation") Signed-off-by: Torra Sowmya Link: https://patch.msgid.link/20261108064626.5539-1-sowmyatorra@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit e510b597d8afca2e790e2b5429bc5e01e3386f65 Author: Kiwoong Kim Date: Fri Nov 6 13:12:47 2026 +0900 scsi: ufs: mcq: Poll OCS after sq cleanup for device management commands Extend ufshcd_mcq_sq_cleanup() to poll the OCS field in the UTRD of a device management command after a successful SQ_CUS poll. UFSHCI does not specify the order between the OCS update and the SQ_CUS update, so OCS may still be stale when cleanup returns. Without this poll, a late response to a timed-out query can arrive while a retry is already in flight, leaving the host controller with two query contexts and raising IS.UTPES. Here is the timeline of an actual case I found with kernel 6.18: 1. The driver sent a query but the device didn't respond to it for a long time. [ 7384.156142] [4: kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_mcq_sq_cleanup, hwq 0: cleanup return code (RTC) 0 [ 7384.156154] [4: kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = -11 2. So after the query timed out, the driver did SQ cleanup. Then the host controller updated the CQ tail and raised IS.CQES. Unfortunately, complete() was called by the driver's ISR afterward. 3. The driver started to retry the query. In the meantime, it set OCS to 0xF. Then the driver didn't wait for completion due to the previous complete() call, and just checked OCS. [ 7384.156163] [4: kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = 15 4. The driver retried the query again, but the device didn't return anything, so the query also timed out. [ 7385.660108] [3: kworker/u40:5:10671] exynos-ufs 38300000.ufs: ufshcd_query_flag: Sending flag query for idn 14 failed, err = -11 5. A few seconds later, the device returned the response of the first query, but since the host controller was holding two query contexts and couldn't handle it, it raised IS.UTPES. The same problem exists in the current code. If the query times out, the SCSI error handler calls ufshcd_abort() -> ufshcd_mcq_abort() -> ufshcd_mcq_sq_cleanup(), the request is finished, and the retry reuses the same reserved tag, struct scsi_cmnd and devman UCD. A late CQE for the first query then maps to the same tag and completes the retry by calling scsi_done() too early. The retry then returns the OCS of the first query and, if that OCS is OCS_SUCCESS, its response as well. Hence ufshcd_mcq_sq_cleanup() must not return until the CQE of the cleaned-up request has been processed. The poll is limited to device management commands because ufshcd_compl_one_cqe() copies the OCS from the CQE into the UTRD only for them. For SCSI commands, the OCS in the UTRD stays OCS_INVALID_COMMAND_STATUS, so polling it would always time out. The poll waits until OCS is no longer OCS_INVALID_COMMAND_STATUS or MCQ_POLL_US elapses. -ETIMEDOUT is returned only if OCS is still OCS_INVALID_COMMAND_STATUS after the poll. Any other value, such as OCS_ABORTED reported by the host controller for the cleaned-up request, means the cleanup has completed. The UFSHCI specification says "The host controller shall free up any resources associated to the nexus, and shall post a Completion Queue entry with OCS = ABORTED if clean up successful." Each poll iteration reaps the CQ with ufshcd_mcq_poll_cqe_lock() before reading the OCS, as ufshcd_clear_lu_cmds() does after ufshcd_clear_cmd(). This removes the dependency on interrupt delivery. Otherwise the OCS is only updated once the interrupt handler processes the CQE, and a delayed or lost interrupt would make the poll time out and escalate to a host reset although the request has already been cleaned up. The OCS is still read under hwq->cq_lock because the interrupt handler may reap the CQE between the reap and the read. ufshcd_compl_one_cqe() updates the OCS under that lock before it sets cmd->result and calls scsi_done(). Without the lock, cleanup could observe the new OCS and return while the completion is still running. The abort could then finish the command and a retry could reuse the same reserved request before the pending scsi_done() call, which would then complete the retry prematurely. Fixes: 8d7290348992 ("scsi: ufs: mcq: Add supporting functions for MCQ abort") Signed-off-by: Kiwoong Kim Reviewed-by: Bart Van Assche Reviewed-by: Bean Huo Link: https://patch.msgid.link/a1af44cd90dca0dd8a9a06d09a254a4e7e0861b2.1793938245.git.kwmad.kim@samsung.com Signed-off-by: Martin K. Petersen (Oracle) commit 30bdadc9aa3a684cd634c7fa49740b1151e7b2e5 Author: Kiwoong Kim Date: Fri Nov 6 13:12:46 2026 +0900 scsi: ufs: core: Skip ABORT TASK for device management commands In MCQ mode, ufshcd_mcq_abort() falls through to ufshcd_try_to_abort_task() for all timed-out commands. However, device management commands (query, NOP) use reserved requests and are not SCSI I/O commands. The ABORT TASK task management function is designed for SCSI I/O UPIUs and is not applicable to device management UPIUs. This is only reachable since device management commands were converted to scsi_get_internal_cmd(); before that, a timed-out query was handled by ufshcd_wait_for_dev_cmd() -> ufshcd_clear_cmd() and never reached ufshcd_try_to_abort_task(). Fix this by checking ufshcd_is_scsi_cmd() in ufshcd_try_to_abort_task(). For a reserved (device management) command, skip the TM path and call ufshcd_clear_cmd() directly. ufshcd_abort() now calls ufshcd_try_to_abort_task() for every request, so its separate reserved-request branch is removed. Fixes: 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()") Reported-by: Bart Van Assche Signed-off-by: Kiwoong Kim Reviewed-by: Bean Huo Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/ab14d2f1414fa1a0a396f160abf8c27c404b4ec4.1793938245.git.kwmad.kim@samsung.com Signed-off-by: Martin K. Petersen (Oracle) commit 04feb5fd2c23894ebc2cdaf4a4cc38b8667b17ac Author: Dongdong Hao Date: Wed Nov 4 17:28:08 2026 +0800 scsi: leapraid: Fix init_cmd_priv error handling leapraid_init_cmd_priv() ignores the return value of leapraid_internal_init_cmd_priv() and always returns success. If dma_pool_alloc() fails, io_tracker->chain remains NULL, but the SCSI midlayer considers the command successfully initialized. A subsequent I/O requiring more than LEAPRAID_SGL_INLINE_THRESHOLD DMA-mapped scatter-gather entries dereferences the NULL chain buffer while building the chained SGL, causing a kernel crash. Return the result of leapraid_internal_init_cmd_priv() so that allocation failures propagate to the SCSI midlayer and abort initialization of the affected request. Reviewed-by: Damien Le Moal Signed-off-by: Dongdong Hao Link: https://patch.msgid.link/20261104092808.206067-1-doubled@leap-io-kernel.com Fixes: 5597088c9e79 ("scsi: leapraid: Add new SCSI driver") Signed-off-by: Martin K. Petersen (Oracle) commit c14818f4d2b46a67fa0d2fd8fd5ef3532245f07a Author: Bart Van Assche Date: Fri Oct 30 15:42:39 2026 -0700 scsi: core: Limit retries of commands that receive UNIT ATTENTION Fail non-removable commands in scsi_io_completion_action() on UNIT ATTENTION if retries exceed max(cmd->allowed, 3). This bounds the number of retries of commands for which scsi_decide_disposition() exhausted the retries or that have been finished by the error handler, e.g. because a target keeps reporting UNIT ATTENTION after recovery. Since scmd->retries is not incremented for failfast commands on this code path, failfast commands are retried until the command runtime limit is exceeded, as before. Signed-off-by: Bart Van Assche Tested-by: Alexey Charkov Link: https://patch.msgid.link/959f1c7628af83cd184ac51f35e38d654b261069.1793400000.git.bvanassche@acm.org Signed-off-by: Martin K. Petersen (Oracle) commit 49da33f609929db6f6c3b8567d0e0cca6f9ae182 Author: Bart Van Assche Date: Fri Oct 30 15:42:38 2026 -0700 scsi: core: Escalate persistent UNIT ATTENTION conditions Recover from persistent UNIT ATTENTION conditions in the SCSI midlayer instead of maintaining a per-device quirk list for targets such as BIWIN BWU2A05* UFS devices that fail to clear power-on or reset UNIT ATTENTION on WRITE commands while clearing it on commands such as TEST UNIT READY, READ, and SYNCHRONIZE CACHE. If a non-removable block request that is not failfast receives the same UNIT ATTENTION repeatedly, retry it twice and invoke the error handler thereafter, instead of letting scsi_io_completion_action() retry uncounted until the command runtime limit is exceeded. The error handler clears the UNIT ATTENTION by sending TEST UNIT READY. Track this with a dedicated per-command counter and the additional sense code of the most recent UNIT ATTENTION instead of scmd->retries. scmd->retries is also incremented for other retry reasons and by the error handler, and a target may report multiple queued UNIT ATTENTION conditions with different additional sense codes. On most architectures the new fields occupy an existing hole in struct scsi_cmnd. Limit the number of error handler invocations for commands with unlimited retries since scsi_eh_flush_done_q() does not limit these. Only apply this escalation when the sense data is evaluated by scsi_decide_disposition() and leave the behavior of the exported scsi_check_sense() function unchanged. libata calls scsi_check_sense() from its own error handler, which translates FAILED into an ATA port reset and never sends TEST UNIT READY. Reported-by: Alexey Charkov Closes: https://lore.kernel.org/linux-scsi/20261028-biwin-tua-quirk-v1-1-767a12c9b9cc@flipper.net/ Signed-off-by: Bart Van Assche Tested-by: Alexey Charkov Link: https://patch.msgid.link/5c34851674a67879e175251b9bfe6ccf091e390a.1793400000.git.bvanassche@acm.org Signed-off-by: Martin K. Petersen (Oracle) commit d54e68b5c31cbfb108c1f22ec21bdf43c5133e0e Author: Bart Van Assche Date: Fri Oct 30 15:42:37 2026 -0700 scsi: core: Clear UNIT ATTENTION conditions with TEST UNIT READY Some targets, e.g. BIWIN BWU2A05* UFS devices, fail to clear power-on or reset UNIT ATTENTION conditions on WRITE commands while clearing these on commands like TEST UNIT READY, READ, and SYNCHRONIZE CACHE. Add scsi_eh_clear_ua() to scsi_eh_ready_devs() ahead of device reset so that the error handler sends TEST UNIT READY to consume a stuck UNIT ATTENTION and verifies with a follow-up TEST UNIT READY that the condition cleared before requeueing affected commands. Allow a few additional TEST UNIT READY attempts for queued UNIT ATTENTION conditions and busy devices, delay retries, and honor the error handler deadline. Save and restore scmd->sense_buffer across scsi_send_eh_cmnd() so that the original sense data remains intact while filtering work_q and if retries are later exhausted. Log a rate-limited message when a persistent UNIT ATTENTION is cleared to make it possible to identify misbehaving devices. Signed-off-by: Bart Van Assche Link: https://patch.msgid.link/444e78b0fa892e8854bee89f341824d67000d968.1793400000.git.bvanassche@acm.org Signed-off-by: Martin K. Petersen (Oracle) commit 099fb3376bb73c29457782d917a3b68d846a9e87 Author: Bart Van Assche Date: Fri Oct 30 15:42:36 2026 -0700 scsi: core: Simplify scsi_eh_ready_devs() Replace the nested if-statements in scsi_eh_ready_devs() with a single if-statement that combines the conditions with the && operator. This reduces the indentation level and makes it easier to insert additional recovery steps. No functionality has been changed. Signed-off-by: Bart Van Assche Link: https://patch.msgid.link/de1a210fb52adaefd818ed68eb5e7678a004762e.1793400000.git.bvanassche@acm.org Signed-off-by: Martin K. Petersen (Oracle) commit b7545895b1c97b8fd0201ee6eac9cbeb57f1e3c5 Author: Bart Van Assche Date: Fri Oct 30 15:42:35 2026 -0700 scsi: core: Introduce scsi_cmd_needs_stu() Introduce scsi_cmd_needs_stu() and use it in scsi_eh_stu() instead of testing scsi_check_sense(scmd) == FAILED. This makes it explicit that START UNIT is only sent for LU_NOT_READY_INITIALIZING_COMMAND_REQUIRED and prevents that the error handler reports sense data a second time. This patch prepares for making scsi_decide_disposition() escalate persistent UNIT ATTENTION conditions to the error handler. Signed-off-by: Bart Van Assche Link: https://patch.msgid.link/c35a3b27958cb93c26c1ccecccd572c54da448e4.1793400000.git.bvanassche@acm.org Signed-off-by: Martin K. Petersen (Oracle) commit c84374cf4d2cb0c6efff91f7a37e85656cbbd593 Author: Shawn Lin Date: Thu Oct 29 15:24:55 2026 +0800 scsi: ufs: rockchip: Improve RX noise immunity Program VND_RX_SAVE_DET_CTRL for each RX lane to raise the receiver's tolerance against short transients on the incoming signal, as recommended by the Rockchip PHY team. Signed-off-by: Shawn Lin Link: https://patch.msgid.link/20261029151030.1.I61cd43e660b146e49d4380a754e936270e5fb6a1@changeid Signed-off-by: Martin K. Petersen (Oracle) commit 9eb89611d95914e47cec62826e4000396df0f953 Author: Stanley Jhu Date: Thu Oct 29 15:08:40 2026 +0800 scsi: ufs: hwmon, debugfs: Propagate runtime PM resume errors ufs_hwmon_read(), ufs_hwmon_write(), and ufs_debugfs_get_user_access() resume the UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its return value. For example, for a hwmon temperature read: 1. The W-LUN is runtime suspended. 2. User space reads temp1_input of the UFS hwmon device. 3. ufs_hwmon_read() calls ufshcd_rpm_get_sync(). 4. The W-LUN runtime resume fails and the W-LUN stays suspended. 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored. 6. ufs_hwmon_read() sends an attribute query UPIU while the W-LUN is still suspended. ufs_hwmon_write() and the debugfs writers that use ufs_debugfs_get_user_access() (exception_event_mask and tx_eq_ctrl) follow the same sequence. Convert all three call sites to ufshcd_rpm_resume_and_get() and release hba->host_sem before returning the error, ahead of __acquire(ufs_debugfs) in ufs_debugfs_get_user_access(). Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun") Fixes: e88e2d32200a ("scsi: ufs: core: Probe for temperature notification support") Fixes: adbabdcf0db0 ("scsi: ufs: core: Add support to retrain TX Equalization via debugfs") Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper" Signed-off-by: Stanley Jhu Reviewed-by: Bart Van Assche Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261029040003.2100003-6-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit 2b8541edf7c43f0294c45d2e687bbc1288292f4e Author: Stanley Jhu Date: Thu Oct 29 15:08:39 2026 +0800 scsi: ufs: bsg: Abort ufs_bsg_request() when runtime resume fails ufs_bsg_request() resumes the UFS device W-LUN with ufshcd_rpm_get_sync() and ignores its return value: 1. The W-LUN is runtime suspended. 2. User space submits a BSG request. 3. ufs_bsg_request() calls ufshcd_rpm_get_sync(). 4. The W-LUN runtime resume fails and the W-LUN stays suspended. 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored. 6. ufs_bsg_request() dispatches the BSG command while the W-LUN is still suspended. Use ufshcd_rpm_resume_and_get() and jump to out_complete on error so the BSG job is completed via bsg_job_done() with the failure code without dropping an unacquired runtime PM reference. Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun") Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper" Signed-off-by: Stanley Jhu Reviewed-by: Bart Van Assche Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261029040003.2100003-5-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit 93891d1c486efcef2267c32e6e73ca2fd243704e Author: Stanley Jhu Date: Thu Oct 29 15:08:38 2026 +0800 scsi: ufs: sysfs: Propagate runtime PM resume errors All 14 ufshcd_rpm_get_sync() callers in ufs-sysfs.c resume the UFS device W-LUN and ignore the return value. For example, for a UFS descriptor read: 1. The W-LUN is runtime suspended. 2. User space reads a UFS descriptor attribute in sysfs. 3. ufs_sysfs_read_desc_param() calls ufshcd_rpm_get_sync(). 4. The W-LUN runtime resume fails and the W-LUN stays suspended. 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored. 6. ufs_sysfs_read_desc_param() sends a query UPIU while the W-LUN is still suspended. The other sysfs callers follow the same sequence. They send other query UPIUs, or read a host register in ufshcd_read_hci_reg(). Switch all 14 sysfs callers to ufshcd_rpm_resume_and_get() and return the error after releasing any held buffer and hba->host_sem. Fixes: aef80fd1da32 ("scsi: ufs: sysfs: Resume the proper SCSI device") Fixes: b9d104465a6c ("scsi: ufs: Prepare to add HCI capabilities sysfs") Fixes: 600edc6620a4 ("scsi: ufs: sysfs: Make max_number_of_rtt read-write") Fixes: 6c4148ce7cc1 ("scsi: ufs: wb: Add explicit flush sysfs attribute") Fixes: 500d4b742e0c ("scsi: ufs: core: Add WB buffer resize support") Fixes: ae7795a8c258 ("scsi: ufs: core: Add HID support") Fixes: 1fd2e77b8897 ("scsi: ufs: core: Add device level exception support") Cc: stable@vger.kernel.org # needs "scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper" Signed-off-by: Stanley Jhu Reviewed-by: Bart Van Assche Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261029040003.2100003-4-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit cbab12e5b4a7f49d5add4301de275351269cd431 Author: Stanley Jhu Date: Thu Oct 29 15:08:37 2026 +0800 scsi: ufs: core: Introduce ufshcd_rpm_resume_and_get() helper ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() resume the UFS device W-LUN with ufshcd_rpm_get_sync() and ignore its return value. For clkscale_enable: 1. The W-LUN is runtime suspended and clock scaling is disabled. 2. User space writes 1 to clkscale_enable. 3. ufshcd_clkscale_enable_store() calls ufshcd_rpm_get_sync(). 4. The W-LUN runtime resume fails and the W-LUN stays suspended. 5. ufshcd_rpm_get_sync() returns a negative errno, which is ignored. 6. ufshcd_clkscale_enable_store() enables clock scaling and resumes devfreq while the W-LUN is still suspended. For auto_hibern8: 1. The W-LUN starts a runtime suspend. 2. User space writes a new value to auto_hibern8. 3. ufshcd_auto_hibern8_update() sees that the W-LUN is not yet suspended and calls ufshcd_rpm_get_sync(). 4. ufshcd_rpm_get_sync() waits for the runtime suspend to finish and then runs the W-LUN runtime resume. 5. The W-LUN runtime resume fails and the W-LUN stays suspended. 6. ufshcd_rpm_get_sync() returns a negative errno, which is ignored. 7. ufshcd_auto_hibern8_update() writes REG_AUTO_HIBERNATE_IDLE_TIMER while the W-LUN is still suspended. Add ufshcd_rpm_resume_and_get() wrapping pm_runtime_resume_and_get() so failed resumes drop the usage reference automatically, and return early in ufshcd_clkscale_enable_store() and ufshcd_auto_hibern8_update() when it fails. Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun") Cc: stable@vger.kernel.org Signed-off-by: Stanley Jhu Reviewed-by: Bart Van Assche Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261029040003.2100003-3-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit ebf5cab0dd223a36a09742a91be4fea97e46c816 Author: Stanley Jhu Date: Thu Oct 29 15:08:36 2026 +0800 scsi: ufs: core: Restore jiffies conversion of device management timeouts Before commit 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()"), ufshcd_wait_for_dev_cmd() converted the millisecond timeout with msecs_to_jiffies() before waiting for the command. That commit moved the timeout to the block layer and assigns the millisecond value to rq->timeout as is, but rq->timeout is in jiffies. A 1500 ms query timeout (QUERY_REQ_TIMEOUT_DEFAULT) becomes 6 s with CONFIG_HZ=250 and 15 s with CONFIG_HZ=100, and NOP_OUT_TIMEOUT and ADVANCED_RPMB_REQ_TIMEOUT grow the same way. Restore the conversion with msecs_to_jiffies(). Fixes: 08b12cda6c44 ("scsi: ufs: core: Switch to scsi_get_internal_cmd()") Cc: stable@vger.kernel.org # v6.19+ Signed-off-by: Stanley Jhu Reviewed-by: Bart Van Assche Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261029040003.2100003-2-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit cae8db99f3956e6446827ae4a9605a1ed815772b Author: Dmitry Bogdanov Date: Tue Oct 27 21:01:23 2026 +0300 scsi: target: iscsi: Fix hanging WRITE_PENDING commands When Data comes for an aborted WRITE command in WRITE_PENDING state it is silently received and the command does not pass to the target. That leads to hanging of other session with LUN_RESET aborting that command. Pass the aborted WRITE commands when all Data has been gathered. Signed-off-by: Dmitry Bogdanov Reviewed-by: Laurence Oberman Tested-by: Laurence Oberman Link: https://patch.msgid.link/20261027180123.13163-3-d.bogdanov@yadro.com Signed-off-by: Martin K. Petersen (Oracle) commit 94196cd3413fba6cf6d1f71d6de401e56caaf29b Author: Dmitry Bogdanov Date: Tue Oct 27 21:01:22 2026 +0300 scsi: Revert "scsi: target: iscsi: Fix hang for aborted WRITE_PENDING commands" This reverts commit d5869dae5080e976d4b03cc33eb7ceb527f242bf as it introduces double completion of the command and other issues. Signed-off-by: Dmitry Bogdanov Reviewed-by: Laurence Oberman Tested-by: Laurence Oberman Link: https://patch.msgid.link/20261027180123.13163-2-d.bogdanov@yadro.com Signed-off-by: Martin K. Petersen (Oracle) commit 6da1bc55c060bec3163b0e6077f3ac9641f8100c Author: Stanley Jhu Date: Thu Oct 29 15:08:30 2026 +0800 scsi: ufs: core: Keep clock-gating hold on failed W-LUN runtime resume 1. __ufshcd_wl_suspend() takes one ufshcd_hold() reference and sets hba->clk_gating.is_suspended while the UFS device W-LUN enters RPM_SUSPENDED. 2. Since commit eef1d74bf88f ("PM: runtime: Only set runtime_error on suspend callback failures"), a failed runtime resume (for example START STOP UNIT completing with an error) leaves the W-LUN in RPM_SUSPENDED with power.runtime_error == 0, while __ufshcd_wl_resume() already clears hba->clk_gating.is_suspended and calls ufshcd_release(). 3. The next W-LUN runtime resume runs __ufshcd_wl_resume() again without an intervening suspend and calls ufshcd_release() a second time, dropping a reference it does not own and underflowing hba->clk_gating.active_reqs on UFSHCD_CAP_CLK_GATING hosts. Keep hba->clk_gating.is_suspended and the suspend hold across a failed W-LUN runtime resume, so the hold stays paired with the W-LUN RPM_SUSPENDED state and the next successful resume releases it. Fixes: eef1d74bf88f ("PM: runtime: Only set runtime_error on suspend callback failures") Cc: stable@vger.kernel.org # v7.3+ Signed-off-by: Stanley Jhu Reviewed-by: Brian Norris Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261029040002.2100002-1-stanleyjhu@google.com Signed-off-by: Martin K. Petersen (Oracle) commit 2b2bb55990cf1d9dbd59ee326d545798061fce97 Author: James Houghton Date: Mon Oct 26 21:52:17 2026 +0000 scsi: bsg: Don't copy sense data to user memory when canceled scsi_bsg_uring_task_cb() copies the sense data to the submitter's response_addr with copy_to_user(). It runs as io_uring task work, but io_uring may also run it with tw.cancel set from other contexts when the submitting task can't run it: from a kworker when the submitting task has exited (io_tctx_fallback_work()), or from io_cancel_local_task_work() when a DEFER_TASKRUN ring is torn down. In a kworker, current->mm is NULL, and the copy does not reliably fail: the user half of the address space belongs to whatever mm happens to be lazily loaded, if any, so up to max_response_len bytes of sense data may be written into an unrelated process. Don't copy the sense data when the task work is canceled, and complete the command with -ECANCELED. Fixes: 7b6d3255e7f8 ("scsi: bsg: add io_uring passthrough handler") Signed-off-by: James Houghton Reviewed-by: Jens Axboe Link: https://patch.msgid.link/20261026215226.3713941-2-jthoughton@google.com Signed-off-by: Martin K. Petersen (Oracle) commit c78b78166c55ebd6ae0b378499abd519aee7a966 Author: Matt Wang Date: Mon Oct 19 14:29:58 2026 +0800 scsi: vmw_pvscsi: Add support for ARM64 architecture This change adds PVSCSI support for the ARM64 architecture, restricted to little endian and 4K memory page size. Barrier usage is updated from compiler barriers, which were sufficient on x86, to the appropriate DMA barriers. Signed-off-by: Matt Wang Reviewed-by: Vishal Bhakta Link: https://patch.msgid.link/20261019062959.426900-1-matt.wang@broadcom.com Signed-off-by: Martin K. Petersen (Oracle) commit a3d959d2778f22b44c2df52cb70e78811c0e739e Author: Matt Wang Date: Wed Sep 30 07:15:39 2026 +0800 scsi: vmw_pvscsi: Clamp on e->dataLen in pvscsi_complete_request() When calculating the residual bytes, clamp dataLen to the buffer length before the subtraction. This prevents an overflow if the device sends a larger value than expected. Signed-off-by: Matt Wang Link: https://patch.msgid.link/20260929231539.630963-1-matt.wang@broadcom.com Fixes: 851b164231d1 ("[SCSI] vmw_pvscsi: SCSI driver for VMware's virtual HBA.") Signed-off-by: Martin K. Petersen (Oracle) commit 6e862335a8d3a3c8bfc8488dc1c6fa81b83a83ee Author: Matt Wang Date: Wed Sep 30 07:14:59 2026 +0800 scsi: vmw_pvscsi: Add boundary check for cmd_map access The context value provided by the device in a completion is used to index into cmd_map to find the command that was completed. To prevent out of bounds access or completion of an inactive context, check that the context value is in-bounds and that it maps to an active context. Signed-off-by: Matt Wang Link: https://patch.msgid.link/20260929231459.630938-1-matt.wang@broadcom.com Fixes: 851b164231d1 ("[SCSI] vmw_pvscsi: SCSI driver for VMware's virtual HBA.") Signed-off-by: Martin K. Petersen (Oracle) commit b8d0bb6a8ba0d3878940a914a19336844101867b Author: Shao Mingyin Date: Mon Oct 26 19:52:45 2026 +0800 scsi: target: tcmu: Fix divide-by-zero in data_pages_per_blk store tcmu_set_data_pages_per_blk() only validates the upper bound of the value parsed from data_pages_per_blk=. Zero passes that check and is then used as the divisor when computing udev->max_blocks: divide error: 0000 [#1] SMP ... tcmu_set_data_pages_per_blk tcmu_configure_device Reject non-positive values, as the neighbouring max_data_area_mb and cmd_ring_size setters already do. Fixes: 08976cb548d6 ("scsi: target: tcmu: Make data_pages_per_blk changeable via configfs") Signed-off-by: Shao Mingyin Cc: stable@vger.kernel.org Reviewed-by: Bodo Stroesser Link: https://patch.msgid.link/20261026195245337ktSXy9G17VCcXyw760g9s@zte.com.cn Signed-off-by: Martin K. Petersen (Oracle) commit cdf4b87a18cb6a0ee26865cb1b7b5660a491d302 Author: Yuanhe Shu Date: Mon Oct 26 20:41:38 2026 +0800 scsi: target: Verify the iSCSI ISID is null-terminated iscsi_parse_pr_out_transport_id() returns the ISID of a FORMAT CODE 01b TransportID as a pointer into the PERSISTENT RESERVE OUT parameter list, lowercased in place and never null-terminated. spc4r37 Table 508 requires the field to be null-terminated, but a non-conforming initiator can omit the NULL; when the ISID ends at the end of the received buffer, the pointer is not a C string. The registration code still consumes it as one: strcmp() in __core_scsi3_locate_pr_reg() and in the REGISTER AND MOVE path, and snprintf("%s") in __core_scsi3_do_alloc_registration(), which also reads its first 8 bytes unconditionally with get_unaligned_be64() - a NUL check does not bound that read. When the parameter list spans more than one page, transport_kmap_data_sg() maps it with vmap(), and the over-read walks off the end of the mapping into the vmalloc() guard page and oopses. Reproduced with a PR OUT REGISTER + SPEC_I_PT parameter list of exactly 8192 bytes whose final TransportID carries a 12-byte ISID without a terminating NUL: BUG: unable to handle page fault for address: ffffc9000138c000 RIP: 0010:strcmp+0xc/0x30 Call Trace: __core_scsi3_locate_pr_reg+0xd3/0x120 [target_core_mod] core_scsi3_decode_spec_i_port+0x8fc/0x13a0 [target_core_mod] core_scsi3_emulate_pro_register+0x73c/0x900 [target_core_mod] ... iscsi_target_rx_thread+0xef/0x1d0 [iscsi_target_mod] With a single-page parameter list the buffer is a kmap() direct mapping, so the over-read continues into the physically adjacent page instead of faulting. snprintf("%s") then copies whatever follows the ISID in memory into pr_reg_isid, and PR IN READ FULL STATUS reports the registration back to any initiator, turning the over-read into an info leak of kernel heap contents. Reproduced with a 4096-byte parameter list whose last TransportID ends at the end of the buffer with a 4-byte ISID and no NUL, interleaved with I/O to populate adjacent pages: the READ FULL STATUS response returned the ISID as "0xleak" followed by raw bytes that were not part of the parameter list. The snprintf() into pr_reg_isid[PR_REG_ISID_LEN] caps the echoed ISID at 15 characters, so at most 11 bytes past the buffer are leaked per command, but the PR OUT command is not rate limited. Any initiator that can send PR OUT to an iSCSI-exported LUN can trigger either variant, including a guest via vhost-scsi. Require 8 bytes to remain after the ",i,0x" separator, and a NUL inside the rest of the descriptor, before the ISID pointer is returned. REGISTER AND MOVE fails with TCM_INVALID_PARAMETER_LIST; on SPEC_I_PT no target port claims the malformed TransportID, and the command fails the same way. Fixes: d04a179085c2 ("scsi: target: Bound PR-OUT TransportID parsing to the received buffer") Reported-by: kitta Reported-by: sashiko AI review Link: https://lore.kernel.org/r/sashiko-outbox-184760@kernel.org/ Cc: stable@vger.kernel.org Cc: Bryam Vargas Cc: John Garry Assisted-by: LLM Signed-off-by: Yuanhe Shu Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6") Link: https://patch.msgid.link/20261026124138.2708365-1-xiangzao@linux.alibaba.com Signed-off-by: Martin K. Petersen (Oracle) commit ffb7b533a47906b96166eec4b7eaa4199b7a7462 Author: Yingjie Wang Date: Fri Oct 23 16:23:06 2026 +0000 scsi: bsg: Report io_uring data copyback failures scsi_bsg_uring_task_cb() discards the result of blk_rq_unmap_user(). For a data-in command that uses a bounce buffer, the task work can therefore post a CQE with res == 0 despite a copyback failure. Use the unmap result as the CQE status. A later sense-buffer copy failure continues to take precedence. On x86_64, a raw BSG INQUIRY into an unaligned anonymous PROT_NONE mapping posted a CQE with res == 0 in 20/20 runs before this change and res == -EFAULT in 20/20 runs afterward. Writable controls succeeded in 20/20 runs on both kernels. Fixes: 7b6d3255e7f8 ("scsi: bsg: add io_uring passthrough handler") Cc: stable@vger.kernel.org Signed-off-by: Yingjie Wang Reviewed-by: Yang Xiuwei Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/0b35d2d46bf8ff9f2dbba83ae093d17351e950e9.1792772194.git.x-professor@outlook.com Signed-off-by: Martin K. Petersen (Oracle) commit a52f2ad45726d788755b525adcf51f65a6b836ff Author: Yingjie Wang Date: Fri Oct 23 16:23:04 2026 +0000 scsi: bsg: Report synchronous data copyback failures scsi_bsg_sg_io_fn() ignores the result of blk_rq_unmap_user(). For a data-in command that uses a bounce buffer, unmapping copies the completed data to userspace. If that copy fails, SG_IO can report success despite the copyback failure. Capture the unmap status. Preserve an earlier sense-buffer copy error and otherwise return the data copyback error. This matches the error precedence used by scsi_complete_sghdr_rq(). On x86_64, a virtio-scsi INQUIRY with an unaligned PROT_NONE destination made ioctl() return 0 in 20/20 runs before this change and return -1 with errno EFAULT in 20/20 runs afterward. Writable controls succeeded in 20/20 runs on both kernels. Fixes: 10e8855b9451 ("bsg: add SG_IO to SG v4") Cc: stable@vger.kernel.org Signed-off-by: Yingjie Wang Reviewed-by: Yang Xiuwei Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/2561d633cc8cef513d75eb1df260046a4971e783.1792772194.git.x-professor@outlook.com Signed-off-by: Martin K. Petersen (Oracle) commit 5d5913710c81eed6fa275b6a24773059d9dbfdfa Author: Jia Jia Date: Wed Oct 21 17:43:34 2026 +0800 scsi: target: Validate REGISTER AND MOVE TransportID length REGISTER AND MOVE has a 24-byte parameter-list header followed by a TransportID. A 24-byte parameter list with a zero TransportID length passes the existing tid_len + 24 check, then the handler reads buf[24] for the TransportID protocol identifier, one byte past the received parameter list. A TransportID is at least 24 bytes. Reject shorter TransportIDs and compare the declared length with the bytes following the header before reading buf[24]. A malformed PR OUT sent through vhost-scsi triggered this read on a KASAN kernel. The command is now rejected with INVALID PARAMETER LIST before buf[24] is accessed. Fixes: c66ac9db8d4a ("[SCSI] target: Add LIO target core v4.0.0-rc6") Signed-off-by: Jia Jia Link: https://patch.msgid.link/20261021094334.198599-1-physicalmtea@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit d58e6d962e5b59297be24d908f41af93f20ec11f Author: Vincent YUE Date: Wed Oct 21 07:08:56 2026 +1000 scsi: mpt3sas: Register devices during SANITIZE A SAS disk being sanitized responds to TEST UNIT READY with NOT READY, ASC 0x04, ASCQ 0x1b. mpt3sas discovery maps this sense to DEVICE_START_UNIT and issues START UNIT repeatedly. The drive stays NOT READY until the sanitize operation completes, causing discovery to exhaust its retry budget and decline SCSI device registration. Allow registration only for the SANITIZE IN PROGRESS sense, so sd/sg can expose the target while retaining its actual NOT READY state. All other sense dispositions are unchanged. On an LSI SAS3008 with an HGST HUH728080AL4200, unpatched Linux 7.2.11 retried discovery 145 times without registering the device. Linux 6.18.55 registered the same sanitizing drive. With the equivalent 7.2.11 fix the disk registered as /dev/sda (0 B) and /dev/sg0 while TEST UNIT READY still reported 02/04/1b and 47.32% SANITIZE progress. Another SAS drive continued to enumerate. This updated variant uses the named 0x041b sense constant introduced in newer kernels. It passed static review on the current SCSI for-next branch but has not been independently boot-tested there. Fixes: aee682fad6cd ("scsi: mpt3sas: Improve device discovery and readiness handling for slow devices") Assisted-by: LLM Signed-off-by: Vincent YUE Link: https://patch.msgid.link/20261020210856.42835-1-vince@palmit.com.au Reviewed-by: Laurence Oberman Signed-off-by: Martin K. Petersen (Oracle) commit 503e6172fa74da6b4944ece458f5534681e51d21 Author: Adrián García Casado Date: Tue Oct 20 21:59:34 2026 +0200 scsi: libsas: Add __printf attribute to sas_ata_printk() sas_ata_printk() formats its variadic arguments via struct va_format and %pV before passing them to printk(). Because %pV hides the format string from the compiler, GCC does not suggest the format attribute under -Wsuggest-attribute=format, and callers do not get compile-time format string validation. Add the __printf(3, 4) attribute to sas_ata_printk() to enable compile-time format string checking for its callers. Signed-off-by: Adrián García Casado Reviewed-by: John Garry Link: https://patch.msgid.link/20261020195934.250768-1-adriangarciacasado42@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit 6a6e7d7230cd4e0a6c003bae5b85bf37a1e77b94 Author: Yu Zhang Date: Wed Oct 14 11:37:46 2026 +1000 scsi: target: Fix demo-mode dynamic ACL dev-entry UAF vs LUN teardown A demo-mode (generate_node_acls=1) login that allocates a dynamic NodeACL populates that ACL's per-LUN dev entries in core_tpg_add_node_to_devs() *before* the ACL is linked onto tpg->acl_node_list by target_add_node_acl(): core_tpg_check_initiator_node_acl(): ... core_tpg_add_node_to_devs(acl, tpg, NULL); /* builds deves */ target_add_node_acl(acl); /* only now listed */ The LUN teardown sweep, core_clear_lun_from_tpg(), enumerates only tpg->acl_node_list, so a dev entry whose ACL is still in the window above is invisible to the sweep and is never disabled. It is left on the se_lun->lun_deve_list after core_tpg_remove_lun() frees the se_lun; when the same unpacked_lun is later re-added and the se_lun is reallocated at the same address, the stale dev entry is rediscovered by target_nacl_find_deve() and core_enable_device_list_for_node() corrupts lun_deve_list: BUG: KASAN: slab-use-after-free ... core_enable_device_list_for_node+0x5ce/0x880 core_tpg_add_node_to_devs+0x169/0x190 core_dev_add_lun+0x146/0x190 target_fabric_port_link+0xe9/0x1b0 configfs_symlink+0x381/0xae0 __x64_sys_symlink+0x55/0x80 The demo-mode login path that drives the ACL/dev-entry creation is reachable by an unauthenticated initiator; the colliding LUN add/remove is a local configfs operation. Commit 49cb77e297dc ("target: Avoid mappedlun symlink creation during lun shutdown") introduced se_lun->lun_shutdown and guarded the *explicit* ACL MappedLUN path (target_fabric_mappedlun_link()), but the demo-mode automatic path, core_tpg_add_node_to_devs() -> core_enable_device_list_for_node(), was never given the equivalent guard, and the publish-after-populate ordering in core_tpg_check_initiator_node_acl() was left unchanged. Fix it in three cooperating parts: 1) Publish the dynamic NodeACL onto acl_node_list *before* creating its dev entries, so the teardown sweep can observe them. 2) Refuse to attach a dev entry to an se_lun that is shutting down, checked under nacl->lun_entry_mutex -- the same lock the sweep takes -- so once the sweep has passed an ACL any later enable for that LUN observes lun_shutdown and skips it. 3) In core_enable_device_list_for_node(), insert the new dev entry onto lun->lun_deve_list while still holding nacl->lun_entry_mutex, in both the replace and the new-entry branch. Previously the entry was added to nacl->lun_entry_hlist under the mutex but to lun->lun_deve_list only after dropping it; with the ACL now published early, the sweep could take the mutex in that gap, find the entry on the hlist, core_disable_device_list_for_node() it (list_del() on the not-yet- linked lun_link succeeds and the entry is freed), and then the enable would list_add_tail() the freed entry back onto lun_deve_list. Linking both lists under the mutex makes enable and the sweep mutually exclusive, closing that window. core_tpg_add_node_to_devs() already ignores the return value of core_enable_device_list_for_node(), so a shutting-down LUN is simply skipped. Cc: stable@vger.kernel.org Fixes: 49cb77e297dc ("target: Avoid mappedlun symlink creation during lun shutdown") Signed-off-by: Yu Zhang Tested-by: Yu Zhang Link: https://patch.msgid.link/20261014013746.46705-1-yuz08559@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit 9ec6671b137de06f0345962fb8091466b7d56a96 Author: Matthew Whitehead Date: Tue Sep 29 10:45:28 2026 -0400 scsi: aha1542: Remove unneeded scsi_dma_unmap() call aha1542 never DMA maps the command's scatterlist. Data is bounced through a per-command buffer allocated with dma_alloc_coherent() in aha1542_init_cmd_priv(), the adapter is programmed with acmd->data_buffer_handle, and the payload is copied to and from the request segments in aha1542_queuecommand() and aha1542_free_cmd(). The scsi_dma_unmap() call left in aha1542_free_cmd() therefore unmaps a scatterlist that was never mapped. With CONFIG_DMA_API_DEBUG enabled this results in: device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=0 bytes] Remove the call. Verified by testing on real hardware. Fixes: 2f2fef022c3e ("aha1542: use a local bounce buffer") Suggested-by: Laurence Oberman Assisted-by: LLM Signed-off-by: Matthew Whitehead Reviewed-by: Laurence Oberman Link: https://patch.msgid.link/20260929144528.7061-1-tedheadster@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit ba80a742b3e184b1af8f1ce636105e67f7cedb14 Author: Bart Van Assche Date: Fri Sep 25 11:25:43 2026 -0700 scsi: BusLogic: Prepare for enabling lock context analysis Document locking requirements with __must_hold() annotations to prepare the BusLogic driver for enabling compiler-based lock context analysis. Cc: Khalid Aziz Signed-off-by: Bart Van Assche Acked-by: Khalid Aziz Link: https://patch.msgid.link/abe0bc09b63eb55f278a883b65b881b94ce1c31b.1790360262.git.bvanassche@acm.org Signed-off-by: Martin K. Petersen (Oracle) commit b54bd8da110dd9efb058d68b04b50d9341f9f090 Author: Bart Van Assche Date: Fri Sep 25 11:25:42 2026 -0700 scsi: BusLogic: Pass the host pointer directly to several functions Pass the struct Scsi_Host pointer directly to multiple functions. This prepares the BusLogic driver for enabling compiler-based lock context analysis. No functionality has been changed. Cc: Khalid Aziz Signed-off-by: Bart Van Assche Acked-by: Khalid Aziz Link: https://patch.msgid.link/09e99ec9c6fa24ee5fe3c47110c88a1be076e01a.1790360262.git.bvanassche@acm.org Signed-off-by: Martin K. Petersen (Oracle) commit 6b2ff2b3eafa381db9b4c8a6ed98b353b2a09f39 Author: HOYOUNG SEO Date: Tue Oct 27 20:03:57 2026 +0900 scsi: ufs: core: Change the error check sequence for auto hibern8 Auto-hibern8 enter and exit are performed by the host controller without a UIC command, and the auto-hibern8 idle timer only runs while no UIC command is outstanding. An auto-hibern8 error (IS.UHES or IS.UHXS) is therefore usually reported while hba->active_uic_cmd is NULL. Since commit fcd8b0450a9a ("scsi: ufs: core: Make ufshcd_uic_cmd_compl() easier to analyze"), ufshcd_uic_cmd_compl() returns early when hba->active_uic_cmd is NULL, before ufshcd_is_auto_hibern8_error() is called. Such auto-hibern8 errors are no longer recorded in hba->errors, so ufshcd_check_errors() is not called for them and the error handler is not scheduled. Check for auto-hibern8 errors before checking for an active UIC command, as was done before that commit, but keep returning early when there is no active UIC command so that a NULL cmd is never dereferenced. Only report the missing UIC command if no auto-hibern8 error was found. Fixes: fcd8b0450a9a ("scsi: ufs: core: Make ufshcd_uic_cmd_compl() easier to analyze") Cc: stable@vger.kernel.org # v6.13+ Signed-off-by: HOYOUNG SEO Reviewed-by: Stanley Jhu Reviewed-by: Bean Huo Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/20261027110357.3649301-1-hy50.seo@samsung.com Signed-off-by: Martin K. Petersen (Oracle) commit 8a832fb632da303cdf0704e0d56722ec47799f19 Author: Giuseppe Piscitelli Date: Tue Oct 27 11:08:50 2026 +0100 scsi: core: Balance the pseudo target reap reference With memory allocation profiling enabled, unloading scsi_debug reports allocations left at module unload. A stock Linux 7.2.11 VM without OpenZFS emitted the following on each of three load/unload cycles: [ 1.644665] drivers/scsi/scsi_debug.c:8863 module scsi_debug func:sdebug_add_host_helper has 1024 allocated at module unload [ 1.656260] drivers/scsi/scsi_debug.c:1261 module scsi_debug func:sdebug_target_alloc has 16 allocated at module unload scsi_alloc_target() supplies a reap reference for its caller. The SCSI device initializer takes another reference, which device removal drops. scsi_get_pseudo_sdev() drops its caller reference only when device allocation fails. On success the target cannot be destroyed, retaining its driver-private data and its parent host and adapter. Drop the caller reference in the common cleanup path, as the other scsi_alloc_target() callers do. Fixes: d630fbf6fc8c ("scsi: core: Support allocating a pseudo SCSI device") Signed-off-by: Giuseppe Piscitelli Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/20261027100859.1031135-1-ooonea@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit 34c99ce2993971712d89010a948d2f650687b796 Author: Giuseppe Piscitelli Date: Mon Oct 26 21:23:41 2026 +0100 scsi: scsi_debug: Drain target cleanup before module exit Target destruction queues cleanup in an exclusive async domain. The module loader's async_synchronize_full() does not wait for exclusive domains. Wait for target cleanup after removing the hosts and before removing the debugfs root and returning from module exit. Fixes: b402a0dce64a ("scsi: scsi_debug: Fix create target debugfs failure") Signed-off-by: Giuseppe Piscitelli Link: https://patch.msgid.link/20261026202342.668361-1-ooonea@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit f057a8bfeb6ff89c65e95540b8700a53c66d4a31 Author: Andrew Luebke Date: Mon Oct 26 10:20:32 2026 -0700 scsi: aic79xx: Fix NULL pointer dereference in device reset Since commit c67e63800446 ("scsi: aic79xx: Do not reference SCSI command when resetting device") the device reset SCB has no SCSI command, but ahd_linux_dev_reset() still sets its residual, and ahd_abort_scbs(), which completes it, sets its status. Seen on an AIC-7902 when a failing disk triggered a device reset, which killed the SCSI error handler: BUG: kernel NULL pointer dereference, address: 0000009c EIP: ahd_linux_dev_reset.cold+0xee/0x26e Add NULL command checks to the accessors in aic79xx_osm.h. Also skip autosense for an SCB without a command and complete it with ahd_done() right away: the REQUEST SENSE path can clear SCB_DEVICE_RESET, after which ahd_done() would dereference the missing command. Fixes: c67e63800446 ("scsi: aic79xx: Do not reference SCSI command when resetting device") Cc: stable@vger.kernel.org Reviewed-by: Hannes Reinecke Signed-off-by: Andrew Luebke Assisted-by: LLM Link: https://patch.msgid.link/20261026172032.749756-1-andrew.luebke@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit 696bdfc58975fbc70d2e2347a74e0b562e7e2494 Author: Imre Kaloz Date: Mon Oct 26 14:14:32 2026 +0100 scsi: aic7xxx: Use default settings on the SGI O2 onboard controllers The SGI O2 firmware runs its onboard aic7880s without the Adaptec BIOS, so scratch RAM holds no settings. The left over BIOS path reads uninitialised bytes, and bad parity panics the boot. Use the defaults there with host ID 0. ahc_init() keeps the default host ID ahc_pci_config() chose, 7 on other PCI controllers, so only the O2 changes. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Imre Kaloz Link: https://patch.msgid.link/20261026131432.26065-1-kaloz@kernel.org Signed-off-by: Martin K. Petersen (Oracle) commit 9a2690eb4bbea8d7fbc3dfe478fca75fe956abb4 Author: Imre Kaloz Date: Tue Oct 13 11:42:53 2026 +0200 scsi: aic7xxx: Fix REQUEST SENSE allocation length on big-endian hosts The REQUEST SENSE length was taken from sg->len after the AHC_DMA_LAST_SEG flag was or-ed in and the value converted to little-endian, so the 8-bit field is 0x80 on big-endian hosts and the target is asked for 128 bytes into a 32-byte buffer. Use the buffer size, as aic79xx does. On an SGI O2 with a Fujitsu MAX3147NC, the sense data of its CHECK CONDITIONs during probe was lost. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Imre Kaloz Link: https://patch.msgid.link/20261013094253.2956-1-kaloz@kernel.org Signed-off-by: Martin K. Petersen (Oracle)