From 89f67f97477aeba24aebfc58ae1a17e5bea69724 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Sun, 9 Dec 2012 05:10:14 +0100 Subject: [PATCH] iv_event_raw: Deal with eventfd() EINVAL return. The Linux glibc eventfd() wrapper function (around the SYS_eventfd{,2} system calls) returns EINVAL if it is given a nonzero flags argument and SYS_eventfd2 (which is the variant of SYS_eventfd that takes a flags argument) isn't implemented, while iv_event_raw was expecting to get either ENOSYS or success. Instead of falling back on SYS_eventfd by calling the eventfd() wrapper again with a zero flags argument and then setting the O_NONBLOCK and O_CLOEXEC flags by hand, disable use of eventfd on systems that have SYS_eventfd but not SYS_eventfd2 as a minimally invasive fix for the stable branches. Reported by user "Dit" on the Balabit community forums. Signed-off-by: Lennert Buytenhek --- modules/iv_event_raw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/iv_event_raw.c b/modules/iv_event_raw.c index 5afe967..5e0a936 100644 --- a/modules/iv_event_raw.c +++ b/modules/iv_event_raw.c @@ -41,7 +41,7 @@ static int grab_eventfd(void) fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); if (fd < 0) { - if (errno != ENOSYS) + if (errno != EINVAL && errno != ENOSYS) perror("eventfd"); return -errno; } @@ -96,7 +96,7 @@ int iv_event_raw_register(struct iv_event_raw *this) ret = grab_eventfd(); if (ret < 0) { - if (ret != -ENOSYS) + if (ret != -EINVAL && ret != -ENOSYS) return -1; eventfd_unavailable = 1; } else {