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

Lennart Poettering lennart at poettering.net
Wed Jun 20 11:08:42 UTC 2018


On Mi, 20.06.18 10:45, magnus at minimum.se (magnus at minimum.se) wrote:

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

I have prepped a PR for this now:

https://github.com/systemd/systemd/pull/9354

It drops the flag tree-wide for all recvmsg() invocations. PTAL.

(Also, there's something really wrong with your mailer, the ML
archiver and text MUAs will show your mail as being signed by Simon,
which is quite misleading)

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list