commit efd68f17acca65f581b9f2fa9ba50c8643ab544d Author: Weibin Liu Date: Thu Oct 29 15:33:16 2026 +0800 scsi: mpt3sas: Validate data_out size before SMP link-reset check _ctl_do_mpt_command() handles MPI2_FUNCTION_SMP_PASSTHROUGH by reading data[1] and data[10] of the data_out buffer to detect SMP link-reset requests. The non-IMMEDIATE path sets data = data_out after checking only for a NULL pointer, so a payload shorter than 11 bytes can read past the end of the buffer, and out-of-bounds bytes can unexpectedly set ioc_link_reset_in_progress and ignore_loginfos. However, a short SMP request is not invalid: SMP_REPORT_GENERAL, for example, can use an 8-byte payload. Rejecting every data_out smaller than 11 bytes would break valid requests. Instead, require enough data only when checking for a link reset, and keep sending the request normally otherwise. The IMMEDIATE path reads from the request frame rather than data_out, so data_out_sz does not apply to it. Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS") Cc: stable@vger.kernel.org # 3.8+ Reviewed-by: Guanglei Zhu Signed-off-by: Weibin Liu Link: https://patch.msgid.link/20261029073316.4188569-1-liuwb@xiaopeng.com Signed-off-by: Martin K. Petersen (Oracle) commit 71b5da0b45fb83b590f1ec3df5361c7754b0e113 Author: Xiangwu Lai Date: Thu Nov 19 15:16:10 2026 +0800 scsi: ufs-mediatek: Restore the M-PHY power state when va09 disable fails In ufs_mtk_mphy_power_on(), the power-off path tears the M-PHY down in two steps before regulator_disable() is called: phy_power_off() puts the PHY PLL and its clocks down, and ufs_mtk_va09_pwr_ctrl() asks the firmware to drop the VA09 supply. If regulator_disable() then fails, the M-PHY stays physically off while host->mphy_powered_on is left set, so the next power-on attempt bails out through the !(on ^ host->mphy_powered_on) check and never powers the M-PHY back up, leaving the UFS host with an unpowered PHY (I/O timeouts, controller lockups). Simply forcing mphy_powered_on to false would trade this for two more problems. First, the regulator core drops the consumer enable count only after a successful disable, so the count stays at 1, the next power-on raises it to 2 and it never returns to zero: va09 is then never physically disabled and the devm-acquired regulator would hit WARN_ON(enable_count) again on release. Second, when the power-off fails during ufs_mtk_suspend(), the error recovery in __ufshcd_wl_suspend() runs ufshcd_host_reset_and_restore() without powering the M-PHY back on, which would run against an unpowered PHY. (Both points were raised by the Sashiko AI review of v2.) Since the va09 regulator stays enabled when its disable fails, restore the M-PHY power state instead: power the PHY back on through ufs_mtk_va09_pwr_ctrl() and phy_power_on() and leave mphy_powered_on set. The next power-off attempt then retries the full sequence and the enable count stays balanced. Found by code inspection while reviewing the va09 error paths of the driver; the failure has not been observed on real hardware. Suggested-by: Peter Wang Link: https://lore.kernel.org/r/sashiko-outbox-220026@kernel.org Fixes: cf137b3ea49a ("scsi: ufs-mediatek: Support VA09 regulator operations") Signed-off-by: Xiangwu Lai Reviewed-by: Peter Wang Link: https://patch.msgid.link/20261119071611.117-3-laixiangwu@cmss.chinamobile.com Signed-off-by: Martin K. Petersen (Oracle) commit def1745a6a8bc44b39e8670c737c27fd38b3595c Author: Xiangwu Lai Date: Thu Nov 19 15:16:09 2026 +0800 scsi: ufs-mediatek: Use devm_regulator_get() for the va09 regulator ufs_mtk_init_va09_pwr_ctrl() obtains the va09 regulator with regulator_get() but the reference is never released with regulator_put(), neither on driver unbind nor on probe failure. The other regulators handled by this driver (dvfsrc-vcore) are already obtained with devm_regulator_get_optional(). Use devm_regulator_get() so that the reference is released automatically when the UFS device is detached. This alone is not enough, though: ufs_mtk_init() powers the M-PHY on, which enables the va09 regulator, and nothing powers it off again on the way out. The variant operations have no .exit callback and ufshcd_pltfrm_remove() only resumes the device. The devm release would then hit WARN_ON(regulator->enable_count) in _regulator_put() and leak the enable reference. Balance the use count by adding an .exit callback which powers the M-PHY off, in the same spirit as the .exit callbacks of ufs-exynos and ufs-qcom. ufshcd_hba_exit() invokes it both on driver unbind and on ufshcd_init() failure after the variant init, so the enable count is always balanced by the time devm releases the regulator. It relies on the state tracking in ufs_mtk_mphy_power_on() and is a no-op if the M-PHY was never powered on. Fixes: cf137b3ea49a ("scsi: ufs-mediatek: Support VA09 regulator operations") Reviewed-by: Peter Wang Signed-off-by: Xiangwu Lai Link: https://patch.msgid.link/20261119071611.117-2-laixiangwu@cmss.chinamobile.com Signed-off-by: Martin K. Petersen (Oracle) commit fb8fd1da808feef6af8686986fedcfe45c693dc8 Author: Ciro Iriarte Date: Mon Nov 9 11:31:01 2026 -0300 scsi: target: core: Compare all six ISID bytes when identifying a nexus lio_sess_get_initiator_sid() reports the ISID as twelve hex digits, and iSCSI TransportIDs carry the same digits. __transport_register_session(), __core_scsi3_do_alloc_registration() and core_scsi3_alloc_aptpl_registration() turn that text into sess_bin_isid and pr_reg_bin_isid with get_unaligned_be64(), which takes the first eight characters, i.e. the first four ISID bytes. open-iscsi ISIDs start with 00023d00 and differ only in the qualifier in the last two bytes, so every session of one initiator gets the same binary ISID. target_scsi2_reservation_check() and target_scsi3_pr_reservation_check() then treat any session of the reservation holder's initiator as the holder: - after RESERVE(6) on one session, another session of the same initiator can still write; - with a Write Exclusive persistent reservation, another session that is not registered, or registered but not the holder, can still write. Reproduced with two open-iscsi sessions (ifaces default and if2) to a ramdisk LUN: on v6.12.113 every TEST UNIT READY, READ(10) and WRITE(10) the test sent from the second session completed with GOOD, under RESERVE(6) and under each persistent reservation type, whether or not that session was registered. Convert all six bytes. Text that is not exactly twelve hex digits keeps the old conversion of its first eight characters, now copied into a zeroed buffer so that a shorter string, such as an initiator_sid written to res_aptpl_metadata, is not read past its end. An all-zero ISID now converts to 0, which target_scsi2_reservation_reserve() took to mean "no ISID". Set DRF_SPC2_RESERVATIONS_WITH_ISID when the fabric reports ISIDs instead. Also update the TransportID parser comment that referred to the get_unaligned_be64() read. With distinct ISIDs, target_scsi3_pr_reservation_check() now sets isid_mismatch for the holder initiator's other sessions, and core_scsi3_pr_seq_non_holder() treated every such session as unregistered: DEF_PR_REG_ACTIVE is kept per se_dev_entry, which all sessions of the initiator share, so it cannot tell them apart. A session that registered its own key would then get RESERVATION CONFLICT for writes under a Registrants Only or All Registrants reservation, and for PREEMPT, CLEAR and RELEASE. Look up that session's own registration with core_scsi3_locate_pr_reg() instead. With this patch, TEST UNIT READY and WRITE(10) from the second session under RESERVE(6) return RESERVATION CONFLICT. Under Write Exclusive, WRITE(10) from the second session conflicts whether or not it is registered, and READ(10) is allowed. Under the Registrants Only and All Registrants types, WRITE(10) from the second session conflicts until it registers, as does READ(10) under the Exclusive Access types; once registered it has access and can PREEMPT the holder. Initiators that relied on the old behaviour, reserving through one session and writing through another without registering it, will now see RESERVATION CONFLICT, as SPC requires. 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/8b1ac7d9-b0e4-42ac-b8a2-c4c70cccdddc@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit 6b745a4ae88a38871421eef2fd995cd308abce0a Author: yong liu Date: Wed Nov 11 11:05:43 2026 +0800 scsi: target: core: Disable protection processing for zero-block transfers A READ(10) with its TRANSFER LENGTH field set to zero on a PI-enabled LUN can select TARGET_PROT_DIN_STRIP while leaving cmd->prot_length at zero. transport_generic_new_cmd() then allocates an empty protection scatterlist, causing a target-side Oops, which can also lead to use-after-free during subsequent iSCSI connection cleanup. A logged-in iSCSI initiator can trigger this on a FILEIO LUN with protection information enabled. After validating PROTECT, reset the protection operation, type and checks for zero-block commands in sbc_check_prot(). This avoids the empty allocation and prevents backends and fabrics from selecting PI processing without a protection payload. Preserve the existing data-length adjustment for commands carrying PI over the wire. The issue was discovered and fixed by Qihoo 360's Tulongfeng multi-agent system. Fixes: 5835812f13e5 ("target: ensure se_cmd->t_prot_sg is allocated when required") Cc: stable@vger.kernel.org Signed-off-by: yong liu Link: https://patch.msgid.link/20261111030544.1216434-1-pkfxxxing@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit b30d7199af282be0a0db7f92fd8916a8ffa3d3aa Author: Yehyeong Lee Date: Wed Nov 18 06:13:46 2026 +0900 scsi: target: iscsi: Run the Time2Retain handler in process context iscsit_handle_time2retain_timeout() is a timer callback, so it runs in timer softirq context, and from there it closes the session: iscsit_handle_time2retain_timeout() <- timer softirq iscsit_close_session(sess, false) transport_deregister_session() target_for_each_device(target_release_res, se_sess) mutex_lock(&device_mutex) transport_deregister_session() has walked the device list under device_mutex since commit 80647a89eaf3f2 ("scsi: target: core: Release SPC-2 reservations when closing a session"). The can_sleep argument that the handler passes as false only guards iscsit_check_session_usage_count(); the transport_deregister_session() call below it runs either way. The callback also takes se_tpg->session_lock in softirq context, and it is the only code that does, which makes that lock SOFTIRQ-safe. iscsit_start_time2retain_handler() takes tpg->tpg_state_lock with plain spin_lock() under it, so lockdep reports an inversion as well. Both the softirq acquisition and the plain spin_lock() are as old as the driver, commit e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1"). An initiator needs nothing but a session to get there: log in, then send a Logout with reason CLOSE_CONNECTION. iscsit_close_connection() leaves session_fall_back_to_erl0 clear for a Logout, so instead of closing the session it arms the Time2Retain handler, which runs DefaultTime2Retain seconds later because the session is never resumed. Three such logouts on a KASAN + PROVE_LOCKING + DEBUG_ATOMIC_SLEEP guest give three of these: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:623 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/0 preempt_count: 101, expected: 0 RCU nest depth: 0, expected: 0 INFO: lockdep is turned off. CPU: 0 UID: 0 PID: 0 Comm: swapper/0 Not tainted 7.4.0-rc2-00563-g97d73c825122 #1 PREEMPT(lazy) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 Call Trace: dump_stack_lvl+0x80/0xa0 __might_resched+0x31c/0x520 ? __pfx___might_resched+0x10/0x10 __mutex_lock+0x10e/0x24e0 ? target_for_each_device+0x6c/0xc0 ? __irq_work_queue_local+0x18e/0x370 ? __pfx___irq_work_queue_local+0x10/0x10 ? lock_acquire+0x2c8/0x300 ? __pfx___mutex_lock+0x10/0x10 ? lock_release+0x1de/0x280 ? vprintk_emit+0x2dd/0x3d0 ? __pfx_vprintk_emit+0x10/0x10 ? target_for_each_device+0x6c/0xc0 target_for_each_device+0x6c/0xc0 ? __pfx_target_for_each_device+0x10/0x10 ? __pfx_target_release_res+0x10/0x10 ? trace_hardirqs_on+0x18/0x160 transport_deregister_session+0x19c/0x250 ? iscsit_check_session_usage_count+0xa4/0xd0 ? __local_bh_enable_ip+0xa7/0x120 iscsit_close_session+0x20c/0x540 ? __pfx_iscsit_handle_time2retain_timeout+0x10/0x10 call_timer_fn+0x15a/0x4b0 ? __pfx_call_timer_fn+0x10/0x10 ? lock_acquire+0x18d/0x300 ? __run_timer_base.part.0+0x5d4/0x930 ? lock_release+0xc6/0x280 ? timer_recalc_next_expiry+0x6e/0x210 ? lockdep_hardirqs_on_prepare+0xa9/0x190 ? __pfx_iscsit_handle_time2retain_timeout+0x10/0x10 __run_timer_base.part.0+0x5e3/0x930 ? __pfx___run_timer_base.part.0+0x10/0x10 ? __lock_acquire+0x570/0x1b00 ? find_held_lock+0x2b/0x80 ? clockevents_program_event+0x1b8/0x860 ? lock_release+0xc6/0x280 run_timer_softirq+0x12c/0x210 ? __pfx_run_timer_softirq+0x10/0x10 ? lock_acquire+0x18d/0x300 ? lockdep_hardirqs_on_prepare+0xa9/0x190 handle_softirqs+0x1ff/0x8e0 ? __irq_exit_rcu+0x1b8/0x1e0 ? __pfx_handle_softirqs+0x10/0x10 __irq_exit_rcu+0x153/0x1e0 irq_exit_rcu+0x9/0x20 sysvec_apic_timer_interrupt+0x6b/0x80 and, once per boot, this: WARNING: possible irq lock inversion dependency detected 7.4.0-rc2-00563-g97d73c825122 #1 Not tainted -------------------------------------------------------- swapper/0/0 just changed the state of lock: ffff88800ec7c148 (&se_tpg->session_lock){+.-.}-{3:3}, at: iscsit_handle_time2retain_timeout+0x46/0x1a0 but this lock took another, SOFTIRQ-unsafe lock in the past: (&tpg->tpg_state_lock){+.+.}-{3:3} and interrupts could create inverse lock ordering between them. other info that might help us debug this: Chain exists of: &se_tpg->session_lock --> &sess->conn_lock --> &tpg->tpg_state_lock Keep the timer and move only its body into a work item, so that nothing in iscsi_target takes se_tpg->session_lock in softirq context any more and the invalid sleep goes away with the inversion. Arming and stopping do not change: mod_timer() queues on the timer base of the CPU that arms it, which a caller holding a spinlock with softirqs disabled cannot let expire under itself, and iscsit_stop_time2retain_timer() still ends in timer_delete_sync(). What a stop can no longer wait for is the work. Every caller holds se_tpg->session_lock with softirqs disabled, so it must not sleep in cancel_work_sync(), and a work that has started but not yet taken that lock would outlive the stop: ISCSI_TF_STOP does not hold it back, because a later iscsit_start_time2retain_handler() clears the flag again and the work would then close a session that has been resumed. So the expiry itself is handed over. The timer sets ->time2retain_fired, the work takes it back under se_tpg->session_lock and returns without it, and a stop clears it. Only an expiry that no stop has overtaken closes a session. iscsit_close_session() must leave neither behind. The stop above can return before deleting the timer - on ISCSI_TF_EXPIRED it is the work itself that is closing the session - so delete it there, which also waits for a callback that has set the flag but not yet queued the work. Then cancel the work: wait for it where this may sleep; where it may not, it is that work, and because a work never runs twice at once the only one it can have is queued, which a non-sync cancel drops. What the restart in iscsit_close_session() does when a session usage count is held is unchanged and still wrong: iscsit_start_time2retain_handler() returns without arming anything because ISCSI_TF_RUNNING is still set. Waiting for the count instead is not an answer either, because the thread that closes the session waits on the same single completion. Fixes: e48354ce078c ("iscsi-target: Add iSCSI fabric support for target v4.1") Fixes: 80647a89eaf3 ("scsi: target: core: Release SPC-2 reservations when closing a session") Cc: stable@vger.kernel.org Signed-off-by: Yehyeong Lee Link: https://patch.msgid.link/20261117211346.2132827-1-yhlee@isslab.korea.ac.kr Signed-off-by: Martin K. Petersen (Oracle) commit 14bc5d239dddb3ce1264de74b8460c0a61745563 Author: Louis Sautier Date: Wed Nov 18 21:13:16 2026 +0100 scsi: mpt3sas: Fix out-of-bounds cpu_msix_table read on CPU hotplug mpt3sas_base_attach() allocates cpu_msix_table based on the highest CPU online at probe time, but _base_get_msix_index() indexes it with raw_smp_processor_id() without a bounds check. Once a CPU with a higher id comes online, I/O submitted from it causes an out-of-bounds read of the table. The value read is sent to the firmware as the reply queue index. When it is not a valid queue, the IOC faults and I/O fails. On a SAS3224 (FW 16.00.01.00) running v7.4-rc3 with KASAN, booted with maxcpus=1 and CPUs 1-95 onlined later, read-only fio pinned to each CPU in turn triggers, on CPU 1: BUG: KASAN: slab-out-of-bounds in _base_get_msix_index+0x1de/0x230 [mpt3sas] Read of size 1 at addr ffff88812fdf51c1 by task kworker/1:1H/1528 and, on CPU 16: mpt3sas_cm0: fault_state(0x1500)! mpt3sas_cm0: sending diag reset !! I/O error, dev sda, sector 3873068048 op 0x0:(READ) flags 0x800000 phys_seg 1 prio class 2 mpt3sas_cm0: removing unresponding devices: start sd 0:0:0:0: [sda] Synchronizing SCSI cache Allocate the table based on nr_cpu_ids instead, and map every CPU in each reply queue's affinity mask, including offline ones. Managed IRQ affinity already spreads the vectors over all possible CPUs, so a CPU onlined later uses the queue whose affinity mask contains it. The online-mask restriction and the bounds check added by commit 4a8842de8db4 ("scsi: mpt3sas: fix an out of bound write") are no longer needed, since the table now has an entry for every possible CPU. When smp_affinity_enable=0 or a reply queue has no affinity mask, the fallback path still sets only the entries of the CPUs online at probe time. A CPU onlined later then reads 0 from the zeroed table, and queue 0 is always a valid queue. With the change, the same fio test runs without errors, also while CPUs 1-95 are taken offline and back online in a loop. With maxcpus=12 (12 reply queues), I/O from each of the 96 CPUs completes on the vector whose affinity mask contains that CPU. Fixes: f92363d12359 ("[SCSI] mpt3sas: add new driver supporting 12GB SAS") Cc: stable@vger.kernel.org Signed-off-by: Louis Sautier Link: https://patch.msgid.link/20261118201316.326943-1-sautier.louis@gmail.com Signed-off-by: Martin K. Petersen (Oracle) commit 3ad578b22f7a34a2391ca8910dfc931b01cc94f6 Author: Terrence Adams Date: Wed Nov 18 10:03:44 2026 -0800 scsi: pm8001: Offset hardware queue index for MSI-X pre-vector When MSI-X interrupt vectors are configured in pm8001_setup_msix(), the driver requests vector affinity with .pre_vectors = 1 to reserve Vector 0 for non-affinitized housekeeping interrupts. blk_mq_map_hw_queues() maps hardware queues (hwq 0 to nr_hw_queues - 1) with an offset of 1, mapping hwq 0 to Vector 1, hwq 1 to Vector 2, etc. However, pm80xx_chip_get_q_index() retrieves the queue index directly from blk_mq_unique_tag_to_hwq(tag) without adding 1 for the pre-vector offset. Consequently, commands on hwq 0 are issued with responseQueue 0 (firing unmanaged Vector 0 on CPU 0), while hwq k fires Vector k (the CPU affinitized to hwq k-1). This results in 100% of I/O completion interrupts being delivered to the wrong CPU core, causing heavy cross-CPU IPIs, cache line bouncing, and increased kernel and IRQ CPU processing overhead. Define PM8001_PRE_VECTORS for the reserved housekeeping vector and use it consistently across MSI-X vector allocation, hardware queue setup and mapping, and queue index lookup. Update pm80xx_chip_get_q_index() to accept pm8001_ha and add PM8001_PRE_VECTORS to blk_mq_unique_tag_to_hwq() whenever multi-queue is enabled (number_of_intr > PM8001_PRE_VECTORS), routing completion interrupts to their affinitized CPU cores. Note that offsetting completions by PM8001_PRE_VECTORS routes the highest hardware queue to outbound queue max_q_num - 1, which pm80xx_chip_init() also programs as the fatal error interrupt vector. As a result, process_oq() now reads MSGU_SCRATCH_PAD_1 (and MSGU_SCRATCH_PAD_RSVD_0 when no fatal error is reported) on every interrupt for that queue, matching the behavior before commit 42f22fe36d51 ("scsi: pm8001: Expose hardware queues for pm80xx"). Fixes: 42f22fe36d51 ("scsi: pm8001: Expose hardware queues for pm80xx") Signed-off-by: Terrence Adams Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/20261118180344.1159617-1-tadamsjr@google.com Signed-off-by: Martin K. Petersen (Oracle) 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)