[systemd-devel] Authenticating "sd bus" fails with Invalid argument

magnus at minimum.se magnus at minimum.se
Wed Jun 20 10:45:11 UTC 2018


Hey,
On Tue, Jun 19, 2018 at 15:30, Simon McVittie  wrote:
On Tue, 19 Jun 2018 at 12:32:19 +0000, magnus at minimum.se (mailto:magnus at minimum.se) wrote:
The system is on a quite old kernel (3.18.44)
...
At this point, things go wrong when
recvmsg() is called on bus->input_fd with flags MSG_DONTWAIT|MSG_NOSIGNAL|
MSG_CMSG_CLOEXEC. This syscall returns -22 (Invalid argument) which propagates
all the way up to the user.

(I hate the way kernel/syscall/libc error-reporting isn't accompanied
by a human-readable message that could tell you *which* argument is
invalid... compare with GLib/D-Bus errors)

MSG_NOSIGNAL is meaningless for recvmsg()
 so it's possible
that your older kernel doesn't allow it, but newer kernels allow and
ignore it? sd-bus should probably only use that flag for sendmsg()
and the rest of the send(2) family.

You are right, if I remove the MSG_NOSIGNAL flag to recvmsg() everything works (systemd-logind, busctl etc). I was unable to locate the place in my kernel code where it actually rejects MSG_NOSIGNAL for recvmsg(), but I think your theory is sane: 3.18.44 rejects it, newer kernels ignore it.
I can send a patch that removes use of MSG_NOSIGNAL in recvmsg() if you are willing to accept it. I think there should be no side effects for users of newer kernels.

smcv
_______________________________________________
systemd-devel mailing list
systemd-devel at lists.freedesktop.org (mailto:systemd-devel at lists.freedesktop.org)
https://lists.freedesktop.org/mailman/listinfo/systemd-devel (https://lists.freedesktop.org/mailman/listinfo/systemd-devel)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20180620/194b67f2/attachment.html>


More information about the systemd-devel mailing list