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)