From 8cfdf693ec5ad9d6060312ca8d1c7ddb842672c9 Mon Sep 17 00:00:00 2001 From: Christian Wiese Date: Wed, 8 Sep 2010 11:51:23 +0200 Subject: [PATCH] uclibc: added upstream fixes (borrowed from buildroot) --- ...libc-0.9.31-dnslookup-use-after-free.patch | 52 +++++++++++++ ...uClibc-0.9.31-fix-error-locale-utf-8.patch | 33 +++++++++ ....9.31-fix-fcntl64-for-64-bit-targets.patch | 50 +++++++++++++ ...-0.9.31-more-workarounds-GCC-PR32219.patch | 56 ++++++++++++++ ...uClibc-0.9.31-workaround-GCC-PR32219.patch | 73 +++++++++++++++++++ 5 files changed, 264 insertions(+) create mode 100644 base/uclibc/uClibc-0.9.31-dnslookup-use-after-free.patch create mode 100644 base/uclibc/uClibc-0.9.31-fix-error-locale-utf-8.patch create mode 100644 base/uclibc/uClibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch create mode 100644 base/uclibc/uClibc-0.9.31-more-workarounds-GCC-PR32219.patch create mode 100644 base/uclibc/uClibc-0.9.31-workaround-GCC-PR32219.patch diff --git a/base/uclibc/uClibc-0.9.31-dnslookup-use-after-free.patch b/base/uclibc/uClibc-0.9.31-dnslookup-use-after-free.patch new file mode 100644 index 000000000..cd1ec6ff5 --- /dev/null +++ b/base/uclibc/uClibc-0.9.31-dnslookup-use-after-free.patch @@ -0,0 +1,52 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../uclibc/uClibc-0.9.31-dnslookup-use-after-free.patch +# Copyright (C) 2010 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +From eb1d8c8289f466ba3ad10b9a88ab2e426b8a9dc7 Mon Sep 17 00:00:00 2001 +From: Gabor Juhos +Date: Tue, 6 Apr 2010 09:55:19 +0200 +Subject: [PATCH] Fix use-after-free bug in __dns_lookup + +If the type of the first answer does not match with the requested type, +then the dotted name was freed. If there are no further answers in +the DNS reply, this pointer was used later on in the same function. +Additionally it is passed to the caller, and caused strange +behaviour. + +Signed-off-by: Gabor Juhos +Signed-off-by: Bernhard Reutner-Fischer +--- + libc/inet/resolv.c | 4 +--- + 1 files changed, 1 insertions(+), 3 deletions(-) + +diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c +index 056539f..9459199 100644 +--- a/libc/inet/resolv.c ++++ b/libc/inet/resolv.c +@@ -1517,10 +1517,8 @@ int attribute_hidden __dns_lookup(const char *name, + memcpy(a, &ma, sizeof(ma)); + if (a->atype != T_SIG && (NULL == a->buf || (type != T_A && type != T_AAAA))) + break; +- if (a->atype != type) { +- free(a->dotted); ++ if (a->atype != type) + continue; +- } + a->add_count = h.ancount - j - 1; + if ((a->rdlength + sizeof(struct in_addr*)) * a->add_count > a->buflen) + break; +-- +1.7.0 + diff --git a/base/uclibc/uClibc-0.9.31-fix-error-locale-utf-8.patch b/base/uclibc/uClibc-0.9.31-fix-error-locale-utf-8.patch new file mode 100644 index 000000000..69594de2b --- /dev/null +++ b/base/uclibc/uClibc-0.9.31-fix-error-locale-utf-8.patch @@ -0,0 +1,33 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../uclibc/uClibc-0.9.31-fix-error-locale-utf-8.patch +# Copyright (C) 2010 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +--- + extra/locale/gen_wc8bit.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +Index: uClibc-0.9.31/extra/locale/gen_wc8bit.c +=================================================================== +--- uClibc-0.9.31.orig/extra/locale/gen_wc8bit.c ++++ uClibc-0.9.31/extra/locale/gen_wc8bit.c +@@ -120,7 +120,7 @@ + } + + locale_failure: +- printf("could not find a UTF8 locale ... please enable en_US.UTF-8\n"); ++ fprintf(stderr, "could not find a UTF8 locale ... please enable en_US.UTF-8\n"); + return EXIT_FAILURE; + locale_success: + pclose(fp); diff --git a/base/uclibc/uClibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch b/base/uclibc/uClibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch new file mode 100644 index 000000000..7c7b18444 --- /dev/null +++ b/base/uclibc/uClibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch @@ -0,0 +1,50 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../uclibc/uClibc-0.9.31-fix-fcntl64-for-64-bit-targets.patch +# Copyright (C) 2010 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +From 6f1daaaf2d94c1e6184add44eda38b0781b88cf0 Mon Sep 17 00:00:00 2001 +From: Rob Landley +Date: Sun, 16 May 2010 21:41:36 +0000 +Subject: Fix fcntl64 for 64 bit targets. + +64 bit targets often don't have a separate fcntl64() system call, because they don't need one. + +Signed-off-by: Rob Landley +Signed-off-by: Austin Foxley +--- +diff --git a/include/fcntl.h b/include/fcntl.h +index e37073f..3cfb25f 100644 +--- a/include/fcntl.h ++++ b/include/fcntl.h +@@ -73,7 +73,7 @@ __BEGIN_DECLS + + This function is a cancellation point and therefore not marked with + __THROW. */ +-#ifndef __USE_FILE_OFFSET64 ++#if !defined(__USE_FILE_OFFSET64) || defined(__LP64__) + extern int fcntl (int __fd, int __cmd, ...); + libc_hidden_proto(fcntl) + #else +@@ -83,7 +83,7 @@ extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64); + # define fcntl fcntl64 + # endif + #endif +-#ifdef __USE_LARGEFILE64 ++#if defined(__USE_LARGEFILE64) && !defined(__LP64__) + extern int fcntl64 (int __fd, int __cmd, ...); + libc_hidden_proto(fcntl64) + #endif +-- +cgit v0.8.2.1 diff --git a/base/uclibc/uClibc-0.9.31-more-workarounds-GCC-PR32219.patch b/base/uclibc/uClibc-0.9.31-more-workarounds-GCC-PR32219.patch new file mode 100644 index 000000000..1f66b55ce --- /dev/null +++ b/base/uclibc/uClibc-0.9.31-more-workarounds-GCC-PR32219.patch @@ -0,0 +1,56 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../uclibc/uClibc-0.9.31-more-workarounds-GCC-PR32219.patch +# Copyright (C) 2010 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +From aa67771881d65373da448ad5f7a8393f3a1d9469 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= +Date: Wed, 30 Jun 2010 14:46:37 +0300 +Subject: [PATCH] more workarounds for GCC PR32219 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit 2e53dd645d5348f207cec7f8595969dc566c5a55 workarounds GCC +bug when accessing _locale_init and _stdio_init. We need the same +fix for __errno_location and __h_errno_location otherwise we crash +calling null with static and non-threaded builds. + +Signed-off-by: Timo Teräs +Signed-off-by: Bernhard Reutner-Fischer +--- + libc/misc/internals/__uClibc_main.c | 4 ++-- + 1 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c +index 3f09ad2..58f6643 100644 +--- a/libc/misc/internals/__uClibc_main.c ++++ b/libc/misc/internals/__uClibc_main.c +@@ -447,11 +447,11 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc, + * have resulted in errno being set nonzero, so set it to 0 before + * we call main. + */ +- if (likely(__errno_location!=NULL)) ++ if (likely(not_null_ptr(__errno_location))) + *(__errno_location()) = 0; + + /* Set h_errno to 0 as well */ +- if (likely(__h_errno_location!=NULL)) ++ if (likely(not_null_ptr(__h_errno_location))) + *(__h_errno_location()) = 0; + + #if defined HAVE_CLEANUP_JMP_BUF && defined __UCLIBC_HAS_THREADS_NATIVE__ +-- +1.7.1 + diff --git a/base/uclibc/uClibc-0.9.31-workaround-GCC-PR32219.patch b/base/uclibc/uClibc-0.9.31-workaround-GCC-PR32219.patch new file mode 100644 index 000000000..9ca080eb7 --- /dev/null +++ b/base/uclibc/uClibc-0.9.31-workaround-GCC-PR32219.patch @@ -0,0 +1,73 @@ +# --- SDE-COPYRIGHT-NOTE-BEGIN --- +# This copyright note is auto-generated by ./scripts/Create-CopyPatch. +# +# Filename: package/.../uclibc/uClibc-0.9.31-workaround-GCC-PR32219.patch +# Copyright (C) 2010 The OpenSDE Project +# +# More information can be found in the files COPYING and README. +# +# This patch file is dual-licensed. It is available under the license the +# patched project is licensed under, as long as it is an OpenSource license +# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms +# of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# --- SDE-COPYRIGHT-NOTE-END --- + +From 2e53dd645d5348f207cec7f8595969dc566c5a55 Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko +Date: Mon, 17 May 2010 15:56:19 +0200 +Subject: [PATCH] workaround GCC PR32219 + +we ended up calling 0 +Fixes bug #1033 + +Signed-off-by: Denys Vlasenko +Signed-off-by: Bernhard Reutner-Fischer +--- + libc/misc/internals/__uClibc_main.c | 15 +++++++++++++-- + 1 files changed, 13 insertions(+), 2 deletions(-) + +diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c +index f9e1244..4ee4443 100644 +--- a/libc/misc/internals/__uClibc_main.c ++++ b/libc/misc/internals/__uClibc_main.c +@@ -105,6 +105,17 @@ _pthread_cleanup_pop_restore(struct _pthread_cleanup_buffer *__buffer, + + #endif /* !SHARED */ + ++/* Defeat compiler optimization which assumes function addresses are never NULL */ ++static __always_inline int not_null_ptr(const void *p) ++{ ++ const void *q; ++ __asm__ ("" ++ : "=r" (q) /* output */ ++ : "0" (p) /* input */ ++ ); ++ return q != 0; ++} ++ + /* + * Prototypes. + */ +@@ -254,7 +265,7 @@ void __uClibc_init(void) + + #ifdef __UCLIBC_HAS_LOCALE__ + /* Initialize the global locale structure. */ +- if (likely(_locale_init!=NULL)) ++ if (likely(not_null_ptr(_locale_init))) + _locale_init(); + #endif + +@@ -264,7 +275,7 @@ void __uClibc_init(void) + * Thus we get a nice size savings because the stdio functions + * won't be pulled into the final static binary unless used. + */ +- if (likely(_stdio_init != NULL)) ++ if (likely(not_null_ptr(_stdio_init))) + _stdio_init(); + + } +-- +1.7.1 +