🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: muc.lists.freebsd.bugs
1 messages
1 total messages Started by bugzilla-noreply Mon, 02 Nov 2026 14:25
[Bug 300446] sendmsg with data and SCM_RIGHTS incorrectly queues and delivers file descriptors on failure (EAGAIN) when the peer...
#329
Author: bugzilla-noreply
Date: Mon, 02 Nov 2026 14:25
100 lines
5143 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300446

            Bug ID: 300446
           Summary: sendmsg with data and SCM_RIGHTS incorrectly queues
                    and delivers file descriptors on failure (EAGAIN) when
                    the peer's buffer free space exactly matches the
                    control message size
           Product: Base System
           Version: 15.1-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: alejo@murena.io
 Attachment #276916 text/plain
         mime type:

Created attachment 276916
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=276916&action=edit
minimal reproducible example

Overview: 

On an AF_UNIX stream or seqpacket socket, when the peer's receive buffer has
free space exactly equal to the size of the internalized control message,
sendmsg with data and SCM_RIGHTS queues the control message, sends no data, and
fails with EAGAIN/EWOULDBLOCK. Although the system call fails, the file
descriptor incorrectly reaches the peer. Under SA_RESTART, the kernel
automatically restarts the call, leading to duplicate delivery of the
descriptor.


Steps to Reproduce: 

Due to the quite specific case, it's almost impossible to run into the bug in
real life. So I prepared a special test (scm_rights_eagain.c in the
attachment). Compile and execute it on a FreeBSD host where the receiver leaves
24 bytes free in its buffer:
`cc scm_rights_eagain.c`
and run
`./scm_rights_eagain`

Observe the output across the three execution modes: no retry, explicit retry,
and SA_RESTART.


Actual Results: 

No retry: sendmsg returns -1 (Resource temporarily unavailable); recvmsg gets 0
bytes and 1 fd.
Retry: sendmsg returns -1 (Resource temporarily unavailable), followed by a
successful retry (sendmsg 2), and recvmsg gets 2 bytes and 2 fds.
SA_RESTART: sendmsg returns 2 (ok), and recvmsg gets 2 bytes and 2 fds
(duplicate descriptor delivery).


Expected Results: 

A failed sendmsg call should be atomic and leave no side effects; descriptors
should not be delivered to the peer if the system call fails or returns an
error. The same way as if only 23 bytes were free.


Build Date & Hardware: 

Version: 15.1-RELEASE-p4 (releng/15.1-n283627-e38a7085f3a8 GENERIC)


Additional Builds and Platforms: 

Introduced via commit d15792780760 (unix: new implementation of unix/stream &
unix/seqpacket).
releng/14.3 does not contain this implementation and is unaffected.


Additional Information: 

While it's unclear if this bug can be exploited, it remains a correctness
question.
Code Reference: sys/kern/uipc_usrreq.c, uipc_sosend_stream_or_seqpacket()

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads