From: Mike Christie <michael.christie@oracle.com>
To: Ye Bin <yebin@huaweicloud.com>,
lduncan@suse.com, cleech@redhat.com,
James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, open-iscsi@googlegroups.com,
linux-scsi@vger.kernel.org
Cc: yebin10@huawei.com
Subject: Re: [PATCH -next 2/2] scsi: iscsi: Fix use-after-free in iscsi_conn_release() for cleanup_work
Date: Tue, 15 Sep 2026 15:49:36 -0500 [thread overview]
Message-ID: <1f506f66-282e-4c5b-89fa-7bdba26b1fe3@oracle.com> (raw)
In-Reply-To: <20260821092435.1632931-3-yebin@huaweicloud.com>
On 8/21/26 4:24 AM, Ye Bin wrote:
> From: Ye Bin <yebin10@ huawei. com> iscsi_conn_error_event() queues conn-
> >cleanup_work without taking a reference to the connection. If the connection's
> refcount drops to zero while the work is still pending or running,
> iscsi_conn_release()
>
>
> From: Ye Bin <yebin10@huawei.com>
>
> iscsi_conn_error_event() queues conn->cleanup_work without taking a
> reference to the connection. If the connection's refcount drops to zero
> while the work is still pending or running, iscsi_conn_release() frees
> the connection memory without canceling the work, leading to a
> use-after-free when iscsi_cleanup_conn_work_fn() later dereferences the
> freed conn struct.
>
> This can happen when a session is torn down via iscsi_remove_session(),
> which calls iscsi_iter_destroy_conn_fn() to remove and drop the final
> reference on each remaining connection. Unlike iscsi_if_destroy_conn()
> (which flushes the work) and iscsi_if_stop_conn() (which cancels or
> flushes the work), the iscsi_iter_destroy_conn_fn() path does not handle
> the pending cleanup_work before dropping the connection reference.
>
> Trigger flow:
>
> CPU 0 (error path) CPU 1 (session teardown)
> ----------------------- --------------------------
> iscsi_conn_error_event(conn)
> queue_work(cleanup_work)
> [no conn reference taken] iscsi_remove_session()
> iscsi_iter_destroy_conn_fn()
> iscsi_remove_conn(conn)
> iscsi_put_conn(conn)
> refcount == 0
> iscsi_conn_release()
> kfree(conn)
>
It's not supported to run iscsi_remove_session while there's running
connections. That code was just meant for a qla4xxx mode where it
doesn't expose connections so the conn was just used to export info
to userspace via sysfs. It's for when the driver uses
qla4xxx_sess_conn_setup to create sessions and conns in one call.
There's not real use for it so I think fix qla4xxx to remove it's conn
firs, then check for session->leadconn != NULL in
libiscsi:iscsi_session_remove().
In scsi_transport_iscsi:iscsi_remove_session you could add a BUG then
since it should never be done.
prev parent reply other threads:[~2026-09-15 20:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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-09-15 20:07 ` Mike Christie
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
2026-09-15 20:49 ` Mike Christie [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1f506f66-282e-4c5b-89fa-7bdba26b1fe3@oracle.com \
--to=michael.christie@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=cleech@redhat.com \
--cc=lduncan@suse.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=open-iscsi@googlegroups.com \
--cc=yebin10@huawei.com \
--cc=yebin@huaweicloud.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox