]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/portable/portable.c
tree-wide: use recvmsg_safe() at various places 15504/head
authorLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 07:40:03 +0000 (09:40 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 23 Apr 2020 07:41:47 +0000 (09:41 +0200)
commit3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1
treecaff7067ab4c3b4c5871c1869ed4e806c65f512d
parent47eae6ce0c28b1984f8f5ec4c2f7bc428cf3b6ad
tree-wide: use recvmsg_safe() at various places

Let's be extra careful whenever we return from recvmsg() and see
MSG_CTRUNC set. This generally means we ran into a programming error, as
we didn't size the control buffer large enough. It's an error condition
we should at least log about, or propagate up. Hence do that.

This is particularly important when receiving fds, since for those the
control data can be of any size. In particular on stream sockets that's
nasty, because if we miss an fd because of control data truncation we
cannot recover, we might not even realize that we are one off.

(Also, when failing early, if there's any chance the socket might be
AF_UNIX let's close all received fds, all the time. We got this right
most of the time, but there were a few cases missing. God, UNIX is hard
to use)
15 files changed:
src/basic/socket-util.c
src/core/manager.c
src/coredump/coredump.c
src/home/homed-manager.c
src/import/importd.c
src/journal/journald-server.c
src/journal/journald-stream.c
src/libsystemd/sd-bus/bus-socket.c
src/nspawn/nspawn.c
src/portable/portable.c
src/resolve/resolved-manager.c
src/shared/ask-password-api.c
src/timesync/timesyncd-manager.c
src/udev/udev-ctrl.c
src/udev/udevd.c