From: Daniel Wagner <wagi@kernel.org>
To: James Smart <james.smart@broadcom.com>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Chaitanya Kulkarni <kch@nvidia.com>
Cc: Hannes Reinecke <hare@suse.de>, Keith Busch <kbusch@kernel.org>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
Daniel Wagner <wagi@kernel.org>
Subject: [PATCH 00/11] nvmet-fcloop: track resources via reference counting
Date: Wed, 26 Feb 2025 19:45:52 +0100 [thread overview]
Message-ID: <20250226-nvmet-fcloop-v1-0-c0bd83d43e6a@kernel.org> (raw)
The fcloop module is mainly used for testing, that is with blktests.
Unfortunatly, there are shortcomings when it comes to releases resources.
E.g. unloading the module can result in UAFs.
I've written two new blktests which are triggering reconnects. The first
one is doing this by removing the target while the host is still up and
running. The second one is trigger a reset via the new debugfs interface.
Both of these two tests cases work fine for TCP and RDMA but not FC.
By introducing reference counting on various objects the UAFs go away.
Also KASAN is happy. There are also a bunch of fixes for nvmet-fc which
got uncovered by the fcloop fixes.
I still see one UAF sometimes happening. When the association attempt
fails (looks like yet another bug), the test case removes all resources:
(NULL device *): Create Association LS failed: Association Allocation Failed
(NULL device *): queue 0 connect admin queue failed (-6).
nvme nvme1: NVME-FC{0}: reset: Reconnect attempt failed (-6)
nvme nvme1: NVME-FC{0}: Reconnect attempt in 1 seconds
nvme nvme1: NVME-FC{0}: create association : host wwpn 0x20001100aa000001 rport wwpn 0x20001100ab000001: NQN "blktests-subsystem-1"
(NULL device *): Create Association LS failed: Association Allocation Failed
(NULL device *): queue 0 connect admin queue failed (-6).
nvme nvme1: NVME-FC{0}: reset: Reconnect attempt failed (-6)
nvme nvme1: NVME-FC{0}: Reconnect attempt in 1 seconds
nvme nvme1: Removing ctrl: NQN "blktests-subsystem-1"
nvme_ns_head_submit_bio: 29 callbacks suppressed
block nvme1n1: no available path - failing I/O
block nvme1n1: no available path - failing I/O
block nvme1n1: no available path - failing I/O
block nvme1n1: no available path - failing I/O
block nvme1n1: no available path - failing I/O
block nvme1n1: no available path - failing I/O
block nvme1n1: no available path - failing I/O
block nvme1n1: no available path - failing I/O
nvme nvme2: Removing ctrl: NQN "nqn.2014-08.org.nvmexpress.discovery"
==================================================================
BUG: KASAN: slab-use-after-free in nvme_fc_rescan_remoteport+0x56/0x1d0 [nvme_fc]
Read of size 8 at addr ffff88810b662890 by task kworker/u36:10/1876
CPU: 3 UID: 0 PID: 1876 Comm: kworker/u36:10 Tainted: G W 6.14.0-rc2+ #48 d5f3bf6340950de08bebd912d815fcf6b60c18ab
Tainted: [W]=WARN
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-3.fc41 04/01/2014
Workqueue: nvmet-wq fcloop_tgt_rscn_work [nvme_fcloop]
static void nvmet_port_subsys_drop_link(struct config_item *parent,
struct config_item *target)
{
[...]
found:
list_del(&p->entry);
nvmet_port_del_ctrls(port, subsys);
nvmet_port_disc_changed(port, subsys); /* XXX triggers the above UAF */
if (list_empty(&port->subsystems))
nvmet_disable_port(port);
up_write(&nvmet_config_sem);
kfree(p);
}
The nvmet_port_disc_changed is a bit useless, because these event will
never be seen by the host. Anyway, more debugging is necessary.
I'll send the new tests cases for blktests soon.
Signed-off-by: Daniel Wagner <wagi@kernel.org>
---
Daniel Wagner (11):
nvmet-fcloop: remove nport from list on last user
nvmet-fcloop: add ref counting to lport
nvmet-fcloop: refactor fcloop_nport_alloc
nvmet-fcloop: track ref counts for nports
nvmet-fcloop: track tport with ref counting
nvmet-fcloop: track rport with ref counting
nvmet-fc: update tgtport ref per assoc
nvmet-fc: take tgtport reference only once
nvmet-fc: free pending reqs on tgtport unregister
nvmet-fc: inline nvmet_fc_delete_assoc
nvmet-fc: inline nvmet_fc_free_hostport
drivers/nvme/target/fc.c | 82 +++++------
drivers/nvme/target/fcloop.c | 326 ++++++++++++++++++++++++++++---------------
2 files changed, 255 insertions(+), 153 deletions(-)
---
base-commit: a64dcfb451e254085a7daee5fe51bf22959d52d3
change-id: 20250214-nvmet-fcloop-a649738b7e6e
Best regards,
--
Daniel Wagner <wagi@kernel.org>
next reply other threads:[~2025-02-26 18:45 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 18:45 Daniel Wagner [this message]
2025-02-26 18:45 ` [PATCH 01/11] nvmet-fcloop: remove nport from list on last user Daniel Wagner
2025-02-28 7:04 ` Hannes Reinecke
2025-03-05 14:16 ` Christoph Hellwig
2025-02-26 18:45 ` [PATCH 02/11] nvmet-fcloop: add ref counting to lport Daniel Wagner
2025-02-28 7:05 ` Hannes Reinecke
2025-03-05 14:17 ` Christoph Hellwig
2025-03-06 9:26 ` Daniel Wagner
2025-03-06 10:06 ` Daniel Wagner
2025-02-26 18:45 ` [PATCH 03/11] nvmet-fcloop: refactor fcloop_nport_alloc Daniel Wagner
2025-02-28 7:11 ` Hannes Reinecke
2025-02-28 7:56 ` Daniel Wagner
2025-03-05 14:18 ` Christoph Hellwig
2025-02-26 18:45 ` [PATCH 04/11] nvmet-fcloop: track ref counts for nports Daniel Wagner
2025-02-28 7:19 ` Hannes Reinecke
2025-02-28 8:09 ` Daniel Wagner
2025-02-28 8:18 ` Daniel Wagner
2025-02-26 18:45 ` [PATCH 05/11] nvmet-fcloop: track tport with ref counting Daniel Wagner
2025-02-28 7:27 ` Hannes Reinecke
2025-02-28 8:30 ` Daniel Wagner
2025-02-28 14:31 ` Daniel Wagner
2025-02-26 18:45 ` [PATCH 06/11] nvmet-fcloop: track rport " Daniel Wagner
2025-02-28 7:29 ` Hannes Reinecke
2025-02-26 18:45 ` [PATCH 07/11] nvmet-fc: update tgtport ref per assoc Daniel Wagner
2025-02-28 7:30 ` Hannes Reinecke
2025-02-26 18:46 ` [PATCH 08/11] nvmet-fc: take tgtport reference only once Daniel Wagner
2025-02-28 7:34 ` Hannes Reinecke
2025-02-28 8:45 ` Daniel Wagner
2025-02-26 18:46 ` [PATCH 09/11] nvmet-fc: free pending reqs on tgtport unregister Daniel Wagner
2025-02-28 7:35 ` Hannes Reinecke
2025-02-26 18:46 ` [PATCH 10/11] nvmet-fc: inline nvmet_fc_delete_assoc Daniel Wagner
2025-02-28 7:36 ` Hannes Reinecke
2025-02-26 18:46 ` [PATCH 11/11] nvmet-fc: inline nvmet_fc_free_hostport Daniel Wagner
2025-02-28 7:37 ` Hannes Reinecke
2025-02-27 16:30 ` [PATCH 00/11] nvmet-fcloop: track resources via reference counting Daniel Wagner
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=20250226-nvmet-fcloop-v1-0-c0bd83d43e6a@kernel.org \
--to=wagi@kernel.org \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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
all inboxes | Powered by JetHome®