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  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]
Date:   Mon, 9 Mar 2020 21:04:24 -0700
From:   Eric Dumazet <>
To:     Kuniyuki Iwashima <>,,,,
Subject: Re: [PATCH v4 net-next 2/5] tcp: bind(0) remove the SO_REUSEADDR
 restriction when ephemeral ports are exhausted.

On 3/8/20 11:16 AM, Kuniyuki Iwashima wrote:
> Commit aacd9289af8b82f5fb01bcdd53d0e3406d1333c7 ("tcp: bind() use stronger
> condition for bind_conflict") introduced a restriction to forbid to bind
> SO_REUSEADDR enabled sockets to the same (addr, port) tuple in order to
> assign ports dispersedly so that we can connect to the same remote host.
> The change results in accelerating port depletion so that we fail to bind
> sockets to the same local port even if we want to connect to the different
> remote hosts.
> You can reproduce this issue by following instructions below.
>   1. # sysctl -w net.ipv4.ip_local_port_range="32768 32768"
>   2. set SO_REUSEADDR to two sockets.
>   3. bind two sockets to (localhost, 0) and the latter fails.
> Therefore, when ephemeral ports are exhausted, bind(0) should fallback to
> the legacy behaviour to enable the SO_REUSEADDR option and make it possible
> to connect to different remote (addr, port) tuples.

Sadly this commit tries hard to support obsolete SO_REUSEADDR for active connections,
which makes little sense now we have more powerful IP_BIND_ADDRESS_NO_PORT

SO_REUSEADDR only really makes sense for a listener, because you want a
server to be able to restart after core dump, while prior sockets are still
kept in TIME_WAIT state.

Same for SO_REUSEPORT : it only made sense for sharded listeners in linux kernel.

Trying to allocate a sport at bind() time, without knowing the destination address/port
is really not something that can be fixed.

Your patches might allow a 2x increase, while IP_BIND_ADDRESS_NO_PORT
basically allows for 1000x increase of the possible combinations.

> This patch allows us to bind SO_REUSEADDR enabled sockets to the same
> (addr, port) only when all ephemeral ports are exhausted.
> The only notable thing is that if all sockets bound to the same port have
> both SO_REUSEADDR and SO_REUSEPORT enabled, we can bind sockets to an
> ephemeral port and also do listen().
> Fixes: aacd9289af8b ("tcp: bind() use stronger condition for bind_conflict")

I disagree with this Fixes: tag  : I do not want this patch in stable kernels,
particularly if you put the sysctl patch as a followup without a Fixes: tag.

Please reorder your patch to first introduce the sysctl, then this one.

Or squash the two patches.

> Signed-off-by: Kuniyuki Iwashima <>

Powered by blists - more mailing lists