netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <hch@lst.de>
Cc: <axboe@kernel.dk>, <gechangzhong@cestc.cn>, <kbusch@kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-nvme@lists.infradead.org>,
	<netdev@vger.kernel.org>, <sagi@grimberg.me>,
	<shaopeijie@cestc.cn>, <zhang.guanghui@cestc.cn>,
	<kuniyu@amazon.com>
Subject: Re: [PATCH v2] nvme-tcp: Fix netns UAF introduced by commit 1be52169c348
Date: Mon, 7 Apr 2025 10:18:18 -0700	[thread overview]
Message-ID: <20250407171925.28802-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20250407143121.GA11876@lst.de>

From: Christoph Hellwig <hch@lst.de>
Date: Mon, 7 Apr 2025 16:31:21 +0200
> I had another look at this patch, and it feels wrong to me.  I don't
> think we are supposed to create sockets triggered by activity in
> a network namespace in the global namespace even if they are indirectly
> created through the nvme interface.  But maybe I'm misunderstanding
> how network namespaces work, which is entirely possible.
> 
> So to avoid the failure I'd be tempted to instead revert commit
> 1be52169c348 until the problem is fully sorted out.

The followup patch is wrong, and the correct fix is to take a reference
to the netns by sk_net_refcnt_upgrade().

---8<---
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 26c459f0198d..72d260201d8c 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1803,6 +1803,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,
 		ret = PTR_ERR(sock_file);
 		goto err_destroy_mutex;
 	}
+
+	sk_net_refcnt_upgrade(queue->sock->sk);
 	nvme_tcp_reclassify_socket(queue->sock);
 
 	/* Single syn retry */
---8<---

  reply	other threads:[~2025-04-07 17:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bd5f2f8a-94f0-43b0-af02-565422d12032@cestc.cn>
     [not found] ` <20250403144748.3399661-1-shaopeijie@cestc.cn>
2025-04-07 14:31   ` [PATCH v2] nvme-tcp: Fix netns UAF introduced by commit 1be52169c348 Christoph Hellwig
2025-04-07 17:18     ` Kuniyuki Iwashima [this message]
2025-04-08  5:04       ` Christoph Hellwig
2025-04-08  5:55         ` Kuniyuki Iwashima
2025-04-08  5:58           ` Christoph Hellwig
2025-04-08  6:08             ` Kuniyuki Iwashima

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=20250407171925.28802-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=axboe@kernel.dk \
    --cc=gechangzhong@cestc.cn \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=sagi@grimberg.me \
    --cc=shaopeijie@cestc.cn \
    --cc=zhang.guanghui@cestc.cn \
    /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;
as well as URLs for NNTP newsgroup(s).