All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] systemd: update a uclibc specific patch to avoid segment fault error
@ 2014-06-04  9:47 Chen Qi
  2014-06-04  9:47 ` [PATCH 1/1] " Chen Qi
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Qi @ 2014-06-04  9:47 UTC (permalink / raw)
  To: openembedded-core

The following changes since commit f8125a1e9b6893a12355d55d4df584a8d97f0bff:

  image_types: Fix ubi filesystem return codes (2014-06-03 16:45:18 +0100)

are available in the git repository at:

  git://git.openembedded.org/openembedded-core-contrib ChenQi/systemd-uclibc-alloca
  http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=ChenQi/systemd-uclibc-alloca

Chen Qi (1):
  systemd: update a uclibc specific patch to avoid segment fault error

 .../systemd/systemd-pam-fix-fallocate.patch        |   56 +++++++++++---------
 1 file changed, 32 insertions(+), 24 deletions(-)

-- 
1.7.9.5



^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH 1/1] systemd: update a uclibc specific patch to avoid segment fault error
  2014-06-04  9:47 [PATCH 0/1] systemd: update a uclibc specific patch to avoid segment fault error Chen Qi
@ 2014-06-04  9:47 ` Chen Qi
  0 siblings, 0 replies; 2+ messages in thread
From: Chen Qi @ 2014-06-04  9:47 UTC (permalink / raw)
  To: openembedded-core

The alloca() function allocates space in the stack frame of the caller,
so using alloca(new_size - old_size) would possibly crash the stack,
causing a segment fault error.

This patch fixes the above problem by avoiding using this function in
journal-file.c.

[YOCTO #6201]

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
---
 .../systemd/systemd-pam-fix-fallocate.patch        |   56 +++++++++++---------
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
index cfca0b9..f8e19ce 100644
--- a/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
+++ b/meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch
@@ -1,10 +1,18 @@
 Upstream-Status: Denied [no desire for uclibc support]
+
+This patch is uclibc specific, thus not suitable for upstream.
+
 Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+---
+ src/journal/journal-file.c  |   16 +++++++++++++++-
+ src/journal/journald-kmsg.c |   16 ++++++++++++++--
+ 2 files changed, 29 insertions(+), 3 deletions(-)
 
-Index: git/src/journal/journal-file.c
-===================================================================
---- git.orig/src/journal/journal-file.c	2014-04-22 22:53:05.000000000 -0700
-+++ git/src/journal/journal-file.c	2014-04-22 22:53:51.130236707 -0700
+diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
+index f2f1f35..092f87b 100644
+--- a/src/journal/journal-file.c
++++ b/src/journal/journal-file.c
 @@ -38,6 +38,8 @@
  #include "compress.h"
  #include "fsprg.h"
@@ -14,7 +22,7 @@ Index: git/src/journal/journal-file.c
  #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem))
  #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem))
  
-@@ -314,7 +316,7 @@
+@@ -314,7 +316,7 @@ static int journal_file_verify_header(JournalFile *f) {
  
  static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) {
          uint64_t old_size, new_size;
@@ -23,7 +31,7 @@ Index: git/src/journal/journal-file.c
  
          assert(f);
  
-@@ -362,9 +364,24 @@
+@@ -362,9 +364,21 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
          /* Note that the glibc fallocate() fallback is very
             inefficient, hence we try to minimize the allocation area
             as we can. */
@@ -32,27 +40,24 @@ Index: git/src/journal/journal-file.c
          if (r != 0)
                  return -r;
 +#else
-+       /* Use good old method to write zeros into the journal file
-+          perhaps very inefficient yet working. */
-+       if(new_size > old_size) {
-+               char *buf = alloca(new_size - old_size);
-+               off_t oldpos = lseek(f->fd, 0, SEEK_CUR);
-+               bzero(buf, new_size - old_size);
-+               lseek(f->fd, old_size, SEEK_SET);
-+               r = write(f->fd, buf, new_size - old_size);
-+               lseek(f->fd, oldpos, SEEK_SET);
-+       }
-+       if (r < 0)
-+               return -errno;
++        /* Write something every 512 bytes to make sure the block is allocated */
++        uint64_t len = new_size - old_size;
++        uint64_t offset = old_size;
++        for (offset += (len-1) % 512; len > 0; offset += 512) {
++                len -= 512;
++                if (pwrite(f->fd, "", 1, offset) != 1)
++                        return -errno;
++        }
++
 +#endif /* HAVE_POSIX_FALLOCATE */
  
          if (fstat(f->fd, &f->last_stat) < 0)
                  return -errno;
-Index: git/src/journal/journald-kmsg.c
-===================================================================
---- git.orig/src/journal/journald-kmsg.c	2014-04-22 22:53:05.000000000 -0700
-+++ git/src/journal/journald-kmsg.c	2014-04-22 22:54:27.830236809 -0700
-@@ -437,6 +437,7 @@
+diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
+index 12992e7..dc4fa93 100644
+--- a/src/journal/journald-kmsg.c
++++ b/src/journal/journald-kmsg.c
+@@ -437,6 +437,7 @@ fail:
  int server_open_kernel_seqnum(Server *s) {
          _cleanup_close_ int fd;
          uint64_t *p;
@@ -60,7 +65,7 @@ Index: git/src/journal/journald-kmsg.c
  
          assert(s);
  
-@@ -449,8 +450,19 @@
+@@ -449,8 +450,19 @@ int server_open_kernel_seqnum(Server *s) {
                  log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m");
                  return 0;
          }
@@ -82,3 +87,6 @@ Index: git/src/journal/journald-kmsg.c
                  log_error("Failed to allocate sequential number file, ignoring: %m");
                  return 0;
          }
+-- 
+1.7.9.5
+
-- 
1.7.9.5



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-04  9:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-04  9:47 [PATCH 0/1] systemd: update a uclibc specific patch to avoid segment fault error Chen Qi
2014-06-04  9:47 ` [PATCH 1/1] " Chen Qi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.