From: sashiko-bot@kernel.org
To: "Hannes Reinecke" <hare@kernel.org>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme-tcp: use correct network namespace to resolve addresses
Date: Wed, 25 Nov 2026 14:29:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-233564@kernel.org> (raw)
In-Reply-To: <20261125142033.4889-1-hare@kernel.org>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] nvme-tcp: use-after-free in nvme_tcp_alloc_ctrl() [1]
--
commit b5c00449d6f49b9a56a985850da55496bd947e27
Author: Hannes Reinecke <hare@kernel.org>
nvme-tcp: use correct network namespace to resolve addresses
This commit initializes ctrl->net earlier in nvme_tcp_alloc_ctrl() and
uses it instead of init_net when resolving traddr, host_traddr, and
host_iface.
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 62a594b8ab9bf..bcc092cdf42b0 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -3309,6 +3309,7 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
> ctrl->ctrl.queue_count = NVME_TCP_OPT_NR_QUEUES(opts);
> ctrl->ctrl.sqsize = opts->queue_size - 1;
> ctrl->ctrl.kato = opts->kato;
> + ctrl->net = get_net(current->nsproxy->net_ns);
>
> INIT_DELAYED_WORK(&ctrl->connect_work,
> nvme_tcp_reconnect_ctrl_work);
> @@ -3325,7 +3326,7 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
> opts->mask |= NVMF_OPT_TRSVCID;
> }
>
> - ret = inet_pton_with_scope(&init_net, AF_UNSPEC,
> + ret = inet_pton_with_scope(ctrl->net, AF_UNSPEC,
> opts->traddr, opts->trsvcid, &ctrl->addr);
> if (ret) {
> pr_err("malformed address passed: %s:%s\n",
> @@ -3334,7 +3335,7 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
> }
>
> if (opts->mask & NVMF_OPT_HOST_TRADDR) {
> - ret = inet_pton_with_scope(&init_net, AF_UNSPEC,
> + ret = inet_pton_with_scope(ctrl->net, AF_UNSPEC,
> opts->host_traddr, NULL, &ctrl->src_addr);
> if (ret) {
> pr_err("malformed src address passed: %s\n",
> @@ -3344,7 +3345,7 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
> }
>
> if (opts->mask & NVMF_OPT_HOST_IFACE) {
> - if (!__dev_get_by_name(current->nsproxy->net_ns,
> + if (!__dev_get_by_name(ctrl->net,
> opts->host_iface)) {
[Severity: Critical]
This problem wasn't introduced by this patch, but can calling
__dev_get_by_name() without holding rtnl_lock or rcu_read_lock() cause a
use-after-free [1]?
__dev_get_by_name() traverses the net->dev_name_head hash list without
taking any locks. Concurrent network device registration or
unregistration can modify or free list entries during the traversal,
leading to a use-after-free or an infinite loop.
[1] https://sashiko.dev/#/bug/linux-8edcdd49-7446-4c9f-86a0-f1b1561c3867
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125142033.4889-1-hare@kernel.org?part=1
next prev parent reply other threads:[~2026-11-25 14:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 14:20 [PATCH] nvme-tcp: use correct network namespace to resolve addresses Hannes Reinecke
2026-11-25 14:29 ` sashiko-bot [this message]
2026-11-26 8:56 ` Christoph Hellwig
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=sashiko-outbox-233564@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hare@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 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.