From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <chuck.lever@oracle.com>
Cc: <axboe@kernel.dk>, <davem@davemloft.net>, <edumazet@google.com>,
<hch@lst.de>, <horms@kernel.org>, <jaka@linux.ibm.com>,
<jlayton@kernel.org>, <kbusch@kernel.org>, <kuba@kernel.org>,
<kuni1840@gmail.com>, <kuniyu@amazon.com>,
<linux-nfs@vger.kernel.org>, <linux-nvme@lists.infradead.org>,
<linux-rdma@vger.kernel.org>, <matttbe@kernel.org>,
<mptcp@lists.linux.dev>, <netdev@vger.kernel.org>,
<pabeni@redhat.com>, <sfrench@samba.org>, <wenjia@linux.ibm.com>,
<willemb@google.com>
Subject: Re: [PATCH v1 net-next 4/6] socket: Remove kernel socket conversion except for net/rds/.
Date: Thu, 22 May 2025 10:04:48 -0700 [thread overview]
Message-ID: <20250522170512.41751-1-kuniyu@amazon.com> (raw)
In-Reply-To: <44b6a9b5-6bd7-48f3-927d-3188cfd726f1@oracle.com>
From: Chuck Lever <chuck.lever@oracle.com>
Date: Thu, 22 May 2025 12:38:03 -0400
> On 5/22/25 4:55 AM, Paolo Abeni wrote:
> > On 5/17/25 5:50 AM, Kuniyuki Iwashima wrote:
> >> Since commit 26abe14379f8 ("net: Modify sk_alloc to not reference
> >> count the netns of kernel sockets."), TCP kernel socket has caused
> >> many UAF.
> >>
> >> We have converted such sockets to hold netns refcnt, and we have
> >> the same pattern in cifs, mptcp, nvme, rds, smc, and sunrpc.
> >>
> >> __sock_create_kern(..., &sock);
> >> sk_net_refcnt_upgrade(sock->sk);
> >>
> >> Let's drop the conversion and use sock_create_kern() instead.
> >>
> >> The changes for cifs, mptcp, nvme, and smc are straightforward.
> >>
> >> For sunrpc, we call sock_create_net() for IPPROTO_TCP only and still
> >> call __sock_create_kern() for others.
> >>
> >> For rds, we cannot drop sk_net_refcnt_upgrade() for accept()ed
> >> sockets.
> >>
> >> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> >
> > This LGTM, but is touching a few other subsystems, it would be great to
> > collect acks from the relevant maintainers: I'm adding a few CCs.
> >
> > Direct link to the series:
> >
> > https://lore.kernel.org/all/20250517035120.55560-1-kuniyu@amazon.com/#t
>
> Thank you, Paolo, for forwarding this series.
>
> For all hunks modifying net/sunrpc/svcsock.c and
> net/handshake/handshake-test.c:
>
> Acked-by: Chuck Lever <chuck.lever@oracle.com>
>
> Regarding patch 4/6:
>
> This paragraph in the patch description needs to explain /why/ sunrpc
> is an exception:
>
> > For sunrpc, we call sock_create_net() for IPPROTO_TCP only and still
> > call __sock_create_kern() for others.
Sorry I noticed this sentence was not updated from the previous series.
I'll change it as follows
For sunrpc, we call sk_net_refcnt_upgrade() for IPPROTO_TCP only
so we use sock_create_kern() for TCP and keep __sock_create_kern()
for others.
>
> The below hunk doesn't seem related to the marquee purpose of this
> series. Should it be a separate patch with its own rationale?
>
> @@ -1541,8 +1544,8 @@ static struct svc_xprt *svc_create_socket(struct
> svc_serv *serv,
> newlen = error;
>
> if (protocol == IPPROTO_TCP) {
> - sk_net_refcnt_upgrade(sock->sk);
The part above is related, and the below is not, using the old
style warned by checkpatch, so I cleaned it up while at it but
didn't think it's worth a patch. I'm fine to drop it.
> - if ((error = kernel_listen(sock, 64)) < 0)
> + error = kernel_listen(sock, 64);
> + if (error < 0)
> goto bummer;
> }
>
next prev parent reply other threads:[~2025-05-22 17:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250517035120.55560-1-kuniyu@amazon.com>
[not found] ` <20250517035120.55560-5-kuniyu@amazon.com>
2025-05-22 8:55 ` [PATCH v1 net-next 4/6] socket: Remove kernel socket conversion except for net/rds/ Paolo Abeni
2025-05-22 16:12 ` Kuniyuki Iwashima
2025-05-22 16:38 ` Chuck Lever
2025-05-22 17:04 ` Kuniyuki Iwashima [this message]
2025-05-23 4:23 ` 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=20250522170512.41751-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=axboe@kernel.dk \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hch@lst.de \
--cc=horms@kernel.org \
--cc=jaka@linux.ibm.com \
--cc=jlayton@kernel.org \
--cc=kbusch@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-rdma@vger.kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sfrench@samba.org \
--cc=wenjia@linux.ibm.com \
--cc=willemb@google.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