linux/drivers/target
Sujal Tuladhar f4825922d2 scsi: target: iscsi: Reserve a terminator byte for the login payload
iscsi_target_check_login_request() rejects a login PDU whose
DataSegmentLength exceeds MAX_KEY_VALUE_PAIRS, but the test is '>' and
login->req_buf is allocated with exactly MAX_KEY_VALUE_PAIRS
bytes. Since iscsit_get_login_rx() receives payload_length + padding
bytes, where

	padding = ((-payload_length) & 3);

any payload_length from 8189 to 8192 fills the whole 8192 byte
buffer. The write stays in bounds, but no byte is left for a NUL
terminator.

The buffer is subsequently consumed as a C string. In the CHAP path
chap_check_algorithm() calls kstrdup(a_str), and extract_param() calls
strstr(in_buf, pattern) followed by strlen_semi(), none of which take a
length. convert_null_to_semi() additionally rewrites every embedded NUL
to ';', so even a payload made of well formed NUL separated key=value
records is left without a terminator. These walk past the end of the
object into adjacent slab memory. It is reachable by an unauthenticated
initiator against a portal configured for CHAP; when authentication is
not required iscsi_login_zero_tsih_s2() rewrites AuthMethod to None and
the CHAP path is never entered.

Allocate one extra byte. kzalloc() zeroes it and nothing ever writes to
it, as every writer copies to offset 0 for at most MAX_KEY_VALUE_PAIRS
bytes, so the buffer is always terminated.

Fixes: e48354ce07 ("iscsi-target: Add iSCSI fabric support for target v4.1")
Assisted-by: Claude Opus5 (custom harness)
Cc: stable@vger.kernel.org
Signed-off-by: Sujal Tuladhar <sujaltuladhar1231@gmail.com>
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
2026-09-01 22:08:31 -04:00
..
iscsi scsi: target: iscsi: Reserve a terminator byte for the login payload 2026-09-01 22:08:31 -04:00
loopback Merge branch 7.1/scsi-fixes into 7.2/scsi-staging 2026-06-15 21:01:30 -04:00
sbp
tcm_fc
tcm_remote
Kconfig
Makefile
target_core_alua.c scsi: target: use scoped_with_init_fs() for ALUA metadata 2026-06-29 10:44:06 +02:00
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
target_core_fabric_configfs.c usb: gadget: f_tcm: keep port count until LUN teardown completes 2026-08-14 10:49:21 +09: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
target_core_iblock.c scsi: target: iblock: Fix wrong PR ops NULL check for PREEMPT/RELEASE 2026-07-28 21:52:08 -04: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 vfs-7.3-rc1.kthread 2026-08-17 11:35:12 -07:00
target_core_pr.h
target_core_pscsi.c
target_core_pscsi.h
target_core_rd.c
target_core_rd.h
target_core_sbc.c
target_core_spc.c
target_core_stat.c
target_core_tmr.c
target_core_tpg.c
target_core_transport.c scsi: target: Clear cmd_cnt when initial counter enrollment fails 2026-07-28 21:52:09 -04:00
target_core_ua.c
target_core_ua.h
target_core_user.c
target_core_xcopy.c
target_core_xcopy.h