All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next 0/2] scsi: iscsi: Fix races in connection cleanup path
@ 2026-08-21  9:24 Ye Bin
  2026-08-21  9:24 ` [PATCH -next 1/2] scsi: iscsi: fix NULL pointer dereference in iscsi_sw_tcp_release_conn() Ye Bin
  2026-08-21  9:24 ` [PATCH -next 2/2] scsi: iscsi: Fix use-after-free in iscsi_conn_release() for cleanup_work Ye Bin
  0 siblings, 2 replies; 5+ messages in thread
From: Ye Bin @ 2026-08-21  9:24 UTC (permalink / raw)
  To: lduncan, cleech, michael.christie, James.Bottomley,
	martin.petersen, open-iscsi, linux-scsi
  Cc: yebin10

From: Ye Bin <yebin10@huawei.com>

This series fixes two races in the iSCSI connection cleanup path that
were introduced by commit 23d6fefbb3f6 ("scsi: iscsi: Fix in-kernel
conn failure handling").

Patch 1 fixes a NULL pointer dereference in iscsi_sw_tcp_release_conn()
that occurs when userspace delivers STOP_CONN_TERM while the kernel has
already queued cleanup_work for the same connection. The two paths race
on tcp_sw_conn->sock: the userspace path clears it under sock_lock while
the workqueue path dereferences it locklessly in
iscsi_sw_tcp_conn_restore_callbacks(), leading to a NULL dereference.
The fix sets ISCSI_CLS_CONN_BIT_CLEANUP when userspace delivers
STOP_CONN_TERM to prevent concurrent invocation of iscsi_stop_conn().

Patch 2 fixes a use-after-free in iscsi_conn_release().
iscsi_conn_error_event() queues conn->cleanup_work without taking a
reference to the connection, so if the connection is freed (e.g. via
iscsi_remove_session() -> iscsi_iter_destroy_conn_fn()) while the work
is still pending or running, iscsi_cleanup_conn_work_fn() dereferences
freed memory. Unlike the iscsi_if_destroy_conn() and iscsi_if_stop_conn()
paths, the session teardown path does not handle the pending
cleanup_work before dropping the connection reference. The fix calls
cancel_work_sync(&conn->cleanup_work) in iscsi_conn_release() before
freeing the connection.

Ye Bin (2):
  scsi: iscsi: fix NULL pointer dereference in
    iscsi_sw_tcp_release_conn()
  scsi: iscsi: Fix use-after-free in iscsi_conn_release() for
    cleanup_work

 drivers/scsi/scsi_transport_iscsi.c | 50 +++++++++++++++++------------
 1 file changed, 30 insertions(+), 20 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-21  9:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21  9:24 [PATCH -next 0/2] scsi: iscsi: Fix races in connection cleanup path Ye Bin
2026-08-21  9:24 ` [PATCH -next 1/2] scsi: iscsi: fix NULL pointer dereference in iscsi_sw_tcp_release_conn() Ye Bin
2026-08-21  9:47   ` sashiko-bot
2026-08-21  9:24 ` [PATCH -next 2/2] scsi: iscsi: Fix use-after-free in iscsi_conn_release() for cleanup_work Ye Bin
2026-08-21  9:49   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.