Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: src



Module Name:    src
Committed By:   riastradh
Date:           Fri Oct  2 01:31:31 UTC 2026

Modified Files:
        src/sys/kern: uipc_socket2.c
        src/tests/kernel: t_fdpass.c

Log Message:
sendmsg(2): Don't fail with ENOBUFS on fd passing.

We don't fail with ENOBUFS if we're not fd-passing -- we just block
or fail earlier on with EAGAIN; no reason to invent a new failure
mode just for the fd-passing case.

Whether we should have _any_ path that checks the receiving socket's
receive buffer limit is another question, but it's silly for it to:
1. apply _only_ when passing fds,
2. trip only when the kernel internally expands the buffer, and/or
3. fail with ENOBUFS instead of blocking or failing with EAGAIN.

This change essentially matches FreeBSD's subversion r337328:

commit 5b0480f2cca0a4a04f21055ed769be93f11348de
Author: Mark Johnston <markj%FreeBSD.org@localhost>
Date:   Sat Aug 4 20:26:54 2018 +0000

    Don't check rcv sockbuf limits when sending on a unix stream socket.

    sosend_generic() performs an initial comparison of the amount of data
    (including control messages) to be transmitted with the send buffer
    size. When transmitting on a unix socket, we then compare the amount
    of data being sent with the amount of space in the receive buffer size;
    if insufficient space is available, sbappendcontrol() returns an error
    and the data is lost.  This is easily triggered by sending control
    messages together with an amount of data roughly equal to the send
    buffer size, since the control message size may change in uipc_send()
    as file descriptors are internalized.

    Fix the problem by removing the space check in sbappendcontrol(),
    whose only consumer is the unix sockets code.  The stream sockets code
    uses the SB_STOP mechanism to ensure that senders will block if the
    receive buffer fills up.

    PR:             181741
    MFC after:      1 month
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D16515

https://cgit.freebsd.org/src/commit/?id=5b0480f2cca0a4a04f21055ed769be93f11348de

PR kern/60832: AF_LOCAL stream: sendmsg() with SCM_RIGHTS silently
drops data and descriptors but reports success


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/kern/uipc_socket2.c
cvs rdiff -u -r1.3 -r1.4 src/tests/kernel/t_fdpass.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index