Page MenuHomeFreeBSD

Improve POSIX compliance of listen()
ClosedPublic

Authored by tuexen on Sep 3 2021, 11:55 AM.
Tags
None
Referenced Files
F81682326: D31821.id.diff
Fri, Apr 19, 9:14 PM
Unknown Object (File)
Thu, Apr 18, 8:59 AM
Unknown Object (File)
Tue, Apr 9, 3:30 PM
Unknown Object (File)
Thu, Apr 4, 6:32 PM
Unknown Object (File)
Mar 4 2024, 8:22 PM
Unknown Object (File)
Mar 4 2024, 8:22 PM
Unknown Object (File)
Mar 4 2024, 8:22 PM
Unknown Object (File)
Mar 4 2024, 8:22 PM

Details

Summary

POSIX states:

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 patch ensures that a negative backlog argument is handle as it if was 0.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

tuexen created this revision.

I think I'm ok with the change, but IMO listen.2 should also document our behaviour for the cases backlog < 0, backlog == 0, backlog > 0.

Document the code change in the man-page

I think I'm ok with the change, but IMO listen.2 should also document our behaviour for the cases backlog < 0, backlog == 0, backlog > 0.

I added text to the listen.2, which documents the code change. Or are you referring to also document the semantic of backlog for the SCTP case? This is missing, but not related to the code change in this patch.

I think I'm ok with the change, but IMO listen.2 should also document our behaviour for the cases backlog < 0, backlog == 0, backlog > 0.

Ping.

This revision is now accepted and ready to land.Oct 10 2022, 11:47 PM
This revision was automatically updated to reflect the committed changes.

Please note such things:

https://github.com/php/php-src/blob/master/sapi/fpm/www.conf.in#L39
https://github.com/php/php-src/blob/master/sapi/fpm/fpm/fpm_sockets.h#L20

I think it may be quite popular listen() usage and, even if we patch and recompile new software, this patch may break a lot of legacy jails with somethng like COMPAT_FREEBSD9.

Please note such things:

https://github.com/php/php-src/blob/master/sapi/fpm/www.conf.in#L39
https://github.com/php/php-src/blob/master/sapi/fpm/fpm/fpm_sockets.h#L20

I think it may be quite popular listen() usage and, even if we patch and recompile new software, this patch may break a lot of legacy jails with somethng like COMPAT_FREEBSD9.

Thanks! There is already a discussion on the commit mailing list... Wanted to provide a link, but discussion starters removed the public list from Cc :( The change is already backed out.

4.2BSD established the backlog == -1 convention, and that convention was never changed in BSD.
We didn't have INT_MAX until 4.3BSD-Tahoe, but the interface didn't change then.
Most implementations have copied this interface, and I'm not sure where POSIX got its recommendations, but in this case it is at odds with the historical definition.
This is an unwise change and brings only liability with no real benefits.