Bug 212167

Summary: listen() system call succeeds for a locally bound UNIX-domain datagram-oriented socket
Product: Base System Reporter: Arseny Vakhrushev <arseny.vakhrushev>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: kevans
Priority: ---    
Version: 10.3-STABLE   
Hardware: Any   
OS: Any   
Description Flags
Simple program that illustrates the bug none

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 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.