[systemd-devel] [PATCH 2/2] journald: fix fd leak in journal_file_empty

2013-09-04 Thread George McCollister
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 george.mccollis...@gmail.com
---
 src/journal/journal-vacuum.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c
index ace7722..2cfc73c 100644
--- a/src/journal/journal-vacuum.c
+++ b/src/journal/journal-vacuum.c
@@ -136,12 +136,18 @@ static int journal_file_empty(int dir_fd, const char 
*name) {
 if (fd  0)
 return -errno;
 
-if (lseek(fd, offsetof(Header, n_entries), SEEK_SET)  0)
+if (lseek(fd, offsetof(Header, n_entries), SEEK_SET)  0) {
+close(fd);
 return -errno;
+}
 
 r = read(fd, n_entries, sizeof(n_entries));
-if (r != sizeof(n_entries))
+if (r != sizeof(n_entries)) {
+close(fd);
 return r == 0 ? -EINVAL : -errno;
+}
+
+close(fd);
 
 return le64toh(n_entries) == 0;
 }
-- 
1.8.2.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] libudev: fix memleak when enumerating childs

2013-09-04 Thread Kay Sievers
On Wed, Sep 4, 2013 at 12:36 PM, David Herrmann dh.herrm...@gmail.com wrote:
 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.

Applied.

Thanks,
Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] cgtop: fixup the online help

2013-09-04 Thread Kay Sievers
On Wed, Sep 4, 2013 at 6:41 AM, Brandon Philips bran...@ifup.co wrote:
 The online help shows the keys as uppercase but the code and manpage say
 lower case. Make the online help follow reality.

Applied.

Thanks,
Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/2] systemd-coredump: Ignore coredumps larger than COREDUMP_MAX

2013-09-04 Thread Andrew Cook
Currently this check happens when the coredump has been collected in
it's entirety and being received by journald. this is not ideal
behaviour when the crashing process is consuming significant percentage
of physical memory such as a large instance of firefox or a java
application.

---
 src/journal/coredump.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)





diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index fd03e38..a7d3c34 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -41,7 +41,7 @@
 #define COREDUMP_MIN_START (3*1024*1024)
 /* Make sure to not make this larger than the maximum journal entry
  * size. See ENTRY_SIZE_MAX in journald-native.c. */
-#define COREDUMP_MAX (768*1024*1024)
+#define COREDUMP_MAX (767*1024*1024)
 
 enum {
 ARG_PID = 1,
@@ -258,6 +258,12 @@ int main(int argc, char* argv[]) {
 break;
 
 coredump_size += n;
+
+if(coredump_size  COREDUMP_MAX) {
+log_error(Coredump too large, ignoring);
+goto finish;
+}
+
 if (!GREEDY_REALLOC(coredump_data, coredump_bufsize, coredump_size + 1)) {
 r = log_oom();
 goto finish;




___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 2/2] systemd-coredump: Log crashes without coredumps on failure

2013-09-04 Thread Andrew Cook
Make a best-effort attempt to store information about crashes during
failure, currently if these are encountered the crash is completely
silenced.

ideally coredumpctl would show if a coredump is available.

---
 src/journal/coredump.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)




diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index a7d3c34..68c353f 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -241,7 +241,7 @@ int main(int argc, char* argv[]) {
 coredump_data = malloc(coredump_bufsize);
 if (!coredump_data) {
 r = log_oom();
-goto finish;
+goto finalize;
 }
 
 memcpy(coredump_data, COREDUMP=, 9);
@@ -261,12 +261,12 @@ int main(int argc, char* argv[]) {
 
 if(coredump_size  COREDUMP_MAX) {
 log_error(Coredump too large, ignoring);
-goto finish;
+goto finalize;
 }
 
 if (!GREEDY_REALLOC(coredump_data, coredump_bufsize, coredump_size + 1)) {
 r = log_oom();
-goto finish;
+goto finalize;
 }
 }
 
@@ -274,6 +274,7 @@ int main(int argc, char* argv[]) {
 iovec[j].iov_len = coredump_size;
 j++;
 
+finalize:
 r = sd_journal_sendv(iovec, j);
 if (r  0)
 log_error(Failed to send coredump: %s, strerror(-r));



___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] libudev: enumerate: fix NULL-deref for subsystem-matches

2013-09-04 Thread Kay Sievers
On Fri, Aug 30, 2013 at 3:50 PM, David Herrmann dh.herrm...@gmail.com wrote:
 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.

Yeah, seems we never handled that properly.

The lazy evaluation of properties can return NULL if the device is
removed between creating it and asking for the values.

 Instead of testing for it in each helper, we treat subsystem==NULL as
 empty subsystem in match_subsystem().

Applied.

Thanks,
Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel