1 |
commit: 33a9bf25d218173400e1115011ed867e84b4bf38 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 19 18:15:05 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Dec 19 18:15:25 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=33a9bf25 |
7 |
|
8 |
sys-apps/sandbox: fix memory corruption #568714 |
9 |
|
10 |
.../files/sandbox-2.10-memory-corruption.patch | 42 ++++++++++++++++++++++ |
11 |
...{sandbox-2.10.ebuild => sandbox-2.10-r1.ebuild} | 1 + |
12 |
2 files changed, 43 insertions(+) |
13 |
|
14 |
diff --git a/sys-apps/sandbox/files/sandbox-2.10-memory-corruption.patch b/sys-apps/sandbox/files/sandbox-2.10-memory-corruption.patch |
15 |
new file mode 100644 |
16 |
index 0000000..7dd27c9 |
17 |
--- /dev/null |
18 |
+++ b/sys-apps/sandbox/files/sandbox-2.10-memory-corruption.patch |
19 |
@@ -0,0 +1,42 @@ |
20 |
+From 529a388ebb1b4e9d6ad8a1bb61dd8211833a5976 Mon Sep 17 00:00:00 2001 |
21 |
+From: Denis Lisov <dennis.lissov@×××××.com> |
22 |
+Date: Sat, 19 Dec 2015 19:13:58 +0300 |
23 |
+Subject: [PATCH] libsandbox: fix old_malloc_size check on realloc |
24 |
+ |
25 |
+Realloc uses SB_MALLOC_TO_SIZE assuming it returns the usable size, |
26 |
+while it is really the mmap size, which is greater. Thus it may fail |
27 |
+to reallocate even if required. |
28 |
+ |
29 |
+URL: https://bugs.gentoo.org/568714 |
30 |
+Signed-off-by: Denis Lisov <dennis.lissov@×××××.com> |
31 |
+Signed-off-by: Mike Frysinger <vapier@g.o> |
32 |
+--- |
33 |
+ libsandbox/memory.c | 5 +++-- |
34 |
+ 1 file changed, 3 insertions(+), 2 deletions(-) |
35 |
+ |
36 |
+diff --git a/libsandbox/memory.c b/libsandbox/memory.c |
37 |
+index 8581128..a2d69a2 100644 |
38 |
+--- a/libsandbox/memory.c |
39 |
++++ b/libsandbox/memory.c |
40 |
+@@ -40,7 +40,8 @@ static int sb_munmap(void *addr, size_t length) |
41 |
+ |
42 |
+ #define SB_MALLOC_TO_MMAP(ptr) ((void*)((uintptr_t)(ptr) - MIN_ALIGN)) |
43 |
+ #define SB_MMAP_TO_MALLOC(ptr) ((void*)((uintptr_t)(ptr) + MIN_ALIGN)) |
44 |
+-#define SB_MALLOC_TO_SIZE(ptr) (*((size_t*)SB_MALLOC_TO_MMAP(ptr))) |
45 |
++#define SB_MALLOC_TO_MMAP_SIZE(ptr) (*((size_t*)SB_MALLOC_TO_MMAP(ptr))) |
46 |
++#define SB_MALLOC_TO_SIZE(ptr) (SB_MALLOC_TO_MMAP_SIZE(ptr) - MIN_ALIGN) |
47 |
+ |
48 |
+ void *malloc(size_t size) |
49 |
+ { |
50 |
+@@ -57,7 +58,7 @@ void free(void *ptr) |
51 |
+ { |
52 |
+ if (ptr == NULL) |
53 |
+ return; |
54 |
+- if (munmap(SB_MALLOC_TO_MMAP(ptr), SB_MALLOC_TO_SIZE(ptr))) |
55 |
++ if (munmap(SB_MALLOC_TO_MMAP(ptr), SB_MALLOC_TO_MMAP_SIZE(ptr))) |
56 |
+ sb_ebort("sandbox memory corruption with free(%p): %s\n", |
57 |
+ ptr, strerror(errno)); |
58 |
+ } |
59 |
+-- |
60 |
+2.6.2 |
61 |
+ |
62 |
|
63 |
diff --git a/sys-apps/sandbox/sandbox-2.10.ebuild b/sys-apps/sandbox/sandbox-2.10-r1.ebuild |
64 |
similarity index 97% |
65 |
rename from sys-apps/sandbox/sandbox-2.10.ebuild |
66 |
rename to sys-apps/sandbox/sandbox-2.10-r1.ebuild |
67 |
index 2550852..9df5d29 100644 |
68 |
--- a/sys-apps/sandbox/sandbox-2.10.ebuild |
69 |
+++ b/sys-apps/sandbox/sandbox-2.10-r1.ebuild |
70 |
@@ -46,6 +46,7 @@ sb_foreach_abi() { |
71 |
src_unpack() { |
72 |
unpacker |
73 |
cd "${S}" |
74 |
+ epatch "${FILESDIR}"/${P}-memory-corruption.patch #568714 |
75 |
epatch_user |
76 |
} |