]> git.ipfire.org Git - thirdparty/linux.git/commit
af_unix: don't post cmsg for SO_INQ unless explicitly asked for
authorJens Axboe <axboe@kernel.dk>
Thu, 18 Dec 2025 22:21:28 +0000 (15:21 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Sun, 28 Dec 2025 15:11:22 +0000 (16:11 +0100)
commit4d1442979e4a53b9457ce1e373e187e1511ff688
treee9f0b7ad6e98a9abf792553b052cb68ee67cf1fb
parent3387a7ad478b46970ae8254049167d166e398aeb
af_unix: don't post cmsg for SO_INQ unless explicitly asked for

A previous commit added SO_INQ support for AF_UNIX (SOCK_STREAM), but it
posts a SCM_INQ cmsg even if just msg->msg_get_inq is set. This is
incorrect, as ->msg_get_inq is just the caller asking for the remainder
to be passed back in msg->msg_inq, it has nothing to do with cmsg. The
original commit states that this is done to make sockets
io_uring-friendly", but it's actually incorrect as io_uring doesn't use
cmsg headers internally at all, and it's actively wrong as this means
that cmsg's are always posted if someone does recvmsg via io_uring.

Fix that up by only posting a cmsg if u->recvmsg_inq is set.

Additionally, mirror how TCP handles inquiry handling in that it should
only be done for a successful return. This makes the logic for the two
identical.

Cc: stable@vger.kernel.org
Fixes: df30285b3670 ("af_unix: Introduce SO_INQ.")
Reported-by: Julian Orth <ju.orth@gmail.com>
Link: https://github.com/axboe/liburing/issues/1509
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/07adc0c2-2c3b-4d08-8af1-1c466a40b6a8@kernel.dk
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/unix/af_unix.c