]> git.ipfire.org Git - thirdparty/dhcpcd.git/commit
privsep: enforce message boundaries with MSG_EOR on our messages (#533)
authorGleb Smirnoff <glebius@FreeBSD.org>
Tue, 30 Sep 2025 07:54:35 +0000 (00:54 -0700)
committerGitHub <noreply@github.com>
Tue, 30 Sep 2025 07:54:35 +0000 (08:54 +0100)
commitb709538cbbc7e480e479ac82149adb073bb01531
tree6d312a30afaf335640cd382061d7dfad69aa9daa
parent6dcb1569fc782a8f8a5e8855faee5aadcc769554
privsep: enforce message boundaries with MSG_EOR on our messages (#533)

privsep: enforce message boundaries with MSG_EOR on our messages

The nature of the SOCK_SEQPACKET, that privsep modules uses, is stream.
See:

https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_10_06

To guarantee that a reader will never read two messages in one read
operation, the writer shall put end of record markers.

The problem exposed itself in FreeBSD 15.0 that started to follow the
specification better than before.

Other SOCK_SEQPACKET usage considerations: a) as long as our reader
provides a receive buffer that would fit the largest message our writer
would ever send, we are good with regards to not a reading a partial
message b) as long as our writer always write full messages with one
write, we don't need use of MSG_WAITALL in reader.

Fixes #530

Co-authored-by: Roy Marples <roy@marples.name>
src/dhcpcd.c
src/logerr.c
src/logerr.h
src/privsep-root.c
src/privsep.c