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