Fix for the empty notify message fuckup

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2016-09-29 05:42:52 -04:00
parent 726f6ebadc
commit fff97bd061
3 changed files with 84 additions and 2 deletions

View File

@ -0,0 +1,48 @@
From 619c8d786f8441dfe7fd9787533be8dfb9cc8a14 Mon Sep 17 00:00:00 2001
From: Fedora systemd team <systemd-maint@redhat.com>
Date: Sat, 1 Oct 2016 11:23:32 -0400
Subject: [PATCH] Fix notification assert and return value from handler
---
src/core/manager.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/core/manager.c b/src/core/manager.c
index a1f37bbbb3..ea92e7aebf 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1484,7 +1484,6 @@ static void manager_invoke_notify_message(Manager *m, Unit *u, pid_t pid, char *
assert(m);
assert(u);
assert(buf);
- assert(n > 0);
tags = strv_split(buf, "\n\r");
if (!tags) {
@@ -1538,10 +1537,10 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
n = recvmsg(m->notify_fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
if (n < 0) {
- if (errno == EAGAIN || errno == EINTR)
- break;
+ if (!IN_SET(errno, EAGAIN, EINTR))
+ log_error("Failed to receive notification message: %m");
- return -errno;
+ return 0;
}
CMSG_FOREACH(cmsg, &msghdr) {
@@ -1564,7 +1563,8 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
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.9.0

View File

@ -0,0 +1,31 @@
From 1f74d99193e7d2b0546e641aba25259d9a646e5d Mon Sep 17 00:00:00 2001
From: Jorge Niedbalski <jorge.niedbalski@canonical.com>
Date: Wed, 28 Sep 2016 18:25:50 -0300
Subject: [PATCH] If the notification message length is 0, ignore the message
(#4237)
Fixes #4234.
Signed-off-by: Jorge Niedbalski <jnr@metaklass.org>
---
src/core/manager.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/core/manager.c b/src/core/manager.c
index f36cf5e320..6bd32ed920 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -1557,6 +1557,10 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
return -errno;
}
+ if (n == 0) {
+ log_debug("Got zero-length notification message. Ignoring.");
+ return 0;
+ }
CMSG_FOREACH(cmsg, &msghdr) {
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) {
--
2.9.0

View File

@ -13,7 +13,7 @@
Name: systemd
Url: http://www.freedesktop.org/wiki/Software/systemd
Version: 222
Release: 16%{?gitcommit:.git%{gitcommit}}%{?dist}
Release: 17%{?gitcommit:.git%{gitcommit}}%{?dist}
# For a breakdown of the licensing, see README
License: LGPLv2+ and MIT and GPLv2+
Summary: A System and Service Manager
@ -119,12 +119,12 @@ Patch0083: 0083-ask-password-api-only-emit-a-star-on-valid-unicode-c.patch
Patch0084: 0084-core-add-new-RandomSec-setting-for-time-units.patch
Patch0085: 0085-core-rename-Random-to-RandomizedDelay.patch
Patch0086: 0086-macros.systemd.in-add-systemd_ordering-3776.patch
Patch0087: If-the-notification-message-length-is-0-ignore-the-m.patch
Patch997: 0001-Re-apply-walters-unit-patch-for-F23-systemd-v222.patch
Patch998: 0001-Revert-core-mount-add-dependencies-to-dynamically-mo-v222.patch
Patch999: 0047-Pass-pointer-to-unit-object-instead-of-unit-id.patch
# kernel-install patch for grubby, drop if grubby is obsolete
Patch1000: kernel-install-grubby.patch
@ -860,6 +860,9 @@ getent passwd systemd-journal-upload >/dev/null 2>&1 || useradd -r -l -g systemd
/usr/lib/firewalld/services/*
%changelog
* Thu Sep 29 2016 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 229-17
- Denial-of-service bug against pid1 (#1380286)
* Wed Aug 17 2016 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 222-16
- Ignore the access mode on /var/log/journal (#1317570)
- Add %%systemd_ordering macro