main/musl: fix popen/posix_spawn under qemu-user emulation

cherry-pick upstream commit working around the qemu-user deficiency.
This commit is contained in:
Timo Teräs 2013-07-17 21:12:15 +03:00
parent 07063077ed
commit 8bb80d7fa0
11 changed files with 93 additions and 39 deletions

View File

@ -1,8 +1,8 @@
From 997d58d8052fb9f8374afd2fb456785f53217f50 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Mon, 1 Jul 2013 13:43:43 -0400
Subject: [PATCH 1/9] fix Makefile so "make install" works before include/bits
symlink exists
Subject: [PATCH 01/10] fix Makefile so "make install" works before
include/bits symlink exists
previously, determination of the list of header files for installation
depended on the include/bits symlink (to the arch-specific files)

View File

@ -1,7 +1,7 @@
From 6e31b284fe98686f8a763de775a087da3be05024 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Mon, 1 Jul 2013 13:50:02 -0400
Subject: [PATCH 2/9] add stubs for additional legacy ether.h functions
Subject: [PATCH 02/10] add stubs for additional legacy ether.h functions
these would not be expensive to actually implement, but reading
/etc/ethers does not sound like a particularly useful feature, so for

View File

@ -1,7 +1,7 @@
From 5ece469f37e5cdddb86871b56f4f74674690fbe4 Mon Sep 17 00:00:00 2001
From: rofl0r <retnyg@gmx.net>
Date: Wed, 3 Jul 2013 17:52:44 +0200
Subject: [PATCH 3/9] add legacy scsi/scsi_ioctl.h header
Subject: [PATCH 03/10] add legacy scsi/scsi_ioctl.h header
---
include/scsi/scsi_ioctl.h | 11 +++++++++++

View File

@ -1,7 +1,7 @@
From 129a34db6328cb13fec4d5f2d2703cb7922e8634 Mon Sep 17 00:00:00 2001
From: rofl0r <retnyg@gmx.net>
Date: Wed, 3 Jul 2013 17:55:37 +0200
Subject: [PATCH 4/9] add legacy sys/ttydefaults.h header
Subject: [PATCH 04/10] add legacy sys/ttydefaults.h header
---
include/sys/ttydefaults.h | 39 +++++++++++++++++++++++++++++++++++++++

View File

@ -1,7 +1,7 @@
From 9b9dc74b67b9ecd30db9f3266a5ce309b0ffbfef Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Sat, 6 Jul 2013 01:12:28 -0400
Subject: [PATCH 5/9] add NFDBITS in sys/select.h with appropriate feature
Subject: [PATCH 05/10] add NFDBITS in sys/select.h with appropriate feature
tests
the main use for this macro seems to be knowing the correct allocation

View File

@ -1,7 +1,7 @@
From 9134a8ca79fa9c79eada278b10f4d6b1eaf271d3 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Tue, 9 Jul 2013 02:11:52 -0400
Subject: [PATCH 6/9] fix off-by-one array bound in strsignal
Subject: [PATCH 06/10] fix off-by-one array bound in strsignal
---
src/string/strsignal.c | 2 +-

View File

@ -1,8 +1,8 @@
From 0ccea50c697512b4bcbe76780260dfba09450327 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 10 Jul 2013 14:38:20 -0400
Subject: [PATCH 7/9] fix invalid library phdr pointers passed to callback from
dl_iterate_phdr
Subject: [PATCH 07/10] fix invalid library phdr pointers passed to callback
from dl_iterate_phdr
map_library was saving pointers to an automatic-storage buffer rather
than pointers into the mapping. this should be a fairly simple fix,

View File

@ -1,7 +1,7 @@
From f39afb9ffb34b747bfc1ec9d77b239c0c32a754d Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 10 Jul 2013 16:11:01 -0400
Subject: [PATCH 8/9] add some ARM EABI-specific exception handling
Subject: [PATCH 08/10] add some ARM EABI-specific exception handling
infrastructure
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8

View File

@ -1,7 +1,7 @@
From 84934ac8bcebb41ffca1703d97512682069c68ec Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 10 Jul 2013 16:58:27 -0400
Subject: [PATCH 9/9] add PIE support for ARM
Subject: [PATCH 09/10] add PIE support for ARM
---
crt/arm/Scrt1.s | 30 ++++++++++++++++++++++++++++++

View File

@ -0,0 +1,50 @@
From 53761b469221fbe062629c50249e3d534573eda9 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 17 Jul 2013 13:54:41 -0400
Subject: [PATCH 10/10] make posix_spawn (and functions that use it) use
CLONE_VFORK flag
this is both a minor scheduling optimization and a workaround for a
difficult-to-fix bug in qemu app-level emulation.
from the scheduling standpoint, it makes no sense to schedule the
parent thread again until the child has exec'd or exited, since the
parent will immediately block again waiting for it.
on the qemu side, as regular application code running on an underlying
libc, qemu cannot make arbitrary clone syscalls itself without
confusing the underlying implementation. instead, it breaks them down
into either fork-like or pthread_create-like cases. it was treating
the code in posix_spawn as pthread_create-like, due to CLONE_VM, which
caused horribly wrong behavior: CLONE_FILES broke the synchronization
mechanism, CLONE_SIGHAND broke the parent's signals, and CLONE_THREAD
caused the child's exec to end the parent -- if it hadn't already
crashed. however, qemu special-cases CLONE_VFORK and emulates that
with fork, even when CLONE_VM is also specified. this also gives
incorrect semantics for code that really needs the memory sharing, but
posix_spawn does not make use of the vm sharing except to avoid
momentary double commit charge.
programs using posix_spawn (including via popen) should now work
correctly under qemu app-level emulation.
---
src/process/posix_spawn.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
index e6a031c..68cf795 100644
--- a/src/process/posix_spawn.c
+++ b/src/process/posix_spawn.c
@@ -138,7 +138,8 @@ int __posix_spawnx(pid_t *restrict res, const char *restrict path,
args.envp = envp;
pthread_sigmask(SIG_BLOCK, SIGALL_SET, &args.oldmask);
- pid = __clone(child, stack+sizeof stack, CLONE_VM|SIGCHLD, &args);
+ pid = __clone(child, stack+sizeof stack,
+ CLONE_VM|CLONE_VFORK|SIGCHLD, &args);
close(args.p[1]);
if (pid > 0) {
--
1.8.3.2

View File

@ -2,7 +2,7 @@
# Maintainer: William Pitcock <nenolod@dereferenced.org>
pkgname=musl
pkgver=0.9.11
pkgrel=2
pkgrel=3
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="x86 x86_64 arm armel"
@ -23,6 +23,7 @@ source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
0007-fix-invalid-library-phdr-pointers-passed-to-callback.patch
0008-add-some-ARM-EABI-specific-exception-handling-infras.patch
0009-add-PIE-support-for-ARM.patch
0010-make-posix_spawn-and-functions-that-use-it-use-CLONE.patch
getopt_long.c
getent
@ -85,38 +86,41 @@ crosstool() {
}
md5sums="70b17ca5c847e74e1c77fe8284bb1fa4 musl-0.9.11.tar.gz
aad8311afd9731c4fc0b233b2f8fbea6 0001-fix-Makefile-so-make-install-works-before-include-bi.patch
784768d2852b9e92331b0e4a113885f0 0002-add-stubs-for-additional-legacy-ether.h-functions.patch
68972594ee10388b927c4dab8752ff40 0003-add-legacy-scsi-scsi_ioctl.h-header.patch
be8d8679592120ac58d8e8cd65955858 0004-add-legacy-sys-ttydefaults.h-header.patch
7e34c5d8e8b2561a5c208f45914f5098 0005-add-NFDBITS-in-sys-select.h-with-appropriate-feature.patch
dc3391e1c71f054457a94e96b5c439da 0006-fix-off-by-one-array-bound-in-strsignal.patch
2a34be5410b4b6f849ac65886fe512c0 0007-fix-invalid-library-phdr-pointers-passed-to-callback.patch
254ac95d521dd908739f2d9e361b9129 0008-add-some-ARM-EABI-specific-exception-handling-infras.patch
1eb1f8e1574a70bc39cc66aad536236b 0009-add-PIE-support-for-ARM.patch
cce3406fc07756f25181b71152e55865 0001-fix-Makefile-so-make-install-works-before-include-bi.patch
5ce3afcc1cfc332bebe53355fdd00d3c 0002-add-stubs-for-additional-legacy-ether.h-functions.patch
f0254759e89b0b000f33c8116eb1aac0 0003-add-legacy-scsi-scsi_ioctl.h-header.patch
7c01567c09bcf3f0d530a1e5fc57b932 0004-add-legacy-sys-ttydefaults.h-header.patch
3e5dd5906b99a7c79cd7eea0277b4310 0005-add-NFDBITS-in-sys-select.h-with-appropriate-feature.patch
45f147f5e49692320aec8b13b3ac66a6 0006-fix-off-by-one-array-bound-in-strsignal.patch
902ed8d04e08b912a0ab1166756c3455 0007-fix-invalid-library-phdr-pointers-passed-to-callback.patch
1763905f21ab6b94dfb2d6611c47a84d 0008-add-some-ARM-EABI-specific-exception-handling-infras.patch
980ad576c337b0bd75da128816a2e0a5 0009-add-PIE-support-for-ARM.patch
627a5b94e86e5d0ef4ed575d5e8da229 0010-make-posix_spawn-and-functions-that-use-it-use-CLONE.patch
acbb8a052228d9d5b89bc2ed55616fe3 getopt_long.c
ef81489a6258501cf45db58dfc6d5211 getent"
sha256sums="8b81fd9b71becb7b674ea93fd65d82a039fab79ab738957a5e9ee47ba08a13fd musl-0.9.11.tar.gz
55e07c49e420af16ee2783613b43cb2673b9f4006ede03d202faf53bd103a1c1 0001-fix-Makefile-so-make-install-works-before-include-bi.patch
76b9e2f477ac9c536293f0b7e48d87fdc267e87bda8990c406af8e5314bdc93b 0002-add-stubs-for-additional-legacy-ether.h-functions.patch
f0c51e603f9b45fbcf0a2a372a9867cda5d6a561367b6320dc9f221ac1d9f5d0 0003-add-legacy-scsi-scsi_ioctl.h-header.patch
ac580e372f3f35ecbf56ad4a2a245a2f6717be2ddf545169d89b2c7a8c471996 0004-add-legacy-sys-ttydefaults.h-header.patch
ebbb392854f4ff0bcf5687611c9d0793ebbcbd65824de1a8b861c6f35eeaa1ed 0005-add-NFDBITS-in-sys-select.h-with-appropriate-feature.patch
05b367fa68f444ab4722bddde88f01973fb850f696320a2a115626a5bff094d3 0006-fix-off-by-one-array-bound-in-strsignal.patch
a3de225c2b0e325333ecdfdf015ece988e8f0533f3056cfcd0b855680d7c2264 0007-fix-invalid-library-phdr-pointers-passed-to-callback.patch
d5af7765f2ec1f92f42d6d9d94fd1a1fefa876760141a4701a57db1d5d71e21a 0008-add-some-ARM-EABI-specific-exception-handling-infras.patch
25034a597d18f04fc371c97bc7ab014ff3ec2d185cfb3abc7d3bbcbc63fde3fc 0009-add-PIE-support-for-ARM.patch
61ed4546341484f682d70f57a9d3549d9c646f33c779adb171e31e13b7b62070 0001-fix-Makefile-so-make-install-works-before-include-bi.patch
a49a959e48225e5aa51576ac36c8e07eb064aeb00203d5c47cb201aee1238f40 0002-add-stubs-for-additional-legacy-ether.h-functions.patch
e74a7569444467ca705241e36f68b389826e6159fbd492c2fef843bb8128babf 0003-add-legacy-scsi-scsi_ioctl.h-header.patch
ce53c311a2bbaedce42e5f5749f9ea63f801bf5fa65bb4d406202d9e75f4c3c0 0004-add-legacy-sys-ttydefaults.h-header.patch
1ed281c07ac15f505d017e2034208b4b626af6604f24e53667c25690865fcd54 0005-add-NFDBITS-in-sys-select.h-with-appropriate-feature.patch
354d24787a00b1cd216c0505076cbbd612ed3f36804c596d969f0d628b425b9b 0006-fix-off-by-one-array-bound-in-strsignal.patch
2d640dbedb1674cf378b4caf53e32c1fb7b8b8bc302037f7328b87049479d763 0007-fix-invalid-library-phdr-pointers-passed-to-callback.patch
42cf78d84f6f03bfb5431a38f38b08ad752d466a63ec4197907d3ff2b6849ca7 0008-add-some-ARM-EABI-specific-exception-handling-infras.patch
d0c70b9806329d384752bf4d344176e5dea8a3facb0cfba9d5284d6281f52378 0009-add-PIE-support-for-ARM.patch
7efc54e1943db188bee5398e0d709778fca6578d44a73f215cd96f18a29a6d7b 0010-make-posix_spawn-and-functions-that-use-it-use-CLONE.patch
5427781da6c5877c017eeccba58c70bce3451536355ac949699ed807137a476a getopt_long.c
d6996273f5aaaed429058257e4646b243d9e3a4d8609522f802762453f5be4cb getent"
sha512sums="7ca852eda3be7b34bfdaf1eb9e7d435987d5177f865737b211e62f4037825cc322436e1ff49c3f875b3a20679f6f21ba5ffff271d03d3d03c7a97854f4f51832 musl-0.9.11.tar.gz
02eee7261d28d2cac59910839dfc7b9389bec8bee3f68dc21a0b1d4fd112ffddaae8aadf4392528773dc0c5a48715cdc525a2ba3a51ac5f34fb49e9ceb49e644 0001-fix-Makefile-so-make-install-works-before-include-bi.patch
4b71a25a539ee35a0183503ba28583a38fb96dffa38de63ff8ba0e62893f84e1832e22aca506e1d79e41e2b37c712acf38f479c6b46d5e3237c8158db2352b36 0002-add-stubs-for-additional-legacy-ether.h-functions.patch
b4b3724b754ad3cf56ffbfe9bdd4cafbebb14e1d16a094793a0bf2e219f29e0a7547e123664bd1d7ffa3149f4a52be387e391b5903f967a2f57fbb3161b4fdaf 0003-add-legacy-scsi-scsi_ioctl.h-header.patch
cab60cb2baf86128fd5d45d83ae0315afefce9e1d91b7c5fa3fffc02b1483f753eedae01f226fe339d693de44236292e7b79e3abcc25e823f955aab83889c629 0004-add-legacy-sys-ttydefaults.h-header.patch
e9cd8c3994a22f48288279b2678e24415ab29a8f462df087de63b7415581059d6bd412d17b7d7008cd97ac09276f514fc4bd6cd4e39ee2fd4d7c8591e8478f4c 0005-add-NFDBITS-in-sys-select.h-with-appropriate-feature.patch
20e91a56000ac53bf5d5db8e1f731a2f80824ee6e4a057d64e193601f3d45b1e3dbd836de82cf4c8d855eedb88e9a61f48c30b2b772840bdbd5c004c71cb0deb 0006-fix-off-by-one-array-bound-in-strsignal.patch
a70092efce1fbd02fd8c82bef5bb4c51c98f8023a5fdd7ec3c64519ceb98b72745b375d002c85c29d1adef09ac06bc433505f358e8c3516828291b3f8503626d 0007-fix-invalid-library-phdr-pointers-passed-to-callback.patch
20dd237aa8e9eda29fac0b443abe3ebb45692221425c31f4453d2f9a5394687d5befac00a755bf098b0ac3707ee8c5a52ebf78cc11c5d719f567afb626ddc2dd 0008-add-some-ARM-EABI-specific-exception-handling-infras.patch
b739639e90c8d6c985732dee44e2eadf12195876e60f64437a147fbbd5c758d84fb5078ef0c48ccb560d2c8f0b849e3e4670a2f1cd7f15c075b7b8a95563e2c8 0009-add-PIE-support-for-ARM.patch
69d387f9617757cc0ac66f5c9716c8167408bb848b39011e716a388b451bf3d85fd7ea810970d2deaf42e9b77844f15decb358a78cc6ec6b403fdf0a31a4ca29 0001-fix-Makefile-so-make-install-works-before-include-bi.patch
00a457844f49c43276efecf27f47d3e028cde7648d347b80c63c9f0ebe21baabe875ae6741490885f0d95b37103b31df59f23863d3cc0219c289db05e0ccdcb2 0002-add-stubs-for-additional-legacy-ether.h-functions.patch
eeb67bec8c2f3c1ef83c8bd8f72825745515db1f86d3ccedd74fee2515b003bc34262504a0564f56014fdf9dff7b7b863d6fecd589e7df46f213c37ad24e7709 0003-add-legacy-scsi-scsi_ioctl.h-header.patch
9644c0b932efbdf66b44df6565e1d3594ddcbbff77bd29459d7ee19d55e0857bcd8f3e51fc8be3d20190e22476ad2e09f53e9298466d3853d12b7297f4065463 0004-add-legacy-sys-ttydefaults.h-header.patch
f2b148e91f7df417c4577d00760ae511200a0402075613941cbbfae778c21578f0a887fa20899334a7c69e5c6c3a54d8410af25c81275e7d42879c2cfd7c30c5 0005-add-NFDBITS-in-sys-select.h-with-appropriate-feature.patch
e61e3483ac905b528afd421d1970e2e2f53f32cfadd4d6af6a6b00e73d861880c749234b8d1624e6048c59eb4f568ea47965bb3fb6f161ca55ab2d819403b9d6 0006-fix-off-by-one-array-bound-in-strsignal.patch
3198cd0b8ca0e587f108f7250f45f2f10d0b6202cc7fc4b58cf89e3780a38bfe856b6be312957e27de81b02adf7a20dcf7baa36c2f5f831729f88875224ccc7c 0007-fix-invalid-library-phdr-pointers-passed-to-callback.patch
915d0e7cdd56f369759ea314e54c29d57c012df1ff0d9459f1b0ac941320e5bf5de3e7215224075aead4b6d3a60b7e0dba7f28de75a6c477ae6bf6caf1b65d28 0008-add-some-ARM-EABI-specific-exception-handling-infras.patch
8eb9a822a6529e5dabafc17b6013fdbb7e3b744574df230e3565637c354fe06eeb3a4576f56ef2e2d798aeaac6d2a0968823351f0ee76e6f06114f740f5ae432 0009-add-PIE-support-for-ARM.patch
6897ed7bf575d085fda0c1270090bb44d26712c4f513ed98b4c988a3f31fc808e7fe4b760a46c329b5b3b20a20049410c0c3f0f51d780568427b3f1fc4b7df5b 0010-make-posix_spawn-and-functions-that-use-it-use-CLONE.patch
e5e945f26daae5498e2a2e463d4bb3724294bc5dd4bf9a93a0f18e333f277e18e5977e144642bf45185d25ffa167316fe9914c9885d491a0034b2f4cccb0d07f getopt_long.c
4d92f934d760cf5157d80f19fd766be6b673c65317229b32ac824d9d192f6abcc414e2382b2416dfd5c2f757b46ced98c18e4762bf91f5a48647e0ee61813b06 getent"