commit: 8c0d212ca4afbec9338562b6c0788f8af7ec9108 Author: Aric Belsito <lluixhi <AT> gmail <DOT> com> AuthorDate: Thu Nov 17 22:00:18 2016 +0000 Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com> CommitDate: Thu Nov 17 22:00:18 2016 +0000 URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=8c0d212c
sys-apps/sandbox: Add missing patches. sys-apps/sandbox/Manifest | 2 + .../sandbox/files/sandbox-2.11-exec-hash.patch | 96 ++++++++++++++++++++++ sys-apps/sandbox/files/sandbox-2.11-execvpe.patch | 30 +++++++ 3 files changed, 128 insertions(+) diff --git a/sys-apps/sandbox/Manifest b/sys-apps/sandbox/Manifest index 4a8977c..07a34d9 100644 --- a/sys-apps/sandbox/Manifest +++ b/sys-apps/sandbox/Manifest @@ -2,7 +2,9 @@ AUX 09sandbox 37 SHA256 73e9e9d12ba54f1c649813ec86107924050528852c890a8ba1e28537 AUX sandbox-2.10-disable-same.patch 2547 SHA256 09a11cf077ae69684080d1f0fd8fe83683fdf5f061e0a7a5261ca03463fd554a SHA512 bf005fbde7b6ba88df36bb75064658764e488dd2f3c96a6f92c69ad3f2e8d2db12ba2c7bafa9656326b7fde73301c330f68bd064efa0fce2a7eb28fff6ce0a1e WHIRLPOOL 27f0df961dcedc70819ecd1d0f105fb7176ecd77127ab187025d9aa52df9faa43941314c71a998dd72658105dfec4c5c6d3341dbae18e18b409af7dc6d9c31d6 AUX sandbox-2.10-fix-visibility-musl.patch 573 SHA256 67f70fa39867eeeee45b343db78c73fdb6e63b8a1b52d3dc288894402239dd12 SHA512 a740e0b1a68c0609dc3080e88ab8ab87885fe05f5e0864d10ed76e8e7000f7879cb206342c38d4097c691a7c85d1936e98802b206084eb2af9f78bd43158d759 WHIRLPOOL 0c226daa4b6d36c2df001d3d67b9e4023944c5b010d1bc311d731c121dd94b533546479a7b1b77bcb8be608ecf70508fb7dd65b22bafdb2d13a2860c9c0659da AUX sandbox-2.10-memory-corruption.patch 1515 SHA256 4876cc9962d56d3c5fc5418fe12ef1a399e34ff0272f12640c4a5c5b775e8888 SHA512 1eb650824cc7a876fabef382cafb451a507326a8422fb7bb5014699046b64ea8f4cf2bba9efcb75d7a2eac4eff493d06153422f85c119f49635ac0840071660c WHIRLPOOL db2c834119c7887ed746154e73e88cc09bf2a31184b3cda2732b70cb43dd8bc7f59f1072a4cc56ebcf593ba67330b9888832dc186ee55e009428d607f62293ab +AUX sandbox-2.11-exec-hash.patch 4310 SHA256 e9dbdab6b1db8cbe547aa94057fce55bc6a5e59cf4bfc0b607cf35123a20b981 SHA512 8830c0a4a9c81a61ae7f749d690791a0d9f467d28872976681a1a7995e7f703d06928bd7e392d2042da5452979c39e28783f73803419d782c3ace4e949adbd70 WHIRLPOOL 053e584c1675d43ffc98d25aa5d6f897b635fb3fdb3c036287d6a4a9f9ac36ad871890390003efe87c2177e2d077f428461eb59eb880c6df7f302f1c12218a75 AUX sandbox-2.11-exec-prelink.patch 4960 SHA256 a8dda45a024a42b7b6fbc2ee49a461879eb866ab915c268079704e1698dd0cef SHA512 9bccda3a940aa95d7542c23e3eeb3b58326bc81920fdcfa6dd3e3c40de5ca9c47948f93afe9e58753b6cf3af10342bf581116f038b29c9fa5c25fd0027c5551c WHIRLPOOL 0e99a04fe636287570ad31998c93b9be8eceeb7a6619f18089d7f4a2df4b9c400874ea132a6e8a3855fbee439607d7e7e583fcad3ef4a0fee0cc46b0b5943bf5 +AUX sandbox-2.11-execvpe.patch 986 SHA256 28574866614505b0f65dae5af4a90128997a40c402c6fbe80e809fedad93c113 SHA512 594b8e008178c1d8fa174733e95a02ad6bab1f025225b57e5c224a0b86021a0213cc30a83f607a47aff8756fa561e093b112384a89cc6c842cf2eb7f474e1213 WHIRLPOOL 7309559f0788fafefe17532b88265ed695bdba0836329aad3a4720b0e5d944ea5808dc7f08e0837edb2595da741c033a80cb67e74246a4ba63782497ffd95d7f AUX sandbox-2.11-musl.patch 1851 SHA256 1f2586e81a06daf7b69642d9c5fbf53563832a4ccd769ec696d9c2baabd2874c SHA512 2800191fbf312d9b8858ef29975355ae51a4aff05ccc7c425f5168fe2db24562e4cf164e8ee35ecc77e0777be9d37cc52d66fdd4bf3eaeb0fc4c68c240a0cb61 WHIRLPOOL 9c2abfcd5f68391c4890beeaf99020a9160635c888de7b45238174e7ac51ffac393150698feb0061fd3104e71a6825f9be98e5495a415ede8d2493a77f3e35e8 AUX sandbox-2.6-musl.patch 1821 SHA256 df08faebffbfade91a2620ff8b56c2087e4a34506fbff3dcf9bc35c2d5bd467c SHA512 69d11e80c97a844c0d84404e802950c876edda8eb7909c90f6f5d4b3fe8a33b5bc884ecc3741c10c8bd7e0871db2db1853cfac969a153d162423b3f3c94039c9 WHIRLPOOL 7120eaf3062cb18c3b13a61fe2b6f839a5f267650d9aa809fafc6d25e8faaadd7af3d5fb41cce66ecf71668555847d264ea977442f03f4dfe7b88b98cf86f78e DIST sandbox-2.10.tar.xz 417068 SHA256 019d6a2646b3a5f9b6fc3fcb6ff99332901017eb845442bec8573b9901506fa6 SHA512 178b3b8fcb54e6ff67df1c8101866739b49e4d31a66717c21ef502dd2ab609fca70f1a0c662b913e207bfc1ba6994cefdcf5c92ff32add9dd98bd9707f301305 WHIRLPOOL 5d6cffa7317cafeba02af75de9ae914d4365a62b54d3dfcc14cb272e621f2f76a60a945591ccb57dd59d6750152087cb2f21e43ded3ec181d6b42df173147192 diff --git a/sys-apps/sandbox/files/sandbox-2.11-exec-hash.patch b/sys-apps/sandbox/files/sandbox-2.11-exec-hash.patch new file mode 100644 index 0000000..8a4cd9b --- /dev/null +++ b/sys-apps/sandbox/files/sandbox-2.11-exec-hash.patch @@ -0,0 +1,96 @@ +From e11815bb7f0656f39e122073e0e3284ec7f5d021 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger <vap...@gentoo.org> +Date: Tue, 29 Mar 2016 23:35:44 -0400 +Subject: [PATCH] libsandbox: fix symtab walking with some ELFs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The strtab assumption works if there is no SysV hash table. +Add logic to handle that scenario. + +URL: https://bugs.gentoo.org/578524 +Reported-by: Toralf Förster <toralf.foers...@gmx.de> +Signed-off-by: Mike Frysinger <vap...@gentoo.org> +--- + libsandbox/wrapper-funcs/__wrapper_exec.c | 30 +++++++++++++++++------------- + 1 file changed, 17 insertions(+), 13 deletions(-) + +diff --git a/libsandbox/wrapper-funcs/__wrapper_exec.c b/libsandbox/wrapper-funcs/__wrapper_exec.c +index f7f51ab..d372366 100644 +--- a/libsandbox/wrapper-funcs/__wrapper_exec.c ++++ b/libsandbox/wrapper-funcs/__wrapper_exec.c +@@ -83,10 +83,10 @@ static bool sb_check_exec(const char *filename, char *const argv[]) + ({ \ + Elf##n##_Ehdr *ehdr = (void *)elf; \ + Elf##n##_Phdr *phdr = (void *)(elf + ehdr->e_phoff); \ +- Elf##n##_Addr vaddr, filesz, vsym = 0, vstr = 0; \ +- Elf##n##_Off offset, symoff = 0, stroff = 0; \ ++ Elf##n##_Addr vaddr, filesz, vsym = 0, vstr = 0, vhash = 0; \ ++ Elf##n##_Off offset, symoff = 0, stroff = 0, hashoff = 0; \ + Elf##n##_Dyn *dyn; \ +- Elf##n##_Sym *sym; \ ++ Elf##n##_Sym *sym, *symend; \ + uint##n##_t ent_size = 0, str_size = 0; \ + bool dynamic = false; \ + size_t i; \ +@@ -106,6 +106,7 @@ static bool sb_check_exec(const char *filename, char *const argv[]) + case DT_SYMENT: ent_size = dyn->d_un.d_val; break; \ + case DT_STRTAB: vstr = dyn->d_un.d_val; break; \ + case DT_STRSZ: str_size = dyn->d_un.d_val; break; \ ++ case DT_HASH: vhash = dyn->d_un.d_val; break; \ + } \ + ++dyn; \ + } \ +@@ -123,6 +124,8 @@ static bool sb_check_exec(const char *filename, char *const argv[]) + symoff = offset + (vsym - vaddr); \ + if (vstr >= vaddr && vstr < vaddr + filesz) \ + stroff = offset + (vstr - vaddr); \ ++ if (vhash >= vaddr && vhash < vaddr + filesz) \ ++ hashoff = offset + (vhash - vaddr); \ + } \ + \ + /* Finally walk the symbol table. This should generally be fast as \ +@@ -130,18 +133,20 @@ static bool sb_check_exec(const char *filename, char *const argv[]) + * out there do not export any symbols at all. \ + */ \ + if (symoff && stroff) { \ +- sym = (void *)(elf + symoff); \ ++ /* Hash entries are always 32-bits. */ \ ++ uint32_t *hashes = (void *)(elf + hashoff); \ + /* Nowhere is the # of symbols recorded, or the size of the symbol \ +- * table. Instead, we do what glibc does: assume that the string \ +- * table always follows the symbol table. This seems like a poor \ +- * assumption to make, but glibc has gotten by this long. We could \ +- * rely on DT_HASH and walking all the buckets to find the largest \ +- * symbol index, but that's also a bit hacky. \ ++ * table. Instead, we do what glibc does: use the sysv hash table \ ++ * if it exists, else assume that the string table always directly \ ++ * follows the symbol table. This seems like a poor assumption to \ ++ * make, but glibc has gotten by this long. \ + * \ + * We don't sanity check the ranges here as you aren't executing \ + * corrupt programs in the sandbox. \ + */ \ +- for (i = 0; i < (vstr - vsym) / ent_size; ++i) { \ ++ sym = (void *)(elf + symoff); \ ++ symend = vhash ? (sym + hashes[1]) : (void *)(elf + stroff); \ ++ while (sym < symend) { \ + char *symname = (void *)(elf + stroff + sym->st_name); \ + if (ELF##n##_ST_VISIBILITY(sym->st_other) == STV_DEFAULT && \ + sym->st_shndx != SHN_UNDEF && sym->st_shndx < SHN_LORESERVE && \ +@@ -149,9 +154,8 @@ static bool sb_check_exec(const char *filename, char *const argv[]) + /* Minor optimization to avoid strcmp. */ \ + symname[0] == '_' && symname[1] == '_') { \ + /* Blacklist internal C library symbols. */ \ +- size_t j; \ +- for (j = 0; j < ARRAY_SIZE(libc_alloc_syms); ++j) \ +- if (!strcmp(symname, libc_alloc_syms[j])) { \ ++ for (i = 0; i < ARRAY_SIZE(libc_alloc_syms); ++i) \ ++ if (!strcmp(symname, libc_alloc_syms[i])) { \ + run_in_process = false; \ + goto use_trace; \ + } \ +-- +2.7.4 + diff --git a/sys-apps/sandbox/files/sandbox-2.11-execvpe.patch b/sys-apps/sandbox/files/sandbox-2.11-execvpe.patch new file mode 100644 index 0000000..7e8130b --- /dev/null +++ b/sys-apps/sandbox/files/sandbox-2.11-execvpe.patch @@ -0,0 +1,30 @@ +From 31a135d261a9bc1d65b1fa484345a858bab84db8 Mon Sep 17 00:00:00 2001 +From: Mike Frysinger <vap...@gentoo.org> +Date: Wed, 30 Mar 2016 01:17:21 -0400 +Subject: [PATCH] libsandbox: whitelist execvpe +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +URL: https://bugs.gentoo.org/578516 +Reported-by: Toralf Förster <toralf.foers...@gmx.de> +Signed-off-by: Mike Frysinger <vap...@gentoo.org> +--- + libsandbox/libsandbox.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c +index cbe1aa1..e809308 100644 +--- a/libsandbox/libsandbox.c ++++ b/libsandbox/libsandbox.c +@@ -710,6 +710,7 @@ static int check_access(sbcontext_t *sbcontext, int sb_nr, const char *func, + sb_nr == SB_NR_EXECV || + sb_nr == SB_NR_EXECVP || + sb_nr == SB_NR_EXECVE || ++ sb_nr == SB_NR_EXECVPE || + sb_nr == SB_NR_FEXECVE)) + { + retval = check_prefixes(sbcontext->read_prefixes, +-- +2.7.4 +