summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2014-06-04 17:47:25 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-06-06 09:26:04 +0100
commit85dea57cbea0fb672bfdd6c28ff2942381dff334 (patch)
treee87fdbeabb8ecf54d215ca9faa373eb98d50970d
parent22ff50f3cb5e5ad11c83d19dbd4e89cc7faee729 (diff)
downloadpoky-85dea57cbea0fb672bfdd6c28ff2942381dff334.tar.gz
systemd: update a uclibc specific patch to avoid segment fault error
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] (From OE-Core rev: c69816d2bf84369ba578bf9d92e01c9d91351a64) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/systemd/systemd/systemd-pam-fix-fallocate.patch56
1 files 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 cfca0b95a6..f8e19ce172 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 @@
1Upstream-Status: Denied [no desire for uclibc support] 1Upstream-Status: Denied [no desire for uclibc support]
2
3This patch is uclibc specific, thus not suitable for upstream.
4
2Signed-off-by: Khem Raj <raj.khem@gmail.com> 5Signed-off-by: Khem Raj <raj.khem@gmail.com>
6Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
7---
8 src/journal/journal-file.c | 16 +++++++++++++++-
9 src/journal/journald-kmsg.c | 16 ++++++++++++++--
10 2 files changed, 29 insertions(+), 3 deletions(-)
3 11
4Index: git/src/journal/journal-file.c 12diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
5=================================================================== 13index f2f1f35..092f87b 100644
6--- git.orig/src/journal/journal-file.c 2014-04-22 22:53:05.000000000 -0700 14--- a/src/journal/journal-file.c
7+++ git/src/journal/journal-file.c 2014-04-22 22:53:51.130236707 -0700 15+++ b/src/journal/journal-file.c
8@@ -38,6 +38,8 @@ 16@@ -38,6 +38,8 @@
9 #include "compress.h" 17 #include "compress.h"
10 #include "fsprg.h" 18 #include "fsprg.h"
@@ -14,7 +22,7 @@ Index: git/src/journal/journal-file.c
14 #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem)) 22 #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem))
15 #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem)) 23 #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem))
16 24
17@@ -314,7 +316,7 @@ 25@@ -314,7 +316,7 @@ static int journal_file_verify_header(JournalFile *f) {
18 26
19 static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) { 27 static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) {
20 uint64_t old_size, new_size; 28 uint64_t old_size, new_size;
@@ -23,7 +31,7 @@ Index: git/src/journal/journal-file.c
23 31
24 assert(f); 32 assert(f);
25 33
26@@ -362,9 +364,24 @@ 34@@ -362,9 +364,21 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
27 /* Note that the glibc fallocate() fallback is very 35 /* Note that the glibc fallocate() fallback is very
28 inefficient, hence we try to minimize the allocation area 36 inefficient, hence we try to minimize the allocation area
29 as we can. */ 37 as we can. */
@@ -32,27 +40,24 @@ Index: git/src/journal/journal-file.c
32 if (r != 0) 40 if (r != 0)
33 return -r; 41 return -r;
34+#else 42+#else
35+ /* Use good old method to write zeros into the journal file 43+ /* Write something every 512 bytes to make sure the block is allocated */
36+ perhaps very inefficient yet working. */ 44+ uint64_t len = new_size - old_size;
37+ if(new_size > old_size) { 45+ uint64_t offset = old_size;
38+ char *buf = alloca(new_size - old_size); 46+ for (offset += (len-1) % 512; len > 0; offset += 512) {
39+ off_t oldpos = lseek(f->fd, 0, SEEK_CUR); 47+ len -= 512;
40+ bzero(buf, new_size - old_size); 48+ if (pwrite(f->fd, "", 1, offset) != 1)
41+ lseek(f->fd, old_size, SEEK_SET); 49+ return -errno;
42+ r = write(f->fd, buf, new_size - old_size); 50+ }
43+ lseek(f->fd, oldpos, SEEK_SET); 51+
44+ }
45+ if (r < 0)
46+ return -errno;
47+#endif /* HAVE_POSIX_FALLOCATE */ 52+#endif /* HAVE_POSIX_FALLOCATE */
48 53
49 if (fstat(f->fd, &f->last_stat) < 0) 54 if (fstat(f->fd, &f->last_stat) < 0)
50 return -errno; 55 return -errno;
51Index: git/src/journal/journald-kmsg.c 56diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
52=================================================================== 57index 12992e7..dc4fa93 100644
53--- git.orig/src/journal/journald-kmsg.c 2014-04-22 22:53:05.000000000 -0700 58--- a/src/journal/journald-kmsg.c
54+++ git/src/journal/journald-kmsg.c 2014-04-22 22:54:27.830236809 -0700 59+++ b/src/journal/journald-kmsg.c
55@@ -437,6 +437,7 @@ 60@@ -437,6 +437,7 @@ fail:
56 int server_open_kernel_seqnum(Server *s) { 61 int server_open_kernel_seqnum(Server *s) {
57 _cleanup_close_ int fd; 62 _cleanup_close_ int fd;
58 uint64_t *p; 63 uint64_t *p;
@@ -60,7 +65,7 @@ Index: git/src/journal/journald-kmsg.c
60 65
61 assert(s); 66 assert(s);
62 67
63@@ -449,8 +450,19 @@ 68@@ -449,8 +450,19 @@ int server_open_kernel_seqnum(Server *s) {
64 log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m"); 69 log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m");
65 return 0; 70 return 0;
66 } 71 }
@@ -82,3 +87,6 @@ Index: git/src/journal/journald-kmsg.c
82 log_error("Failed to allocate sequential number file, ignoring: %m"); 87 log_error("Failed to allocate sequential number file, ignoring: %m");
83 return 0; 88 return 0;
84 } 89 }
90--
911.7.9.5
92