]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: xen: scsiback: Free the command tag on the TMR submit-failure path
authorMichael Bommarito <michael.bommarito@gmail.com>
Thu, 11 Jun 2026 12:30:46 +0000 (08:30 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 16 Jun 2026 01:52:39 +0000 (21:52 -0400)
scsiback_device_action() obtains a command tag in
scsiback_get_pend_req() and submits a task-management request with
target_submit_tmr(). When target_submit_tmr() fails it returns < 0 and
scsiback jumps to the err: label, which sends a response but frees
nothing, leaking the tag.

Impact: a pvSCSI guest can leak the command tags of a LUN's session,
stopping the LUN, by issuing VSCSIIF_ACT_SCSI_ABORT or RESET requests
whenever target_submit_tmr() fails.

transport_generic_free_cmd() cannot be used here. By the time
target_submit_tmr() returns an error it has already run
__target_init_cmd() (so se_cmd->cmd_kref is one, not zero), and on its
target_get_sess_cmd() error path it has freed se_cmd->se_tmr_req via
core_tmr_release_req() while leaving SCF_SCSI_TMR_CDB set and the
pointer dangling. Letting the command release run target_free_cmd_mem()
would then double-free se_tmr_req.

Use the same helper, which returns just the tag, on this path too.

Fixes: 2dbcdf33dbf6 ("xen-scsiback: Convert to percpu_ida tag allocation")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://patch.msgid.link/20260611123046.2323342-3-michael.bommarito@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/xen/xen-scsiback.c

index f324732eba7f85c5b57ebbe76f2cc5fc21cc8e4c..c7036e0e41bda1e4b30cc7427c248dc91b30e925 100644 (file)
@@ -658,7 +658,7 @@ static void scsiback_device_action(struct vscsibk_pend *pending_req,
        return;
 
 err:
-       scsiback_do_resp_with_sense(NULL, err, 0, pending_req);
+       scsiback_resp_and_free(pending_req, err);
 }
 
 /*