a19bc6
From 93c5087eed9abf8012dc5b0ccd2dd7ead1323899 Mon Sep 17 00:00:00 2001
c79076
From: Franck Bui <fbui@suse.com>
c79076
Date: Thu, 29 Sep 2016 19:44:34 +0200
c79076
Subject: [PATCH] pid1: don't return any error in manager_dispatch_notify_fd()
c79076
 (#4240)
c79076
c79076
If manager_dispatch_notify_fd() fails and returns an error then the handling of
c79076
service notifications will be disabled entirely leading to a compromised system.
c79076
c79076
For example pid1 won't be able to receive the WATCHDOG messages anymore and
c79076
will kill all services supposed to send such messages.
c79076
Cherry-picked from: 9987750e7a4c62e0eb8473603150596ba7c3a015
a19bc6
Resolves: #1380259
c79076
---
c79076
 src/core/manager.c | 13 +++++++++----
c79076
 1 file changed, 9 insertions(+), 4 deletions(-)
c79076
c79076
diff --git a/src/core/manager.c b/src/core/manager.c
c62b8e
index 689b266158..ed81059554 100644
c79076
--- a/src/core/manager.c
c79076
+++ b/src/core/manager.c
c79076
@@ -1673,10 +1673,14 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
c79076
 
c79076
         n = recvmsg(m->notify_fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
c79076
         if (n < 0) {
c79076
-                if (errno == EAGAIN || errno == EINTR)
c79076
-                        return 0;
c79076
+                if (!IN_SET(errno, EAGAIN, EINTR))
c79076
+                        log_error("Failed to receive notification message: %m");
c79076
 
c79076
-                return -errno;
c79076
+                /* It's not an option to return an error here since it
c79076
+                 * would disable the notification handler entirely. Services
c79076
+                 * wouldn't be able to send the WATCHDOG message for
c79076
+                 * example... */
c79076
+                return 0;
c79076
         }
c79076
         if (n == 0) {
c79076
                 log_debug("Got zero-length notification message. Ignoring.");
c79076
@@ -1703,7 +1707,8 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
c79076
                 r = fdset_new_array(&fds, fd_array, n_fds);
c79076
                 if (r < 0) {
c79076
                         close_many(fd_array, n_fds);
c79076
-                        return log_oom();
c79076
+                        log_oom();
c79076
+                        return 0;
c79076
                 }
c79076
         }
c79076