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] [day] [month] [year] [list]
Date: Fri, 28 Jun 2024 14:58:48 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <cosiekvfj@...pl>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
	<linux-kernel@...r.kernel.org>, <netdev@...r.kernel.org>,
	<pabeni@...hat.com>, <kuniyu@...zon.com>
Subject: Re: [PATCH] net/socket: clamp negative backlog value to 0 in listen()

>From Kacper Piwiński <cosiekvfj@...pl>
Date: Fri, 28 Jun 2024 19:28:36 +0200
> According to manual: https://man7.org/linux/man-pages/man3/listen.3p.html
> If listen() is called with a backlog argument value that is less
> than 0, the function behaves as if it had been called with a
> backlog argument value of 0.

This breaks many applications that assume listen(fd, -1) configures
the backlog with the max value allowed in the netns.

The behaviour is useful especially in a container-like env where app
does not have access to procfs.

The man page should be updated instead.


> 
> Signed-off-by: Kacper Piwiński <cosiekvfj@...pl>
> ---
>  net/socket.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/socket.c b/net/socket.c
> index e416920e9..9567223d7 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -1873,8 +1873,7 @@ int __sys_listen(int fd, int backlog)
>  	sock = sockfd_lookup_light(fd, &err, &fput_needed);
>  	if (sock) {
>  		somaxconn = READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn);
> -		if ((unsigned int)backlog > somaxconn)
> -			backlog = somaxconn;
> +		backlog = clamp(backlog, 0, somaxconn);
>  
>  		err = security_socket_listen(sock, backlog);
>  		if (!err)
> -- 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ