From: lirongqing <lirongqing@baidu.com>
To: Sagi Grimberg <sagi@grimberg.me>, Jason Gunthorpe <jgg@ziepe.ca>,
Leon Romanovsky <leon@kernel.org>,
Jenny Derzhavetz <jennyf@mellanox.com>,
Nicholas Bellinger <nab@linux-iscsi.org>,
<linux-rdma@vger.kernel.org>, <target-devel@vger.kernel.org>
Cc: Li RongQing <lirongqing@baidu.com>
Subject: [PATCH] IB/isert: Don't share drop_cmd_list across concurrent connection teardowns
Date: Mon, 21 Sep 2026 11:11:00 +0800 [thread overview]
Message-ID: <20260921031100.2199-1-lirongqing@baidu.com> (raw)
From: Li RongQing <lirongqing@baidu.com>
isert_put_unsol_pending_cmds() declares drop_cmd_list as a static
LIST_HEAD, so the list is shared across all invocations of the function.
It is called from isert_wait_conn(), the per-connection .iscsit_wait_conn
transport callback, which runs independently for each connection during
teardown.
conn->cmd_lock only protects each connection's own conn_cmd_list, not the
shared drop_cmd_list. If two connections tear down at the same time, both
threads list_move_tail() commands into the same drop_cmd_list without any
mutual exclusion, and then both iterate and list_del/put it concurrently.
This corrupts the linked list and can double-free iscsit_cmd structures.
Make drop_cmd_list a stack-local list, matching the pattern already used
in isert_free_np().
Fixes: 3e03c4b01da3 ("iser-target: Put the reference on commands waiting for unsol data")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/infiniband/ulp/isert/ib_isert.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index e69db43..efa8d7b 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -2583,7 +2583,7 @@ static void
isert_put_unsol_pending_cmds(struct iscsit_conn *conn)
{
struct iscsit_cmd *cmd, *tmp;
- static LIST_HEAD(drop_cmd_list);
+ LIST_HEAD(drop_cmd_list);
spin_lock_bh(&conn->cmd_lock);
list_for_each_entry_safe(cmd, tmp, &conn->conn_cmd_list, i_conn_node) {
--
2.9.4
next reply other threads:[~2026-09-21 3:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 3:11 lirongqing [this message]
2026-09-21 3:22 ` [PATCH] IB/isert: Don't share drop_cmd_list across concurrent connection teardowns sashiko-bot
2026-09-28 19:01 ` Leon Romanovsky
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=20260921031100.2199-1-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=jennyf@mellanox.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=sagi@grimberg.me \
--cc=target-devel@vger.kernel.org \
/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