* Re: [PATCH] smb/server: use sock_create_kern() in create_socket() [not found] <20250324065155.665290-1-chenxiaosong@chenxiaosong.com> @ 2025-03-24 21:07 ` David Laight 2025-03-24 22:11 ` Kuniyuki Iwashima 0 siblings, 1 reply; 2+ messages in thread From: David Laight @ 2025-03-24 21:07 UTC (permalink / raw) To: chenxiaosong Cc: linkinjeon, sfrench, senozhatsky, tom, linux-cifs, linux-kernel, ChenXiaoSong, netdev On Mon, 24 Mar 2025 06:51:55 +0000 chenxiaosong@chenxiaosong.com wrote: > From: ChenXiaoSong <chenxiaosong@kylinos.cn> > > The socket resides in kernel space, so use sock_create_kern() > instead of sock_create(). As in the other patches you need to worry about whether the socket holds a reference to the network namespace. David > > Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> > --- > fs/smb/server/transport_tcp.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c > index 7f38a3c3f5bd..e5f46a91c3fc 100644 > --- a/fs/smb/server/transport_tcp.c > +++ b/fs/smb/server/transport_tcp.c > @@ -429,12 +429,13 @@ static int create_socket(struct interface *iface) > struct socket *ksmbd_socket; > bool ipv4 = false; > > - ret = sock_create(PF_INET6, SOCK_STREAM, IPPROTO_TCP, &ksmbd_socket); > + ret = sock_create_kern(current->nsproxy->net_ns, PF_INET6, SOCK_STREAM, > + IPPROTO_TCP, &ksmbd_socket); > if (ret) { > if (ret != -EAFNOSUPPORT) > pr_err("Can't create socket for ipv6, fallback to ipv4: %d\n", ret); > - ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, > - &ksmbd_socket); > + ret = sock_create_kern(current->nsproxy->net_ns, PF_INET, > + SOCK_STREAM, IPPROTO_TCP, &ksmbd_socket); > if (ret) { > pr_err("Can't create socket for ipv4: %d\n", ret); > goto out_clear; ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] smb/server: use sock_create_kern() in create_socket() 2025-03-24 21:07 ` [PATCH] smb/server: use sock_create_kern() in create_socket() David Laight @ 2025-03-24 22:11 ` Kuniyuki Iwashima 0 siblings, 0 replies; 2+ messages in thread From: Kuniyuki Iwashima @ 2025-03-24 22:11 UTC (permalink / raw) To: chenxiaosong Cc: david.laight.linux, chenxiaosong, linkinjeon, linux-cifs, linux-kernel, netdev, senozhatsky, sfrench, tom From: David Laight <david.laight.linux@gmail.com> Date: Mon, 24 Mar 2025 21:07:47 +0000 > On Mon, 24 Mar 2025 06:51:55 +0000 > chenxiaosong@chenxiaosong.com wrote: > > > From: ChenXiaoSong <chenxiaosong@kylinos.cn> > > > > The socket resides in kernel space, so use sock_create_kern() > > instead of sock_create(). > > As in the other patches you need to worry about whether the socket > holds a reference to the network namespace. Right, and if you don't see any real issue, I recommend leaving it as is for now because we have seen many refcount issues for kernel TCP sockets. And I totally forgot to respin my series after holiday to clean up such callers. https://lore.kernel.org/netdev/20241213092152.14057-1-kuniyu@amazon.com/ I'll repost v4 after the merge window with some modification 1. be less invasive as suggested by Paolo 2. use sk_net_refcnt_upgrade() ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-24 22:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250324065155.665290-1-chenxiaosong@chenxiaosong.com>
2025-03-24 21:07 ` [PATCH] smb/server: use sock_create_kern() in create_socket() David Laight
2025-03-24 22:11 ` Kuniyuki Iwashima
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).