From b721c897983540efd176c2bf3329a471ab44a811 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Thu, 9 Jul 2015 20:16:05 +0000 Subject: During fd passing, receive_fd() tries to read the result value and the file descriptor. If the fd limit is exhausted, recvmsg(2) fails. The kernel discards the fd, but the result value stays in the socket. It has to be read on its own to keep the privsep parent and syslogd child in sync. OK benno@ --- usr.sbin/syslogd/privsep_fdpass.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'usr.sbin/syslogd/privsep_fdpass.c') diff --git a/usr.sbin/syslogd/privsep_fdpass.c b/usr.sbin/syslogd/privsep_fdpass.c index 94f32d199b5..4ef9d107580 100644 --- a/usr.sbin/syslogd/privsep_fdpass.c +++ b/usr.sbin/syslogd/privsep_fdpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep_fdpass.c,v 1.10 2015/07/06 16:12:16 millert Exp $ */ +/* $OpenBSD: privsep_fdpass.c,v 1.11 2015/07/09 20:16:04 bluhm Exp $ */ /* * Copyright 2001 Niels Provos @@ -104,6 +104,9 @@ receive_fd(int sock) if ((n = recvmsg(sock, &msg, 0)) == -1) { warn("%s: recvmsg", "receive_fd"); + /* receive message failed, but the result is in the socket */ + if (errno == EMSGSIZE) + recv(sock, &result, sizeof(int), MSG_DONTWAIT); return -1; } if (n != sizeof(int)) -- cgit v1.2.3