Bug 212167 - listen() system call succeeds for a locally bound UNIX-domain datagram-oriented socket
Summary: listen() system call succeeds for a locally bound UNIX-domain datagram-orient...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 10.3-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-26 03:21 UTC by Arseny Vakhrushev
Modified: 2021-10-02 04:37 UTC (History)
1 user (show)

See Also:


Attachments
Simple program that illustrates the bug (561 bytes, text/plain)
2016-08-26 03:21 UTC, Arseny Vakhrushev
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Vakhrushev 2016-08-26 03:21:44 UTC
Created attachment 174083 [details]
Simple program that illustrates the bug

FreeBSD 10.3-RELEASE-p4:

While messing with UNIX-domain sockets (AF_LOCAL), I've noticed that the listen() system call succeeds for a locally bound datagram-oriented (SOCK_DGRAM) socket on FreeBSD while legitimately failing on other systems since datagram sockets can't be in a listening state. Seemed like not a big deal first but eventually led to some undefined behaviour (which I wasn't able to reproduce as a separate test-case unfortunately).

Nevertheless, expected behaviour would be to fail with EOPNOTSUPP or a similar error code.

Also, please note that no such unexpected behaviour is observed for UDP sockets (AF_INET and AF_INET6). The bug seems to affect only UNIX sockets (AF_LOCAL). See attached a simple program that illustrates the bug.
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2021-10-02 04:37:56 UTC
This was fixed by glebius@ here: https://cgit.freebsd.org/src/commit/?id=beb4b312004b -- the fix is in all supported releases.