Commit f6e0f94b authored by Natanael Copa's avatar Natanael Copa

main/musl: upgrade to 1.1.21 and modernize

parent 6f34f151
From f381c118b2d4f7d914481d3cdc830ce41369b002 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 19 Sep 2018 18:03:22 -0400
Subject: [PATCH] fix getaddrinfo regression with AI_ADDRCONFIG on some
configurations
despite not being documented to do so in the standard or Linux
documentation, attempts to udp connect to 127.0.0.1 or ::1 generate
EADDRNOTAVAIL when the loopback device is not configured and there is
no default route for IPv6. this caused getaddrinfo with AI_ADDRCONFIG
to fail with EAI_SYSTEM and EADDRNOTAVAIL on some no-IPv6
configurations, rather than the intended behavior of detecting IPv6 as
unsuppported and producing IPv4-only results.
previously, only EAFNOSUPPORT was treated as unavailability of the
address family being probed. instead, treat all errors related to
inability to get an address or route as conclusive that the family
being probed is unsupported, and only fail with EAI_SYSTEM on other
errors.
further improvements may be desirable, such as reporting EAI_AGAIN
instead of EAI_SYSTEM for errors which are expected to be transient,
but this patch should suffice to fix the serious regression.
---
src/network/getaddrinfo.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index ba26847a..e33bfa28 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -76,7 +76,16 @@ int getaddrinfo(const char *restrict host, const char *restrict serv, const stru
close(s);
if (!r) continue;
}
- if (errno != EAFNOSUPPORT) return EAI_SYSTEM;
+ switch (errno) {
+ case EADDRNOTAVAIL:
+ case EAFNOSUPPORT:
+ case EHOSTUNREACH:
+ case ENETDOWN:
+ case ENETUNREACH:
+ break;
+ default:
+ return EAI_SYSTEM;
+ }
if (family == tf[i]) return EAI_NONAME;
family = tf[1-i];
}
--
2.18.0
From b6b592d75f694958424b8a4fbd909b52317651f1 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Tue, 18 Sep 2018 01:10:32 +0300
Subject: [PATCH v2] fix race condition in file locking
The condition occurs when
- thread #1 is holding the lock
- thread #2 is waiting for it on __futexwait
- thread #1 is about to release the lock and performs a_swap
- thread #3 enters the __lockfile function and manages to grab the lock
before thread #1 calls __wake, resetting the MAYBE_WAITERS flag
- thread #1 calls __wake
- thread #2 wakes up but goes again to __futexwait as the lock is
held by thread #3
- thread #3 releases the lock but does not call __wake as the
MAYBE_WAITERS flag is not set
This condition results in thread #2 not being woken up. This patch fixes
the problem by making the woken up thread ensure that the flag is
properly set before going to sleep again.
---
src/stdio/__lockfile.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/stdio/__lockfile.c b/src/stdio/__lockfile.c
index 2ff75d8a..0dcb2a42 100644
--- a/src/stdio/__lockfile.c
+++ b/src/stdio/__lockfile.c
@@ -8,13 +8,13 @@ int __lockfile(FILE *f)
int owner = f->lock, tid = __pthread_self()->tid;
if ((owner & ~MAYBE_WAITERS) == tid)
return 0;
- for (;;) {
- owner = a_cas(&f->lock, 0, tid);
- if (!owner) return 1;
- if (a_cas(&f->lock, owner, owner|MAYBE_WAITERS)==owner) break;
+ owner = a_cas(&f->lock, 0, tid);
+ if (!owner) return 1;
+ while ((owner = a_cas(&f->lock, 0, tid|MAYBE_WAITERS))) {
+ if ((owner & MAYBE_WAITERS) ||
+ a_cas(&f->lock, owner, owner|MAYBE_WAITERS)==owner)
+ __futexwait(&f->lock, owner|MAYBE_WAITERS, 1);
}
- while ((owner = a_cas(&f->lock, 0, tid|MAYBE_WAITERS)))
- __futexwait(&f->lock, owner, 1);
return 1;
}
--
2.14.4
From 58dec23397e3fcc4300cc03839ce5e508389abbc Mon Sep 17 00:00:00 2001
From: William Pitcock <nenolod@dereferenced.org>
Date: Thu, 22 Jun 2017 22:04:51 +0000
Subject: [PATCH] pthread internals: increase DEFAULT_GUARD_SIZE to 2 pages
instead of 1 page.
This is intended to be a proactive mitigation against any bugs similar to CVE-2017-1000366.
Signed-off-by: William Pitcock <nenolod@dereferenced.org>
---
src/internal/pthread_impl.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index ae0ab1c5..ad4ea3fa 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -146,7 +146,7 @@ void __block_app_sigs(void *);
void __restore_sigs(void *);
#define DEFAULT_STACK_SIZE 81920
-#define DEFAULT_GUARD_SIZE 4096
+#define DEFAULT_GUARD_SIZE 8192
#define __ATTRP_C11_THREAD ((void*)(uintptr_t)-1)
--
2.13.0
# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.20
pkgrel=3
pkgver=1.1.21
pkgrel=0
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
......@@ -14,10 +14,7 @@ nolibc) ;;
*) subpackages="$subpackages $pkgname-utils";;
esac
source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch
handle-aux-at_base.patch
0001-fix-race-condition-in-file-locking.patch
0001-fix-getaddrinfo-regression-with-AI_ADDRCONFIG-on-som.patch
ldconfig
__stack_chk_fail_local.c
......@@ -38,14 +35,14 @@ build() {
[ "$BOOTSTRAP" = "nocc" ] && return 0
# provide minimal libssp_nonshared.a so we don't need libssp from gcc
${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS -c "$srcdir"/__stack_chk_fail_local.c -o __stack_chk_fail_local.o || return 1
${CROSS_COMPILE}ar r libssp_nonshared.a __stack_chk_fail_local.o || return 1
${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS -c "$srcdir"/__stack_chk_fail_local.c -o __stack_chk_fail_local.o
${CROSS_COMPILE}ar r libssp_nonshared.a __stack_chk_fail_local.o
if [ "$BOOTSTRAP" != "nolibc" ]; then
# getconf/getent/iconv
local i
for i in getconf getent iconv ; do
${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS "$srcdir"/$i.c -o $i || return 1
${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS "$srcdir"/$i.c -o $i
done
fi
......@@ -58,9 +55,8 @@ build() {
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--localstatedir=/var \
|| return 1
make || return 1
--localstatedir=/var
make
}
package() {
......@@ -79,25 +75,25 @@ package() {
mips*) ARCH="mips" ;;
esac
make ARCH="$ARCH" prefix=/usr DESTDIR="$pkgdir" install-headers || return 1
make ARCH="$ARCH" prefix=/usr DESTDIR="$pkgdir" install-headers
else
make DESTDIR="$pkgdir" install || return 1
make DESTDIR="$pkgdir" install
cp libssp_nonshared.a "$pkgdir"/usr/lib || return 1
cp libssp_nonshared.a "$pkgdir"/usr/lib
# make LDSO the be the real file, and libc the symlink
local LDSO=$(make -f Makefile --eval "$(echo -e 'print-ldso:\n\t@echo $$(basename $(LDSO_PATHNAME))')" print-ldso)
mv -f "$pkgdir"/usr/lib/libc.so "$pkgdir"/lib/"$LDSO" || return 1
ln -sf "$LDSO" "$pkgdir"/lib/libc.musl-${CARCH}.so.1 || return 1
ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/lib/libc.so || return 1
mkdir -p "$pkgdir"/usr/bin || return 1
ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/bin/ldd || return 1
mv -f "$pkgdir"/usr/lib/libc.so "$pkgdir"/lib/"$LDSO"
ln -sf "$LDSO" "$pkgdir"/lib/libc.musl-${CARCH}.so.1
ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/lib/libc.so
mkdir -p "$pkgdir"/usr/bin
ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/bin/ldd
fi
# remove libintl.h, currently we don't want by default any NLS
# and use GNU gettext where needed. the plan is to migrate to
# musl gettext() later on as fully as possible.
rm "$pkgdir"/usr/include/libintl.h || return 1
rm "$pkgdir"/usr/include/libintl.h
}
utils() {
......@@ -106,7 +102,7 @@ utils() {
license="MIT BSD GPL2+"
mkdir -p "$subpkgdir"/usr "$subpkgdir"/sbin
mv "$pkgdir"/usr/bin "$subpkgdir"/usr/ || return 1
mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
install -D \
"$builddir"/getent \
......@@ -146,11 +142,8 @@ compat() {
done
}
sha512sums="d3a7a30aa375ca50d7dcfbd618581d59e1aa5378417f50a0ca5510099336fd74cc9db468e05c93dda3067abd890f6bd47af226c3446bb833adf0a5054bff2e5d musl-1.1.20.tar.gz
2c8e1dde1834238097b2ee8a7bfb53471a0d9cff4a5e38b55f048b567deff1cdd47c170d0578a67b1a039f95a6c5fbb8cff369c75b6a3e4d7ed171e8e86ebb8c 2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch
sha512sums="fa6c4cc012626c5e517e0e10926fc845e3aa5f863ffaceeb38ac5b9ce0af631a37f6b94f470997db09aa0d5e03f4f28a2db83484b0f98481bea2239c1989d363 musl-1.1.21.tar.gz
6a7ff16d95b5d1be77e0a0fbb245491817db192176496a57b22ab037637d97a185ea0b0d19da687da66c2a2f5578e4343d230f399d49fe377d8f008410974238 handle-aux-at_base.patch
ab34509cec7419c11352094ed6acf14e5766b314bd2b96506a0d0203e61e90e85ea9a121f1fefc0d00bcba381778d579ea2c02325605344530420305fcf1a0d0 0001-fix-race-condition-in-file-locking.patch
20f9db1f96d4867fb0e4d4e1b4b323e1871ce5660896c8608f7a5147d247f6c6840f84eff25ae8f8b7cf04af0f586afed00acb6abcbedd4240a4678359fa6dc9 0001-fix-getaddrinfo-regression-with-AI_ADDRCONFIG-on-som.patch
8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f ldconfig
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b __stack_chk_fail_local.c
0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d getconf.c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment