From db3a9fa0d988569a2d8005c8911c95729e235ee9 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Fri, 6 Sep 2013 07:47:41 +0200 Subject: [PATCH] systemd-206-11 - support "debug" kernel command line parameter - journald: fix fd leak in journal_file_empty - journald: fix vacuuming of archived journals - libudev: enumerate - do not try to match against an empty subsystem - cgtop: fixup the online help - libudev: fix memleak when enumerating childs --- ...-debug-is-used-on-the-kernel-command.patch | 30 ++++++++++++ ...-fix-memleak-when-enumerating-childs.patch | 49 +++++++++++++++++++ 0044-cgtop-fixup-the-online-help.patch | 27 ++++++++++ ...e-fix-NULL-deref-for-subsystem-match.patch | 44 +++++++++++++++++ ...e-do-not-try-to-match-against-an-emp.patch | 38 ++++++++++++++ ...d-fix-vacuuming-of-archived-journals.patch | 42 ++++++++++++++++ ...ld-fix-fd-leak-in-journal_file_empty.patch | 32 ++++++++++++ systemd.spec | 18 ++++++- 8 files changed, 278 insertions(+), 2 deletions(-) create mode 100644 0042-log-to-kmsg-when-debug-is-used-on-the-kernel-command.patch create mode 100644 0043-libudev-fix-memleak-when-enumerating-childs.patch create mode 100644 0044-cgtop-fixup-the-online-help.patch create mode 100644 0045-libudev-enumerate-fix-NULL-deref-for-subsystem-match.patch create mode 100644 0046-libudev-enumerate-do-not-try-to-match-against-an-emp.patch create mode 100644 0047-journald-fix-vacuuming-of-archived-journals.patch create mode 100644 0048-journald-fix-fd-leak-in-journal_file_empty.patch diff --git a/0042-log-to-kmsg-when-debug-is-used-on-the-kernel-command.patch b/0042-log-to-kmsg-when-debug-is-used-on-the-kernel-command.patch new file mode 100644 index 0000000..0b4bbf8 --- /dev/null +++ b/0042-log-to-kmsg-when-debug-is-used-on-the-kernel-command.patch @@ -0,0 +1,30 @@ +From ea7df0ea7dd50f119f5f6b8cecffdbbbe49deda0 Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Tue, 27 Aug 2013 18:25:06 +0200 +Subject: [PATCH] log to kmsg when "debug" is used on the kernel command line + +--- + src/core/main.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/core/main.c b/src/core/main.c +index 77cdcfe..716def7 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -413,9 +413,14 @@ static int parse_proc_cmdline_word(const char *word) { + + } else if (streq(word, "quiet")) + arg_show_status = false; +- else if (streq(word, "debug")) ++ else if (streq(word, "debug")) { ++ /* Log to kmsg, the journal socket will fill up before the ++ * journal is started and tools running during that time ++ * will block with every log message for for 60 seconds, ++ * before they give up. */ + log_set_max_level(LOG_DEBUG); +- else if (!in_initrd()) { ++ log_set_target(LOG_TARGET_KMSG); ++ } else if (!in_initrd()) { + unsigned i; + + /* SysV compatibility */ diff --git a/0043-libudev-fix-memleak-when-enumerating-childs.patch b/0043-libudev-fix-memleak-when-enumerating-childs.patch new file mode 100644 index 0000000..cf471f8 --- /dev/null +++ b/0043-libudev-fix-memleak-when-enumerating-childs.patch @@ -0,0 +1,49 @@ +From 407df48ed36526f773dcc60ab6cef0f5ce441fe7 Mon Sep 17 00:00:00 2001 +From: David Herrmann +Date: Wed, 4 Sep 2013 12:36:19 +0200 +Subject: [PATCH] libudev: fix memleak when enumerating childs + +We need to free udev-devices again if they don't match. Funny that no-one +noticed it yet since valgrind is quite verbose about it. +Fix it and free non-matching devices. +--- + src/libudev/libudev-enumerate.c | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c +index 3e79107..b96e5b2 100644 +--- a/src/libudev/libudev-enumerate.c ++++ b/src/libudev/libudev-enumerate.c +@@ -829,23 +829,27 @@ nomatch: + static int parent_add_child(struct udev_enumerate *enumerate, const char *path) + { + struct udev_device *dev; ++ int r = 0; + + dev = udev_device_new_from_syspath(enumerate->udev, path); + if (dev == NULL) + return -ENODEV; + + if (!match_subsystem(enumerate, udev_device_get_subsystem(dev))) +- return 0; ++ goto nomatch; + if (!match_sysname(enumerate, udev_device_get_sysname(dev))) +- return 0; ++ goto nomatch; + if (!match_property(enumerate, dev)) +- return 0; ++ goto nomatch; + if (!match_sysattr(enumerate, dev)) +- return 0; ++ goto nomatch; + + syspath_add(enumerate, udev_device_get_syspath(dev)); ++ r = 1; ++ ++nomatch: + udev_device_unref(dev); +- return 1; ++ return r; + } + + static int parent_crawl_children(struct udev_enumerate *enumerate, const char *path, int maxdepth) diff --git a/0044-cgtop-fixup-the-online-help.patch b/0044-cgtop-fixup-the-online-help.patch new file mode 100644 index 0000000..0eccf77 --- /dev/null +++ b/0044-cgtop-fixup-the-online-help.patch @@ -0,0 +1,27 @@ +From 3af2fb43cba8a683cbe8bbcb3bc44dbce8d553af Mon Sep 17 00:00:00 2001 +From: Brandon Philips +Date: Tue, 3 Sep 2013 21:34:02 -0700 +Subject: [PATCH] cgtop: fixup the online help + +The online help shows the keys as uppercase but the code and manpage say +lower case. Make the online help follow reality. +--- + src/cgtop/cgtop.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c +index fb523a3..cacf705 100644 +--- a/src/cgtop/cgtop.c ++++ b/src/cgtop/cgtop.c +@@ -824,9 +824,9 @@ int main(int argc, char *argv[]) { + case '?': + case 'h': + fprintf(stdout, +- "\t<" ON "P" OFF "> By path; <" ON "T" OFF "> By tasks; <" ON "C" OFF "> By CPU; <" ON "M" OFF "> By memory; <" ON "I" OFF "> By I/O\n" ++ "\t<" ON "p" OFF "> By path; <" ON "t" OFF "> By tasks; <" ON "c" OFF "> By CPU; <" ON "m" OFF "> By memory; <" ON "i" OFF "> By I/O\n" + "\t<" ON "+" OFF "> Increase delay; <" ON "-" OFF "> Decrease delay; <" ON "%%" OFF "> Toggle time\n" +- "\t<" ON "Q" OFF "> Quit; <" ON "SPACE" OFF "> Refresh"); ++ "\t<" ON "q" OFF "> Quit; <" ON "SPACE" OFF "> Refresh"); + fflush(stdout); + sleep(3); + break; diff --git a/0045-libudev-enumerate-fix-NULL-deref-for-subsystem-match.patch b/0045-libudev-enumerate-fix-NULL-deref-for-subsystem-match.patch new file mode 100644 index 0000000..e143776 --- /dev/null +++ b/0045-libudev-enumerate-fix-NULL-deref-for-subsystem-match.patch @@ -0,0 +1,44 @@ +From 8d74c49c208f4e36ef844a584557fc5577272c27 Mon Sep 17 00:00:00 2001 +From: David Herrmann +Date: Fri, 30 Aug 2013 15:50:41 +0200 +Subject: [PATCH] libudev: enumerate: fix NULL-deref for subsystem-matches + +udev_device_get_subsystem() may return NULL if no subsystem could be +figured out by libudev. This might be due to OOM or if the device +disconnected between the udev_device_new() call and +udev_device_get_subsystem(). Therefore, we need to handle subsystem==NULL +safely. + +Instead of testing for it in each helper, we treat subsystem==NULL as +empty subsystem in match_subsystem(). + +Backtrace of udev_enumerate with an input-device disconnecting in exactly +this time-frame: + (gdb) bt + #0 0x00007ffff569dc24 in strnlen () from /usr/lib/libc.so.6 + #1 0x00007ffff56d9e04 in fnmatch@@GLIBC_2.2.5 () from /usr/lib/libc.so.6 + #2 0x00007ffff5beb83d in match_subsystem (udev_enumerate=0x7a05f0, subsystem=0x0) at src/libudev/libudev-enumerate.c:727 + #3 0x00007ffff5bebb30 in parent_add_child (enumerate=enumerate@entry=0x7a05f0, path=) at src/libudev/libudev-enumerate.c:834 + #4 0x00007ffff5bebc3f in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=0x7a56b0 "/sys/devices//input/input97", maxdepth=maxdepth@entry=254) at src/libudev/libudev-enumerate.c:866 + #5 0x00007ffff5bebc54 in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=0x79e8c0 "/sys/devices//input", maxdepth=maxdepth@entry=255) at src/libudev/libudev-enumerate.c:868 + #6 0x00007ffff5bebc54 in parent_crawl_children (enumerate=enumerate@entry=0x7a05f0, path=path@entry=0x753190 "/sys/devices/", maxdepth=maxdepth@entry=256) at src/libudev/libudev-enumerate.c:868 + #7 0x00007ffff5bec7df in scan_devices_children (enumerate=0x7a05f0) at src/libudev/libudev-enumerate.c:882 + #8 udev_enumerate_scan_devices (udev_enumerate=udev_enumerate@entry=0x7a05f0) at src/libudev/libudev-enumerate.c:919 + #9 0x00007ffff5df8777 in () at some/file.c:181 +--- + src/libudev/libudev-enumerate.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c +index b96e5b2..385829d 100644 +--- a/src/libudev/libudev-enumerate.c ++++ b/src/libudev/libudev-enumerate.c +@@ -721,6 +721,8 @@ static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *s + { + struct udev_list_entry *list_entry; + ++ subsystem = subsystem ? : ""; ++ + udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_nomatch_list)) { + if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0) + return false; diff --git a/0046-libudev-enumerate-do-not-try-to-match-against-an-emp.patch b/0046-libudev-enumerate-do-not-try-to-match-against-an-emp.patch new file mode 100644 index 0000000..fa630ff --- /dev/null +++ b/0046-libudev-enumerate-do-not-try-to-match-against-an-emp.patch @@ -0,0 +1,38 @@ +From 138ef72fbc2264a341873c1cf8c771c1c143922a Mon Sep 17 00:00:00 2001 +From: Kay Sievers +Date: Wed, 4 Sep 2013 17:59:14 +0200 +Subject: [PATCH] libudev: enumerate - do not try to match against an empty + subsystem + +--- + src/libudev/libudev-enumerate.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c +index 385829d..bc1e37d 100644 +--- a/src/libudev/libudev-enumerate.c ++++ b/src/libudev/libudev-enumerate.c +@@ -721,12 +721,14 @@ static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *s + { + struct udev_list_entry *list_entry; + +- subsystem = subsystem ? : ""; ++ if (!subsystem) ++ return false; + + udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_nomatch_list)) { + if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0) + return false; + } ++ + if (udev_list_get_entry(&udev_enumerate->subsystem_match_list) != NULL) { + udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_match_list)) { + if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0) +@@ -734,6 +736,7 @@ static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *s + } + return false; + } ++ + return true; + } + diff --git a/0047-journald-fix-vacuuming-of-archived-journals.patch b/0047-journald-fix-vacuuming-of-archived-journals.patch new file mode 100644 index 0000000..8dc2355 --- /dev/null +++ b/0047-journald-fix-vacuuming-of-archived-journals.patch @@ -0,0 +1,42 @@ +From 2c284b172a7474731df01a7c3280e30de844ba75 Mon Sep 17 00:00:00 2001 +From: George McCollister +Date: Wed, 4 Sep 2013 07:12:43 -0500 +Subject: [PATCH] journald: fix vacuuming of archived journals + +d_name is modified on line 227 so if the entire journal name is needed +again p must be used. Before this change when journal_file_empty was called +on archived journals it would always return with -2. + +Signed-off-by: George McCollister +--- + src/journal/journal-vacuum.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c +index 79572f1..ace7722 100644 +--- a/src/journal/journal-vacuum.c ++++ b/src/journal/journal-vacuum.c +@@ -265,18 +265,18 @@ int journal_directory_vacuum( + /* We do not vacuum active files or unknown files! */ + continue; + +- if (journal_file_empty(dirfd(d), de->d_name)) { ++ if (journal_file_empty(dirfd(d), p)) { + + /* Always vacuum empty non-online files. */ + +- if (unlinkat(dirfd(d), de->d_name, 0) >= 0) +- log_debug("Deleted empty journal %s/%s.", directory, de->d_name); ++ if (unlinkat(dirfd(d), p, 0) >= 0) ++ log_debug("Deleted empty journal %s/%s.", directory, p); + else if (errno != ENOENT) +- log_warning("Failed to delete %s/%s: %m", directory, de->d_name); ++ log_warning("Failed to delete %s/%s: %m", directory, p); + continue; + } + +- patch_realtime(directory, de->d_name, &st, &realtime); ++ patch_realtime(directory, p, &st, &realtime); + + GREEDY_REALLOC(list, n_allocated, n_list + 1); + diff --git a/0048-journald-fix-fd-leak-in-journal_file_empty.patch b/0048-journald-fix-fd-leak-in-journal_file_empty.patch new file mode 100644 index 0000000..0f9cd82 --- /dev/null +++ b/0048-journald-fix-fd-leak-in-journal_file_empty.patch @@ -0,0 +1,32 @@ +From f29938b8d28e574ae614f6db4e70478d8ccac4d0 Mon Sep 17 00:00:00 2001 +From: George McCollister +Date: Wed, 4 Sep 2013 07:12:44 -0500 +Subject: [PATCH] journald: fix fd leak in journal_file_empty + +Before my previous patch, journal_file_empty wasn't be called with the +correct filename. Now that it's being called with the correct filename +it leaks file descriptors. This patch closes the file descriptors before +returning. + +Signed-off-by: George McCollister + +[Edit harald@redhat.com: make use of _cleanup_close_ instead] +--- + src/journal/journal-vacuum.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c +index ace7722..178c803 100644 +--- a/src/journal/journal-vacuum.c ++++ b/src/journal/journal-vacuum.c +@@ -129,8 +129,9 @@ static void patch_realtime( + } + + static int journal_file_empty(int dir_fd, const char *name) { +- int fd, r; ++ int r; + le64_t n_entries; ++ _cleanup_close_ int fd; + + fd = openat(dir_fd, name, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK); + if (fd < 0) diff --git a/systemd.spec b/systemd.spec index 31a3e56..bb9d98c 100644 --- a/systemd.spec +++ b/systemd.spec @@ -16,7 +16,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 206 -Release: 10%{?gitcommit:.git%{gitcommit}}%{?dist} +Release: 11%{?gitcommit:.git%{gitcommit}}%{?dist} # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: A System and Service Manager @@ -75,7 +75,13 @@ Patch0038: 0038-journal-fix-parsing-of-facility-in-syslog-messages.patch Patch0039: 0039-cgroup.c-check-return-value-of-unit_realize_cgroup_n.patch Patch0040: 0040-Revert-cgroup.c-check-return-value-of-unit_realize_c.patch Patch0041: 0041-Do-not-realloc-strings-which-are-already-in-the-hash.patch - +Patch0042: 0042-log-to-kmsg-when-debug-is-used-on-the-kernel-command.patch +Patch0043: 0043-libudev-fix-memleak-when-enumerating-childs.patch +Patch0044: 0044-cgtop-fixup-the-online-help.patch +Patch0045: 0045-libudev-enumerate-fix-NULL-deref-for-subsystem-match.patch +Patch0046: 0046-libudev-enumerate-do-not-try-to-match-against-an-emp.patch +Patch0047: 0047-journald-fix-vacuuming-of-archived-journals.patch +Patch0048: 0048-journald-fix-fd-leak-in-journal_file_empty.patch # kernel-install patch for grubby, drop if grubby is obsolete Patch1000: kernel-install-grubby.patch @@ -697,6 +703,14 @@ getent passwd systemd-journal-gateway >/dev/null 2>&1 || useradd -r -l -u 191 -g %{_datadir}/systemd/gatewayd %changelog +* Fri Sep 06 2013 Harald Hoyer 206-11 +- support "debug" kernel command line parameter +- journald: fix fd leak in journal_file_empty +- journald: fix vacuuming of archived journals +- libudev: enumerate - do not try to match against an empty subsystem +- cgtop: fixup the online help +- libudev: fix memleak when enumerating childs + * Wed Sep 04 2013 Harald Hoyer 206-10 - Do not require grubby, lorax now takes care of grubby - cherry-picked a lot of patches from upstream