linux/drivers/target
Bryam Vargas fda6a1f3c3 scsi: target: core: Fix iSCSI ISID use-after-free in REGISTER AND MOVE
core_scsi3_emulate_pro_register_and_move() maps the PERSISTENT RESERVE OUT
parameter list with transport_kmap_data_sg() and parses the destination
TransportID with target_parse_pr_out_transport_id(). For an iSCSI
TransportID (FORMAT CODE 01b), iscsi_parse_pr_out_transport_id() returns
the ISID in iport_ptr as a raw pointer into that mapped buffer.

The function then unmaps the buffer with transport_kunmap_data_sg() before
dereferencing iport_ptr in strcmp(), __core_scsi3_locate_pr_reg() and
core_scsi3_alloc_registration(). When the parameter list spans more than
one page (PARAMETER LIST LENGTH > 4096), transport_kmap_data_sg() uses
vmap() and transport_kunmap_data_sg() does vunmap(), so the kernel virtual
address backing iport_ptr is torn down and every subsequent dereference is
a use-after-free read of the unmapped region.

Keep the parameter list mapped until iport_ptr is no longer needed: drop
the early transport_kunmap_data_sg() and unmap once on the success path,
right before returning. The error paths already unmap through the existing
"if (buf) transport_kunmap_data_sg(cmd)" at the out: label, which now runs
on every post-map error exit because buf is no longer cleared early. Only
reads of the mapping happen while spinlocks are held; the map and unmap
calls remain outside any lock. The sibling caller
core_scsi3_decode_spec_i_port() already uses the buffer before unmapping it
and is left unchanged.

Fixes: 4949314c72 ("target: Allow control CDBs with data > 1 page")
Cc: stable@vger.kernel.org
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Link: https://patch.msgid.link/20260610042245.35473-1-hexlabsecurity@proton.me
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2026-07-12 22:21:22 -04:00
..
iscsi scsi: target: Use constant-time crypto_memneq() for CHAP digests 2026-06-08 17:20:33 -04:00
loopback Merge branch 7.1/scsi-fixes into 7.2/scsi-staging 2026-06-15 21:01:30 -04:00
sbp scsi: target: Use driver completion preference by default 2026-02-28 21:04:02 -05:00
tcm_fc scsi: target: Use driver completion preference by default 2026-02-28 21:04:02 -05:00
tcm_remote Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
Kconfig
Makefile
target_core_alua.c
target_core_alua.h
target_core_configfs.c scsi: target: configfs: Bound snprintf() return in tg_pt_gp_members_show() 2026-04-13 22:43:56 -04:00
target_core_device.c scsi: target: core: Fix complete_type use 2026-03-10 21:32:01 -04:00
target_core_fabric_configfs.c scsi: target: Allow userspace to set the completion type 2026-02-28 21:04:03 -05:00
target_core_fabric_lib.c scsi: target: Bound PR-OUT TransportID parsing to the received buffer 2026-07-12 22:21:22 -04:00
target_core_file.c for-7.1/block-20260411 2026-04-13 15:51:31 -07:00
target_core_file.h
target_core_hba.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
target_core_iblock.c block: remove bdev_nonrot() 2026-03-09 14:30:00 -06:00
target_core_iblock.h
target_core_internal.h scsi: target: Bound PR-OUT TransportID parsing to the received buffer 2026-07-12 22:21:22 -04:00
target_core_pr.c scsi: target: core: Fix iSCSI ISID use-after-free in REGISTER AND MOVE 2026-07-12 22:21:22 -04:00
target_core_pr.h
target_core_pscsi.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
target_core_pscsi.h
target_core_rd.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
target_core_rd.h
target_core_sbc.c scsi: target: core: Fix integer overflow in UNMAP bounds check 2026-03-10 21:56:39 -04:00
target_core_spc.c SCSI misc on 20260212 2026-02-12 15:43:02 -08:00
target_core_stat.c scsi: target: Move LUN stats to per-CPU 2025-11-02 22:06:12 -05:00
target_core_tmr.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
target_core_tpg.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
target_core_transport.c scsi: target: Replace strncpy() with strscpy() in VPD dump functions 2026-03-27 16:32:44 -04:00
target_core_ua.c
target_core_ua.h
target_core_user.c uio: replace deprecated mmap hook with mmap_prepare in uio_info 2026-04-05 13:53:44 -07:00
target_core_xcopy.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
target_core_xcopy.h