From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5B9425DB1C; Mon, 9 Feb 2026 14:45:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648324; cv=none; b=MWR9qECT2mWc6RntoXC56AwTmbK7k7ResZe3ZkI1CXMaU7c+ot1JHwdcBmI/5PgfXHyIn07HpSLImtW51eekY+BPU8j8ziuKLBDwLZQv/TgWRvkWkDkLWgAwf5DmSi7UysbrVzb6y7FTGLFA4tIg49aCn5G/3D+VkXFUWaJlcas= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648324; c=relaxed/simple; bh=n0jaqpxNrEdhsH1DFcyxPDCcOlM/2R+/Yivvm+e4GWM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QnHAbrQkUnIPNL9zchh03PuL+AFysrAKTJARIwvyTVCIs/VE3mUF84uxKpoNe01BmA0leTvhNGu7RdGpEITFVl/F5VWcYiZHBn53YC3FGfgQkvIO5+96G5sLe4Q4b0oRykdJWixLrCkYrvk1X59d0j+GJHUJLrGLwVFQ0l6sXIg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=2PqRZBai; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="2PqRZBai" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3B45C116C6; Mon, 9 Feb 2026 14:45:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770648324; bh=n0jaqpxNrEdhsH1DFcyxPDCcOlM/2R+/Yivvm+e4GWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2PqRZBai38Ioqf5WD+vikJ9KeiMKRQ8u2d/lmI4uDJb1yIWLV7U0K3eCZQ/0gfIqL 11J5oanLWQhQ92VmwFWqvaiPPRdon1Ik0IYFH7DnlddxCRg4rCrmwj50jMLaHnj63Z uSwvCD4Ta5HQ8HcnBW/Jq7LWnDqIjJI+1gI6+RkY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Maurizio Lombardi , Zhaojuan Guo , Mike Christie , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 6.1 41/69] scsi: target: iscsi: Fix use-after-free in iscsit_dec_session_usage_count() Date: Mon, 9 Feb 2026 15:24:09 +0100 Message-ID: <20260209142303.403213083@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142301.913348974@linuxfoundation.org> References: <20260209142301.913348974@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maurizio Lombardi [ Upstream commit 84dc6037390b8607c5551047d3970336cb51ba9a ] In iscsit_dec_session_usage_count(), the function calls complete() while holding the sess->session_usage_lock. Similar to the connection usage count logic, the waiter signaled by complete() (e.g., in the session release path) may wake up and free the iscsit_session structure immediately. This creates a race condition where the current thread may attempt to execute spin_unlock_bh() on a session structure that has already been deallocated, resulting in a KASAN slab-use-after-free. To resolve this, release the session_usage_lock before calling complete() to ensure all dereferences of the sess pointer are finished before the waiter is allowed to proceed with deallocation. Signed-off-by: Maurizio Lombardi Reported-by: Zhaojuan Guo Reviewed-by: Mike Christie Link: https://patch.msgid.link/20260112165352.138606-3-mlombard@redhat.com Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/target/iscsi/iscsi_target_util.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 26dc8ed3045b6..61bcdc33f1230 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -785,8 +785,11 @@ void iscsit_dec_session_usage_count(struct iscsit_session *sess) spin_lock_bh(&sess->session_usage_lock); sess->session_usage_count--; - if (!sess->session_usage_count && sess->session_waiting_on_uc) + if (!sess->session_usage_count && sess->session_waiting_on_uc) { + spin_unlock_bh(&sess->session_usage_lock); complete(&sess->session_waiting_on_uc_comp); + return; + } spin_unlock_bh(&sess->session_usage_lock); } -- 2.51.0