lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250519173030.40491-1-kuniyu@amazon.com>
Date: Mon, 19 May 2025 10:28:25 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <david.laight.linux@...il.com>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <horms@...nel.org>,
	<kuba@...nel.org>, <kuni1840@...il.com>, <kuniyu@...zon.com>,
	<netdev@...r.kernel.org>, <pabeni@...hat.com>, <willemb@...gle.com>
Subject: Re: [PATCH v1 net-next 6/6] socket: Clean up kdoc for sock_create() and sock_create_lite().

From: David Laight <david.laight.linux@...il.com>
Date: Mon, 19 May 2025 13:43:09 +0100
> On Fri, 16 May 2025 20:50:27 -0700
> Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> 
> > __sock_create() is now static and the same doc exists on sock_create()
> > and sock_create_kern().
> > 
> > Also, __sock_create() says "On failure @res is set to %NULL.", but
> > this is always false.
> > 
> > In addition, the old style kdoc is a bit corrupted and we can't see the
> > DESCRIPTION section:
> > 
> >   $ scripts/kernel-doc -man net/socket.c | scripts/split-man.pl /tmp/man
> >   $ man /tmp/man/sock_create.9
> > 
> > Let's clean them up.
> 
> I think you need to absolutely explicit about which calls hold a reference
> to 'net' and which don't.

I don't think so regarding sock_create() and sock_create_lite() because

  1) sock_create() is only used for userspace, and we always
     use current->nsproxy->net_ns, which must exist

  2) sock_create_lite() does not create struct sock by itself, and
     sock_create_lite() must be used with an already-created socket
     by other sock_create() helpers, where kdoc says when you need netns ref:

---8<---
/**
 * __sock_create_kern - creates a socket for kernel space
...
 * @net MUST be alive as of calling __sock_create_kern().
...
/**
 * sock_create_kern - creates a socket for kernel space
...
 * This MUST NOT be called from the __net_init path and @net MUST
 * be alive as of calling sock_create_net().
---8<---


> 
> This is separate from any user/kernel flag - and may need a second flag
> (although there are probably only 3 options).
> 
> IIRC some sockets are created internally within the protocol code
> and don't want to stop the 'net' being deleted.
> Such code has to have a callback from the 'net delete' path to tidy up.
> 
> OTOH it is not unreasonable for other kernel activities (perhaps file
> system mounts) to hold a ref count to stop the net being deleted.

It's written in patch 2 and kdoc in patch 3.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ