]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
scsi: target: iscsi: Fix use-after-free in iscsit_dec_conn_usage_count()
authorMaurizio Lombardi <mlombard@redhat.com>
Mon, 12 Jan 2026 16:53:51 +0000 (17:53 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 17 Jan 2026 04:02:15 +0000 (23:02 -0500)
commit9411a89e9e7135cc459178fa77a3f1d6191ae903
tree1349b89b558cd02a6cf87cf38bc926dabd869801
parentfe2f8ad6f0999db3b318359a01ee0108c703a8c3
scsi: target: iscsi: Fix use-after-free in iscsit_dec_conn_usage_count()

In iscsit_dec_conn_usage_count(), the function calls complete() while
holding the conn->conn_usage_lock. As soon as complete() is invoked, the
waiter (such as iscsit_close_connection()) may wake up and proceed to free
the iscsit_conn structure.

If the waiter frees the memory before the current thread reaches
spin_unlock_bh(), it results in a KASAN slab-use-after-free as the function
attempts to release a lock within the already-freed connection structure.

Fix this by releasing the spinlock before calling complete().

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reported-by: Zhaojuan Guo <zguo@redhat.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Link: https://patch.msgid.link/20260112165352.138606-2-mlombard@redhat.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/iscsi/iscsi_target_util.c