From 5bd86eaddb658a7d41f84acd28bb247d37c69b47 Mon Sep 17 00:00:00 2001 From: Celina Sophie Kalus Date: Wed, 10 Apr 2024 11:41:32 +0200 Subject: [PATCH] posix: eventfd: Fix unsetting internal flags in ioctl Commit e6eb0a705bc8 ("posix: eventfd: revise locking, signaling, and allocation") introduced a regression where the internal flags of an event file descriptor would be erased when calling the F_SETFL ioctl operation. This includes the flag EFD_IN_USE_INTERNAL which determines whether this file descriptor has been opened, thus effectively closing the eventfd whenever one tries to change a flag. Signed-off-by: Celina Sophie Kalus --- lib/posix/options/eventfd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/posix/options/eventfd.c b/lib/posix/options/eventfd.c index 767cf5a60cc..81b8f6d6dd8 100644 --- a/lib/posix/options/eventfd.c +++ b/lib/posix/options/eventfd.c @@ -247,7 +247,9 @@ static int eventfd_ioctl_op(void *obj, unsigned int request, va_list args) errno = EINVAL; ret = -1; } else { - efd->flags = flags; + int prev_flags = efd->flags & ~EFD_FLAGS_SET_INTERNAL; + + efd->flags = flags | prev_flags; ret = 0; } } break;