diff --git a/toolchain/musl/Config.in b/toolchain/musl/Config.in new file mode 100644 index 0000000000..7e83b6fa53 --- /dev/null +++ b/toolchain/musl/Config.in @@ -0,0 +1,12 @@ +# Password crypt stubbing + +config MUSL_DISABLE_CRYPT_SIZE_HACK + bool "Include crypt() support for SHA256, SHA512 and Blowfish ciphers" + depends on TOOLCHAINOPTS && USE_MUSL && !EXTERNAL_TOOLCHAIN + default n + help + Enable this option to re-include crypt() support for the SHA256, SHA512 and + Blowfish ciphers. Without this option, attempting to hash a string with a salt + requesting one of these ciphers will cause the crypt() function to call stub + implementations which will always fail with errno ENOSYS. Including the ciphers + will increase the library size by about 14KB after LZMA compression. diff --git a/toolchain/musl/common.mk b/toolchain/musl/common.mk index 2cd2c65ffb..8a9a3f9943 100644 --- a/toolchain/musl/common.mk +++ b/toolchain/musl/common.mk @@ -8,14 +8,14 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/target.mk PKG_NAME:=musl -PKG_VERSION:=1.1.19 -PKG_RELEASE=3 +PKG_VERSION:=1.1.23 +PKG_RELEASE:=3 PKG_SOURCE_PROTO:=git PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_VERSION:=55df09bfccbfe21fc9dd7d8f94550c0ff25ace04 -PKG_MIRROR_HASH:=eb94e4e7e94221dd8890afd9b29e2562c36cf5585649035349ca1c6c1c354f2b -PKG_SOURCE_URL:=git://git.musl-libc.org/musl +PKG_SOURCE_VERSION:=b07d45eb01e900f0176894fdedab62285f5cb8be +PKG_MIRROR_HASH:=47aa4608384cfde1da3e310051a15ddb58ab25d62d8232b6e17e56a681dce44e +PKG_SOURCE_URL:=https://git.musl-libc.org/git/musl PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz LIBC_SO_VERSION:=$(PKG_VERSION) @@ -28,6 +28,9 @@ HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION) include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/hardening.mk +TARGET_CFLAGS:= $(filter-out -O%,$(TARGET_CFLAGS)) +TARGET_CFLAGS+= $(if $(CONFIG_MUSL_DISABLE_CRYPT_SIZE_HACK),,-DCRYPT_SIZE_HACK) + MUSL_CONFIGURE:= \ $(TARGET_CONFIGURE_OPTS) \ CFLAGS="$(TARGET_CFLAGS)" \ @@ -37,7 +40,8 @@ MUSL_CONFIGURE:= \ --host=$(GNU_HOST_NAME) \ --target=$(REAL_GNU_TARGET_NAME) \ --disable-gcc-wrapper \ - --enable-debug + --enable-debug \ + --enable-optimize define Host/Configure ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) diff --git a/toolchain/musl/patches/010-sys-socket.h-fix-SO_PEERSEC-value-on-MIPS.patch b/toolchain/musl/patches/010-sys-socket.h-fix-SO_PEERSEC-value-on-MIPS.patch deleted file mode 100644 index 2319d9cb68..0000000000 --- a/toolchain/musl/patches/010-sys-socket.h-fix-SO_PEERSEC-value-on-MIPS.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 4e0877a604bad684be020f68e96a05156131fd44 Mon Sep 17 00:00:00 2001 -From: Matthias Schiffer -Date: Sun, 24 Jun 2018 17:05:31 +0200 -Subject: [PATCH] sys/socket.h: fix SO_PEERSEC value on MIPS - -Differing from all other archs supported by musl, MIPS defines SO_PEERSEC -to 30 instead of 31. - -Reported-by: Andrey Jr. Mlenikov ---- - arch/mips/bits/socket.h | 2 ++ - arch/mips64/bits/socket.h | 2 ++ - arch/mipsn32/bits/socket.h | 2 ++ - include/sys/socket.h | 3 +++ - 4 files changed, 9 insertions(+) - ---- a/arch/mips/bits/socket.h -+++ b/arch/mips/bits/socket.h -@@ -48,5 +48,7 @@ struct cmsghdr { - #define SO_SNDBUFFORCE 31 - #define SO_RCVBUFFORCE 33 - -+#define SO_PEERSEC 30 -+ - #define SOCK_NONBLOCK 0200 - #define SOCK_CLOEXEC 02000000 ---- a/arch/mips64/bits/socket.h -+++ b/arch/mips64/bits/socket.h -@@ -64,5 +64,7 @@ struct cmsghdr { - #define SO_SNDBUFFORCE 31 - #define SO_RCVBUFFORCE 33 - -+#define SO_PEERSEC 30 -+ - #define SOCK_NONBLOCK 0200 - #define SOCK_CLOEXEC 02000000 ---- a/arch/mipsn32/bits/socket.h -+++ b/arch/mipsn32/bits/socket.h -@@ -48,5 +48,7 @@ struct cmsghdr { - #define SO_SNDBUFFORCE 31 - #define SO_RCVBUFFORCE 33 - -+#define SO_PEERSEC 30 -+ - #define SOCK_NONBLOCK 0200 - #define SOCK_CLOEXEC 02000000 ---- a/include/sys/socket.h -+++ b/include/sys/socket.h -@@ -201,7 +201,10 @@ struct linger { - #define SO_TIMESTAMP 29 - #define SCM_TIMESTAMP SO_TIMESTAMP - -+#ifndef SO_PEERSEC - #define SO_PEERSEC 31 -+#endif -+ - #define SO_PASSSEC 34 - #define SO_TIMESTAMPNS 35 - #define SCM_TIMESTAMPNS SO_TIMESTAMPNS diff --git a/toolchain/musl/patches/020-make-relocation-time-symbol-lookup-and-dlsym-consistent.patch b/toolchain/musl/patches/020-mips-dlsym_donot_return_address_from_undef_sym.patch similarity index 91% rename from toolchain/musl/patches/020-make-relocation-time-symbol-lookup-and-dlsym-consistent.patch rename to toolchain/musl/patches/020-mips-dlsym_donot_return_address_from_undef_sym.patch index 05e2af02e7..b3559471f3 100644 --- a/toolchain/musl/patches/020-make-relocation-time-symbol-lookup-and-dlsym-consistent.patch +++ b/toolchain/musl/patches/020-mips-dlsym_donot_return_address_from_undef_sym.patch @@ -19,16 +19,13 @@ Using common code path for all symbol lookups fixes three dlsym issues: always_inline is used to avoid relocation performance regression, the code generation for find_sym should not be affected. - -BAckported to 1.1.19 - --- ldso/dynlink.c | 84 +++++++++++++++++++------------------------------- 1 file changed, 31 insertions(+), 53 deletions(-) --- a/ldso/dynlink.c +++ b/ldso/dynlink.c -@@ -257,12 +257,16 @@ static Sym *gnu_lookup_filtered(uint32_t +@@ -283,12 +283,16 @@ static Sym *gnu_lookup_filtered(uint32_t #define ARCH_SYM_REJECT_UND(s) 0 #endif @@ -47,9 +44,9 @@ BAckported to 1.1.19 Sym *sym; if ((ght = dso->ghashtab)) { sym = gnu_lookup_filtered(gh, ght, dso, s, gho, ghm); -@@ -290,6 +294,11 @@ static struct symdef find_sym(struct dso - __attribute__((__visibility__("hidden"))) - ptrdiff_t __tlsdesc_static(), __tlsdesc_dynamic(); +@@ -313,6 +317,11 @@ static struct symdef find_sym(struct dso + return def; + } +static struct symdef find_sym(struct dso *dso, const char *s, int need_def) +{ @@ -59,7 +56,7 @@ BAckported to 1.1.19 static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stride) { unsigned char *base = dso->base; -@@ -1872,58 +1881,27 @@ void *__tls_get_addr(tls_mod_off_t *); +@@ -2118,58 +2127,27 @@ static void *addr2dso(size_t a) static void *do_dlsym(struct dso *p, const char *s, void *ra) { @@ -77,7 +74,7 @@ BAckported to 1.1.19 - struct symdef def = find_sym(p, s, 0); - if (!def.sym) goto failed; - if ((def.sym->st_info&0xf) == STT_TLS) -- return __tls_get_addr((tls_mod_off_t []){def.dso->tls_id, def.sym->st_value}); +- return __tls_get_addr((tls_mod_off_t []){def.dso->tls_id, def.sym->st_value-DTP_OFFSET}); - if (DL_FDPIC && (def.sym->st_info&0xf) == STT_FUNC) - return def.dso->funcdescs + (def.sym - def.dso->syms); - return laddr(def.dso, def.sym->st_value); @@ -91,7 +88,7 @@ BAckported to 1.1.19 + if (!p) p=head; + p = p->next; + } else if (__dl_invalid_handle(p)) { -+ return 0; ++ return 0; + } else + use_deps = 1; + struct symdef def = find_sym2(p, s, 0, use_deps); @@ -104,9 +101,9 @@ BAckported to 1.1.19 - } else { - h = sysv_hash(s); - sym = sysv_lookup(s, h, p); - } +- } - if (sym && (sym->st_info&0xf) == STT_TLS) -- return __tls_get_addr((tls_mod_off_t []){p->tls_id, sym->st_value}); +- return __tls_get_addr((tls_mod_off_t []){p->tls_id, sym->st_value-DTP_OFFSET}); - if (DL_FDPIC && sym && sym->st_shndx && (sym->st_info&0xf) == STT_FUNC) - return p->funcdescs + (sym - p->syms); - if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES)) @@ -120,12 +117,12 @@ BAckported to 1.1.19 - sym = sysv_lookup(s, h, p->deps[i]); - } - if (sym && (sym->st_info&0xf) == STT_TLS) -- return __tls_get_addr((tls_mod_off_t []){p->deps[i]->tls_id, sym->st_value}); +- return __tls_get_addr((tls_mod_off_t []){p->deps[i]->tls_id, sym->st_value-DTP_OFFSET}); - if (DL_FDPIC && sym && sym->st_shndx && (sym->st_info&0xf) == STT_FUNC) - return p->deps[i]->funcdescs + (sym - p->deps[i]->syms); - if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES)) - return laddr(p->deps[i], sym->st_value); -- } + } -failed: - error("Symbol not found: %s", s); - return 0; @@ -136,4 +133,4 @@ BAckported to 1.1.19 + return laddr(def.dso, def.sym->st_value); } - int dladdr(const void *addr, Dl_info *info) + int dladdr(const void *addr_arg, Dl_info *info) diff --git a/toolchain/musl/patches/110-read_timezone_from_fs.patch b/toolchain/musl/patches/110-read_timezone_from_fs.patch index fb98f7d10e..f92781f7ed 100644 --- a/toolchain/musl/patches/110-read_timezone_from_fs.patch +++ b/toolchain/musl/patches/110-read_timezone_from_fs.patch @@ -1,6 +1,6 @@ --- a/src/time/__tz.c +++ b/src/time/__tz.c -@@ -23,6 +23,9 @@ static int r0[5], r1[5]; +@@ -25,6 +25,9 @@ static int r0[5], r1[5]; static const unsigned char *zi, *trans, *index, *types, *abbrevs, *abbrevs_end; static size_t map_size; diff --git a/toolchain/musl/patches/200-add_libssp_nonshared.patch b/toolchain/musl/patches/200-add_libssp_nonshared.patch index 7a2909461b..05bd2fe54a 100644 --- a/toolchain/musl/patches/200-add_libssp_nonshared.patch +++ b/toolchain/musl/patches/200-add_libssp_nonshared.patch @@ -4,11 +4,6 @@ Date: Mon, 22 Jun 2015 11:01:56 +0200 Subject: [PATCH] Add libssp_nonshared.a so GCC's is not needed Signed-off-by: Steven Barth ---- - Makefile | 10 ++++++++-- - libssp_nonshared/__stack_chk_fail_local.c | 2 ++ - 2 files changed, 10 insertions(+), 2 deletions(-) - create mode 100644 libssp_nonshared/__stack_chk_fail_local.c --- a/Makefile +++ b/Makefile @@ -21,21 +16,29 @@ Signed-off-by: Steven Barth ALL_TOOLS = obj/musl-gcc WRAPCC_GCC = gcc -@@ -125,7 +125,8 @@ NOSSP_SRCS = $(wildcard crt/*.c) \ - src/thread/__set_thread_area.c src/thread/$(ARCH)/__set_thread_area.c \ - src/string/memset.c src/string/$(ARCH)/memset.c \ - src/string/memcpy.c src/string/$(ARCH)/memcpy.c \ -- ldso/dlstart.c ldso/dynlink.c -+ ldso/dlstart.c ldso/dynlink.c \ -+ src/libssp_nonshared/__stack_chk_fail_local.c - $(NOSSP_SRCS:%.c=obj/%.o) $(NOSSP_SRCS:%.c=obj/%.lo): CFLAGS_ALL += $(CFLAGS_NOSSP) +@@ -86,7 +86,7 @@ else - $(CRT_OBJS): CFLAGS_ALL += -DCRT -@@ -168,6 +169,11 @@ lib/libc.a: $(AOBJS) + all: $(ALL_LIBS) $(ALL_TOOLS) + +-OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(GENH) $(GENH_INT))) obj/include) ++OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(GENH) $(GENH_INT))) obj/include obj/libssp_nonshared) + + $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(ALL_OBJS:%.o=%.lo) $(GENH) $(GENH_INT): | $(OBJ_DIRS) + +@@ -113,6 +113,8 @@ obj/crt/rcrt1.o: $(srcdir)/ldso/dlstart. + + obj/crt/Scrt1.o obj/crt/rcrt1.o: CFLAGS_ALL += -fPIC + ++obj/libssp_nonshared/__stack_chk_fail_local.o: CFLAGS_ALL += $(CFLAGS_NOSSP) ++ + OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=$(srcdir)/src/%)) + $(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.o) $(OPTIMIZE_SRCS:$(srcdir)/%.c=obj/%.lo): CFLAGS += -O3 + +@@ -165,6 +167,11 @@ lib/libc.a: $(AOBJS) $(AR) rc $@ $(AOBJS) $(RANLIB) $@ -+lib/libssp_nonshared.a: obj/src/libssp_nonshared/__stack_chk_fail_local.o ++lib/libssp_nonshared.a: obj/libssp_nonshared/__stack_chk_fail_local.o + rm -f $@ + $(AR) rc $@ $< + $(RANLIB) $@ @@ -44,7 +47,7 @@ Signed-off-by: Steven Barth rm -f $@ $(AR) rc $@ --- /dev/null -+++ b/src/libssp_nonshared/__stack_chk_fail_local.c ++++ b/libssp_nonshared/__stack_chk_fail_local.c @@ -0,0 +1,2 @@ +#include "atomic.h" +void __attribute__((visibility ("hidden"))) __stack_chk_fail_local(void) { a_crash(); } diff --git a/toolchain/musl/patches/300-relative.patch b/toolchain/musl/patches/300-relative.patch index 7e1eb7d6bc..e34e60a09d 100644 --- a/toolchain/musl/patches/300-relative.patch +++ b/toolchain/musl/patches/300-relative.patch @@ -1,6 +1,6 @@ --- a/Makefile +++ b/Makefile -@@ -217,7 +217,7 @@ $(DESTDIR)$(includedir)/%: $(srcdir)/inc +@@ -215,7 +215,7 @@ $(DESTDIR)$(includedir)/%: $(srcdir)/inc $(INSTALL) -D -m 644 $< $@ $(DESTDIR)$(LDSO_PATHNAME): $(DESTDIR)$(libdir)/libc.so diff --git a/toolchain/musl/patches/400-Add-format-attribute-to-some-function-declarations.patch b/toolchain/musl/patches/400-Add-format-attribute-to-some-function-declarations.patch index 915b0b7b47..06aeb34ced 100644 --- a/toolchain/musl/patches/400-Add-format-attribute-to-some-function-declarations.patch +++ b/toolchain/musl/patches/400-Add-format-attribute-to-some-function-declarations.patch @@ -87,7 +87,7 @@ Signed-off-by: Hauke Mehrtens } --- a/include/stdio.h +++ b/include/stdio.h -@@ -21,6 +21,14 @@ extern "C" { +@@ -25,6 +25,14 @@ extern "C" { #include @@ -102,7 +102,7 @@ Signed-off-by: Hauke Mehrtens #ifdef __cplusplus #define NULL 0L #else -@@ -102,19 +110,19 @@ int puts(const char *); +@@ -107,19 +115,19 @@ int puts(const char *); int printf(const char *__restrict, ...); int fprintf(FILE *__restrict, const char *__restrict, ...); int sprintf(char *__restrict, const char *__restrict, ...); @@ -127,7 +127,7 @@ Signed-off-by: Hauke Mehrtens void perror(const char *); -@@ -135,8 +143,8 @@ int pclose(FILE *); +@@ -140,8 +148,8 @@ int pclose(FILE *); int fileno(FILE *); int fseeko(FILE *, off_t, int); off_t ftello(FILE *); @@ -138,7 +138,7 @@ Signed-off-by: Hauke Mehrtens void flockfile(FILE *); int ftrylockfile(FILE *); void funlockfile(FILE *); -@@ -175,8 +183,8 @@ int fileno_unlocked(FILE *); +@@ -180,8 +188,8 @@ int fileno_unlocked(FILE *); int getw(FILE *); int putw(int, FILE *); char *fgetln(FILE *, size_t *); @@ -149,7 +149,7 @@ Signed-off-by: Hauke Mehrtens #endif #ifdef _GNU_SOURCE -@@ -198,6 +206,9 @@ typedef struct _IO_cookie_io_functions_t +@@ -203,6 +211,9 @@ typedef struct _IO_cookie_io_functions_t FILE *fopencookie(void *, const char *, cookie_io_functions_t); #endif diff --git a/toolchain/musl/patches/900-iconv_size_hack.patch b/toolchain/musl/patches/900-iconv_size_hack.patch index 6200262b1d..461a204a4c 100644 --- a/toolchain/musl/patches/900-iconv_size_hack.patch +++ b/toolchain/musl/patches/900-iconv_size_hack.patch @@ -56,7 +56,7 @@ case SHIFT_JIS: if (c < 128) break; if (c-0xa1 <= 0xdf-0xa1) { -@@ -510,6 +517,7 @@ size_t iconv(iconv_t cd, char **restrict +@@ -518,6 +525,7 @@ size_t iconv(iconv_t cd, char **restrict c = ksc[c][d]; if (!c) goto ilseq; break; @@ -64,7 +64,7 @@ default: if (!c) break; c = legacy_map(map, c); -@@ -550,6 +558,7 @@ size_t iconv(iconv_t cd, char **restrict +@@ -559,6 +567,7 @@ size_t iconv(iconv_t cd, char **restrict } } goto subst; @@ -72,7 +72,7 @@ case SHIFT_JIS: if (c < 128) goto revout; if (c == 0xa5) { -@@ -623,6 +632,7 @@ size_t iconv(iconv_t cd, char **restrict +@@ -632,6 +641,7 @@ size_t iconv(iconv_t cd, char **restrict *(*out)++ = 'B'; *outb -= 8; break; diff --git a/toolchain/musl/patches/901-crypt_size_hack.patch b/toolchain/musl/patches/901-crypt_size_hack.patch index 8cd7b1989c..75f196abca 100644 --- a/toolchain/musl/patches/901-crypt_size_hack.patch +++ b/toolchain/musl/patches/901-crypt_size_hack.patch @@ -1,59 +1,74 @@ ---- a/src/crypt/crypt_r.c -+++ b/src/crypt/crypt_r.c -@@ -19,12 +19,6 @@ char *__crypt_r(const char *key, const c - if (salt[0] == '$' && salt[1] && salt[2]) { - if (salt[1] == '1' && salt[2] == '$') - return __crypt_md5(key, salt, output); -- if (salt[1] == '2' && salt[3] == '$') -- return __crypt_blowfish(key, salt, output); -- if (salt[1] == '5' && salt[2] == '$') -- return __crypt_sha256(key, salt, output); -- if (salt[1] == '6' && salt[2] == '$') -- return __crypt_sha512(key, salt, output); - } - return __crypt_des(key, salt, output); - } --- a/src/crypt/crypt_sha512.c +++ b/src/crypt/crypt_sha512.c -@@ -12,6 +12,7 @@ - #include +@@ -13,6 +13,17 @@ #include #include -+#if 0 ++#ifdef CRYPT_SIZE_HACK ++#include ++ ++char *__crypt_sha512(const char *key, const char *setting, char *output) ++{ ++ errno = ENOSYS; ++ return NULL; ++} ++ ++#else ++ /* public domain sha512 implementation based on fips180-3 */ /* >=2^64 bits messages are not supported (about 2000 peta bytes) */ -@@ -369,3 +370,4 @@ char *__crypt_sha512(const char *key, co + +@@ -369,3 +380,4 @@ char *__crypt_sha512(const char *key, co return "*"; return p; } +#endif --- a/src/crypt/crypt_blowfish.c +++ b/src/crypt/crypt_blowfish.c -@@ -50,6 +50,7 @@ +@@ -50,6 +50,17 @@ #include #include -+#if 0 ++#ifdef CRYPT_SIZE_HACK ++#include ++ ++char *__crypt_blowfish(const char *key, const char *setting, char *output) ++{ ++ errno = ENOSYS; ++ return NULL; ++} ++ ++#else ++ typedef uint32_t BF_word; typedef int32_t BF_word_signed; -@@ -796,3 +797,4 @@ char *__crypt_blowfish(const char *key, +@@ -796,3 +807,4 @@ char *__crypt_blowfish(const char *key, return "*"; } +#endif --- a/src/crypt/crypt_sha256.c +++ b/src/crypt/crypt_sha256.c -@@ -13,6 +13,7 @@ +@@ -13,6 +13,17 @@ #include #include -+#if 0 ++#ifdef CRYPT_SIZE_HACK ++#include ++ ++char *__crypt_sha256(const char *key, const char *setting, char *output) ++{ ++ errno = ENOSYS; ++ return NULL; ++} ++ ++#else ++ /* public domain sha256 implementation based on fips180-3 */ struct sha256 { -@@ -320,3 +321,4 @@ char *__crypt_sha256(const char *key, co +@@ -320,3 +331,4 @@ char *__crypt_sha256(const char *key, co return "*"; return p; }