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