uclibc: Switch to using uclibc-ng

uclibc-ng is a maintained fork of uclibc project. Lets switch to using that
add patches to fix memory leak in canonicalize_file_name-memory

(From OE-Core rev: 6a4996395f56836195f5ba10a554ba04eb304c13)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Khem Raj 2015-12-13 04:47:05 +00:00 committed by Richard Purdie
parent 0b5cdddfc0
commit 63bdadccb6
14 changed files with 136 additions and 496 deletions

View File

@ -27,7 +27,7 @@ SDKGCCVERSION ?= "${GCCVERSION}"
BINUVERSION ?= "2.25%"
GDBVERSION ?= "7.9%"
GLIBCVERSION ?= "2.22"
UCLIBCVERSION ?= "0.9.33+git%"
UCLIBCVERSION ?= "1.0%"
LINUXLIBCVERSION ?= "4.1"
PREFERRED_VERSION_gcc ?= "${GCCVERSION}"

View File

@ -119,6 +119,7 @@ def features_to_uclibc_settings(d):
uclibc_cfg('thumb-interwork', distro_features,'USE_BX', cnf, rem)
uclibc_cfg('xattr', distro_features, 'UCLIBC_HAS_XATTR', cnf, rem)
uclibc_cfg('ssp', distro_features, 'UCLIBC_HAS_SSP', cnf, rem)
uclibc_cfg('ssp', distro_features, 'UCLIBC_BUILD_SSP', cnf, rem)
uclibc_cfg('argp', distro_features, 'UCLIBC_HAS_ARGP', cnf, rem)
uclibc_cfg('libc-posix-clang-wchar', distro_features,'UCLIBC_HAS_WCHAR', cnf, rem)
return "\n".join(cnf), "\n".join(rem)

View File

@ -1,24 +1,19 @@
SRCREV = "ca1c74d67dd115d059a875150e10b8560a9c35a8"
SRCREV = "d1b81113b43a6d26dec4e0e58a380895d121006e"
PV = "0.9.33+git${SRCPV}"
PV = "1.0.9+git${SRCPV}"
FILESEXTRAPATHS =. "${FILE_DIRNAME}/uclibc-git:"
SRC_URI = "git://uclibc.org/uClibc.git;branch=master \
SRC_URI = "git://uclibc-ng.org/git/uclibc-ng;branch=1.0 \
file://0001-Disable-lrount_tes-function.patch \
file://0001-Revert-glibc-compat-bump-glibc-minor-version.patch \
file://0002-Add-implementation-for-copysignl-for-ppc.patch \
file://0003-Add-argp-implementation.patch \
file://libc-stdlib-canonicalize_file_name-memory-leak.patch \
file://uClibc.machine \
file://uClibc.distro \
file://obstack.cfg \
file://locale.cfg \
file://0001-Disable-lrount_tes-function.patch \
file://0002-Add-implementation-for-copysignl-for-ppc.patch \
file://0003-Add-argp-implementation.patch \
file://0004-Dont-support-localised-optimizations-this-helps-to-h.patch \
file://0005-Always-use-O2-for-compiling-fork.c.patch \
file://0006-ldso-limited-support-for-ORIGIN-in-rpath.patch \
file://0007-nptl-atfork-Hide-pthread_atfork-in-shared-versions.patch \
file://0001-gcc5-optimizes-away-the-write-only-static-functions-.patch \
file://0001-fcntl-Add-AT_EMPTY_PATH-for-all-and-O_PATH-for-arm.patch \
file://0001-wire-in-syncfs.patch \
"
S = "${WORKDIR}/git"

View File

@ -0,0 +1,28 @@
From f9f566849ad0785b2fd3fd6c4c5d324f9f822aac Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 13 Dec 2015 17:25:11 +0000
Subject: [PATCH] Revert "glibc compat: bump glibc minor version"
This reverts commit 4ff3a6c8eb91db71d6dc3d2932b66e848bd20ac3.
---
Upstream-Status: Inappropriate [ OE-Specific ]
include/features.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/features.h b/include/features.h
index f6fbbf4..dcf1348 100644
--- a/include/features.h
+++ b/include/features.h
@@ -393,7 +393,7 @@ uClibc was built without large file support enabled.
these macros to test for features in specific releases. */
/* Don't do it, if you want to keep uClibc happy. */
#define __GLIBC__ 2
-#define __GLIBC_MINOR__ 10
+#define __GLIBC_MINOR__ 2
#endif
#define __GLIBC_PREREQ(maj, min) \
--
2.6.4

View File

@ -1,42 +0,0 @@
From 4c8f5fe7d41493e8e181941ae5a01713155f44d1 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 15 Oct 2015 15:34:39 +0000
Subject: [PATCH] fcntl: Add AT_EMPTY_PATH for all and O_PATH for arm
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending
include/fcntl.h | 3 +++
libc/sysdeps/linux/arm/bits/fcntl.h | 1 +
2 files changed, 4 insertions(+)
diff --git a/include/fcntl.h b/include/fcntl.h
index 11000dd..8a7ad9b 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -65,6 +65,9 @@ __BEGIN_DECLS
# define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
# define AT_EACCESS 0x200 /* Test access permitted for
effective IDs, not real IDs. */
+# ifdef __USE_GNU
+# define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname. */
+# endif
#endif
/* Do the file control operation described by CMD on FD.
diff --git a/libc/sysdeps/linux/arm/bits/fcntl.h b/libc/sysdeps/linux/arm/bits/fcntl.h
index aedc154..c6ba958 100644
--- a/libc/sysdeps/linux/arm/bits/fcntl.h
+++ b/libc/sysdeps/linux/arm/bits/fcntl.h
@@ -50,6 +50,7 @@
# define O_DIRECT 0200000 /* Direct disk access. */
# define O_NOATIME 01000000 /* Do not set atime. */
# define O_CLOEXEC 02000000 /* Set close_on_exec. */
+# define O_PATH 010000000 /* Resolve pathname but do not open file. */
#endif
/* For now Linux has synchronisity options for data and read operations.
--
2.6.1

View File

@ -1,51 +0,0 @@
From 2659fb25d32f4b29c1c96aa5730fe40e19d53ab0 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 14 Oct 2015 17:38:37 -0700
Subject: [PATCH] gcc5 optimizes away the write only static functions and we
end up with
librt/librt_so.a(rt-unwind-resume.oS): In function `_Unwind_Resume':
rt-unwind-resume.c:(.text+0x3c): undefined reference to `libgcc_s_resume'
collect2: error: ld returned 1 exit status
make[2]: *** [lib/librt.so] Error 1
marking these functions explicitly used with __attribute_used__ avoids
that optimization.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending
libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c | 2 +-
libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c
index f4d6f41..0c2edd7 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c
@@ -27,7 +27,7 @@
#define __libc_fatal(x) {/*write(STDERR_FILENO, x, strlen(x));*/ abort();}
static void *libgcc_s_handle;
-static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc) __attribute_used__;
static _Unwind_Reason_Code (*libgcc_s_personality)
(_Unwind_State, struct _Unwind_Exception *, struct _Unwind_Context *);
static _Unwind_Reason_Code (*libgcc_s_forcedunwind)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c
index f9a4ffb..f0c3047 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c
@@ -25,7 +25,7 @@
#define __libc_dlclose dlclose
#define __libc_fatal(x) {/*write(STDERR_FILENO, x, strlen(x));*/ abort();}
-static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
+static void (*libgcc_s_resume) (struct _Unwind_Exception *exc) __attribute_used__;
static _Unwind_Reason_Code (*libgcc_s_personality)
(_Unwind_State, struct _Unwind_Exception *, struct _Unwind_Context *);
--
2.6.1

View File

@ -1,49 +0,0 @@
From 4f2db1b46bda5e376245ec36198b137709f069e8 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 15 Oct 2015 17:03:37 +0000
Subject: [PATCH] wire in syncfs
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending
include/unistd.h | 2 +-
libc/sysdeps/linux/common/syncfs.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 libc/sysdeps/linux/common/syncfs.c
diff --git a/include/unistd.h b/include/unistd.h
index 3793d2d..d01bb08 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -1073,7 +1073,7 @@ extern char *getpass (const char *__prompt) __nonnull ((1));
extern int fsync (int __fd);
#endif /* Use BSD || X/Open || Unix98. */
-#if 0 /*def __USE_GNU */
+#ifdef __USE_GNU
/* Make all changes done to all files on the file system associated
* with FD actually appear on disk. */
extern int syncfs (int __fd) __THROW;
diff --git a/libc/sysdeps/linux/common/syncfs.c b/libc/sysdeps/linux/common/syncfs.c
new file mode 100644
index 0000000..d2eed05
--- /dev/null
+++ b/libc/sysdeps/linux/common/syncfs.c
@@ -0,0 +1,13 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * fsync() for uClibc
+ *
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <sys/syscall.h>
+#include <unistd.h>
+
+_syscall1(int, syncfs, int, fd)
--
2.6.1

View File

@ -1,30 +0,0 @@
From 31785c544abe8b215dbb2264fb11ee7051515797 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 16 Aug 2015 20:58:59 -0700
Subject: [PATCH 4/7] Dont support localised optimizations this helps to have a
global -O level
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending
libpthread/nptl/pthread_mutex_timedlock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libpthread/nptl/pthread_mutex_timedlock.c b/libpthread/nptl/pthread_mutex_timedlock.c
index 04187f6..f56f6c5 100644
--- a/libpthread/nptl/pthread_mutex_timedlock.c
+++ b/libpthread/nptl/pthread_mutex_timedlock.c
@@ -28,7 +28,9 @@
* error: can't find a register in class GENERAL_REGS while reloading asm
*/
int
+#ifndef __OPTIMIZE__
attribute_optimize("Os")
+#endif
pthread_mutex_timedlock (
pthread_mutex_t *mutex,
const struct timespec *abstime)
--
2.1.4

View File

@ -1,33 +0,0 @@
From 883debc22e30a947fe5858cc07ee5aebd3d07a2e Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 16 Aug 2015 20:59:56 -0700
Subject: [PATCH 5/7] Always use -O2 for compiling fork.c
When compiling in thumb mode for arm with -Os gcc gives up since it can
not find registers to spill. So we use -O2 option for compiling fork.c
It may be addressable in gcc.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending
libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch
index 0ea0b29..0767e9c 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch
@@ -21,3 +21,9 @@ ASFLAGS-pt-vfork.S = -marm
CFLAGS-OMIT-pt-vfork.S = -mthumb
ASFLAGS-vfork.S = -marm
CFLAGS-OMIT-vfork.S = -mthumb
+
+# For arm fork.c does not compile with -Os when compiling
+# in thumb1 mode
+ifeq ($(COMPILE_IN_THUMB_MODE),y)
+CFLAGS-fork.c = -O2
+endif
--
2.1.4

View File

@ -1,233 +0,0 @@
From b40c129ed2d53b69463883a5422dd4a012a398f9 Mon Sep 17 00:00:00 2001
From: Junling Zheng <zhengjunling@huawei.com>
Date: Fri, 3 Apr 2015 05:02:27 +0000
Subject: [PATCH 6/7] ldso: limited support for $ORIGIN in rpath
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Derived from:
http://lists.busybox.net/pipermail/uclibc/2011-March/045003.html
However, the above patch introduced '_dl_strchr' in ldso/ldso/dl-elf.c,
and caused the following undefined referencing compiling error:
| .../libdl.a(libdl.os): In function `search_for_named_library':
| .../dl-elf.c:156: undefined reference to `_dl_strchr'
| collect2: error: ld returned 1 exit status
This problem would be reproduced through compiling gdb in static mode
using uclibc.
So, add the definition of '_dl_strchr' to fix it. The '_dl_strstr' is
added as well.
Upstream-Status: Submitted
Signed-off-by: Timo Teräs <timo.teras at iki.fi>
Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending
ldso/include/dl-string.h | 2 ++
ldso/ldso/dl-elf.c | 79 +++++++++++++++++++++++++-----------------------
ldso/ldso/ldso.c | 18 +++++++++--
3 files changed, 59 insertions(+), 40 deletions(-)
diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h
index aacad10..14ae617 100644
--- a/ldso/include/dl-string.h
+++ b/ldso/include/dl-string.h
@@ -204,7 +204,9 @@ static __always_inline char * _dl_get_last_path_component(char *path)
# define _dl_strcat strcat
# define _dl_strcpy strcpy
# define _dl_strcmp strcmp
+# define _dl_strchr strchr
# define _dl_strrchr strrchr
+# define _dl_strstr strstr
# define _dl_memcpy memcpy
# define _dl_memcmp memcmp
# define _dl_memset memset
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 5631905..6ab7afe 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -133,56 +133,60 @@ _dl_protect_relro (struct elf_resolve *l)
* in uClibc/ldso/util/ldd.c */
static struct elf_resolve *
search_for_named_library(const char *name, unsigned rflags, const char *path_list,
- struct dyn_elf **rpnt)
+ struct dyn_elf **rpnt, const char* origin)
{
- char *path, *path_n, *mylibname;
+ char *mylibname;
+ const char *p, *pn;
struct elf_resolve *tpnt;
- int done;
+ int plen;
if (path_list==NULL)
return NULL;
- /* We need a writable copy of this string, but we don't
- * need this allocated permanently since we don't want
- * to leak memory, so use alloca to put path on the stack */
- done = _dl_strlen(path_list);
- path = alloca(done + 1);
-
/* another bit of local storage */
mylibname = alloca(2050);
- _dl_memcpy(path, path_list, done+1);
-
/* Unlike ldd.c, don't bother to eliminate double //s */
/* Replace colons with zeros in path_list */
/* : at the beginning or end of path maps to CWD */
/* :: anywhere maps CWD */
/* "" maps to CWD */
- done = 0;
- path_n = path;
- do {
- if (*path == 0) {
- *path = ':';
- done = 1;
+ for (p = path_list; p != NULL; p = pn) {
+ pn = _dl_strchr(p + 1, ':');
+ if (pn != NULL) {
+ plen = pn - p;
+ pn++;
+ } else
+ plen = _dl_strlen(p);
+
+ if (plen >= 7 && _dl_memcmp(p, "$ORIGIN", 7) == 0) {
+ int olen;
+ if (rflags && plen != 7)
+ continue;
+ if (origin == NULL)
+ continue;
+ for (olen = _dl_strlen(origin) - 1; olen >= 0 && origin[olen] != '/'; olen--)
+ ;
+ if (olen <= 0)
+ continue;
+ _dl_memcpy(&mylibname[0], origin, olen);
+ _dl_memcpy(&mylibname[olen], p + 7, plen - 7);
+ mylibname[olen + plen - 7] = 0;
+ } else if (plen != 0) {
+ _dl_memcpy(mylibname, p, plen);
+ mylibname[plen] = 0;
+ } else {
+ _dl_strcpy(mylibname, ".");
}
- if (*path == ':') {
- *path = 0;
- if (*path_n)
- _dl_strcpy(mylibname, path_n);
- else
- _dl_strcpy(mylibname, "."); /* Assume current dir if empty path */
- _dl_strcat(mylibname, "/");
- _dl_strcat(mylibname, name);
+ _dl_strcat(mylibname, "/");
+ _dl_strcat(mylibname, name);
#ifdef __LDSO_SAFE_RUNPATH__
- if (*mylibname == '/')
+ if (*mylibname == '/')
#endif
- if ((tpnt = _dl_load_elf_shared_library(rflags, rpnt, mylibname)) != NULL)
- return tpnt;
- path_n = path+1;
- }
- path++;
- } while (!done);
+ if ((tpnt = _dl_load_elf_shared_library(rflags, rpnt, mylibname)) != NULL)
+ return tpnt;
+ }
return NULL;
}
@@ -234,7 +238,8 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp
if (pnt) {
pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
_dl_if_debug_dprint("\tsearching RPATH='%s'\n", pnt);
- if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL)
+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt,
+ tpnt->libname)) != NULL)
return tpnt1;
}
#endif
@@ -243,7 +248,7 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp
/* Check in LD_{ELF_}LIBRARY_PATH, if specified and allowed */
if (_dl_library_path) {
_dl_if_debug_dprint("\tsearching LD_LIBRARY_PATH='%s'\n", _dl_library_path);
- if ((tpnt1 = search_for_named_library(libname, rflags, _dl_library_path, rpnt)) != NULL)
+ if ((tpnt1 = search_for_named_library(libname, rflags, _dl_library_path, rpnt, NULL)) != NULL)
{
return tpnt1;
}
@@ -257,7 +262,7 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp
if (pnt) {
pnt += (unsigned long) tpnt->dynamic_info[DT_STRTAB];
_dl_if_debug_dprint("\tsearching RUNPATH='%s'\n", pnt);
- if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt)) != NULL)
+ if ((tpnt1 = search_for_named_library(libname, rflags, pnt, rpnt, NULL)) != NULL)
return tpnt1;
}
#endif
@@ -291,7 +296,7 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp
/* Look for libraries wherever the shared library loader
* was installed */
_dl_if_debug_dprint("\tsearching ldso dir='%s'\n", _dl_ldsopath);
- tpnt1 = search_for_named_library(libname, rflags, _dl_ldsopath, rpnt);
+ tpnt1 = search_for_named_library(libname, rflags, _dl_ldsopath, rpnt, NULL);
if (tpnt1 != NULL)
return tpnt1;
#endif
@@ -304,7 +309,7 @@ struct elf_resolve *_dl_load_shared_library(unsigned rflags, struct dyn_elf **rp
#ifndef __LDSO_CACHE_SUPPORT__
":" UCLIBC_RUNTIME_PREFIX "usr/X11R6/lib"
#endif
- , rpnt);
+ , rpnt, NULL);
if (tpnt1 != NULL)
return tpnt1;
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index f38f9e3..3812908 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -402,6 +402,20 @@ static ptrdiff_t _dl_build_local_scope (struct elf_resolve **list,
p += _dl_build_local_scope (p, q->tpnt);
return p - list;
}
+
+static void _dl_setup_progname(const char *argv0)
+{
+ char image[PATH_MAX];
+ ssize_t s;
+
+ s = _dl_readlink("/proc/self/exe", image, sizeof(image));
+ if (s > 0 && image[0] == '/') {
+ image[s] = 0;
+ _dl_progname = _dl_strdup(image);
+ } else if (argv0) {
+ _dl_progname = argv0;
+ }
+}
void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
ElfW(auxv_t) auxvt[AT_EGID + 1], char **envp, char **argv
@@ -454,9 +468,7 @@ void *_dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
* been fixed up by now. Still no function calls outside of this
* library, since the dynamic resolver is not yet ready.
*/
- if (argv[0]) {
- _dl_progname = argv[0];
- }
+ _dl_setup_progname(argv[0]);
#ifdef __DSBT__
_dl_ldso_dsbt = (void *)tpnt->dynamic_info[DT_DSBT_BASE_IDX];
--
2.1.4

View File

@ -1,35 +0,0 @@
From 90516af9f776f9c2835b47fc52775dcb307a85ac Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 23 Jun 2012 15:59:01 -0700
Subject: [PATCH 7/7] nptl/atfork: Hide pthread_atfork in shared versions
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Upstream-Status: Pending
---
libpthread/nptl/Makefile.in | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
index 55eeba2..8cb8fa9 100644
--- a/libpthread/nptl/Makefile.in
+++ b/libpthread/nptl/Makefile.in
@@ -16,6 +16,7 @@ libc-shared-routines-y = forward.c libc-cancellation.c
libc-static-routines-y = alloca_cutoff.c libc-cancellation.c
libpthread-shared-only-routines-y = version.c
libpthread-static-only-routines-y = pthread_atfork.c
+
libpthread-routines- += $(notdir $(wildcard $(libpthread_DIR)/gen_*.c)) # dummy generated files
libpthread-routines- += allocatestack.c # dummy included by pthread_create.c
libpthread-routines- += pthread_mutex_getprioceiling.c pthread_mutex_setprioceiling.c # XXX: delete those or use them!
@@ -201,7 +202,7 @@ CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pt-system.c = -fexceptions -I$(top_srcdir)libc/stdlib
-
+CFLAGS-pthread_atfork.c = -DNOT_IN_libc
#
# The rest of this file is uClibc specific.
#
--
2.1.4

View File

@ -0,0 +1,95 @@
From patchwork Wed Oct 21 06:02:30 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: libc/stdlib: canonicalize_file_name() memory leak
From: =?utf-8?q?Wojciech_Nizi=C5=84ski?= <niziak@spox.org>
X-Patchwork-Id: 533608
Message-Id: <loom.20151021T080015-833@post.gmane.org>
To: uclibc@uclibc.org
Date: Wed, 21 Oct 2015 06:02:30 +0000 (UTC)
System based on Buildroot 2014.11
Linux 3.10.88
uclibc 0.9.33.2 (also with 1.0.2)
systemd 216
gcc 4.8.3 (also with 4.9.2)
Bug:
After 2 days system is out of memory. PID 1 (systemd) is allocating.
over 120MB od RAM..
Just after reboot PID 1 is taking only about 600kB.
How to reproduce:
With every systemd service reload or restart, heap of PID 1 grows.
Try with command:
watch -n1 \
'systemctl stop systemd-sysctl ; grep heap /proc/1/smaps -A15; free'
Source of bug:
Uclibc's canonicalize_file_name() is allocating temprary buffer of.
4kB (PATH_MAX), and passing it to realpath() as second argument..
Function canonicalize... is not checking if realpath() fails and.
memory is lost.
Backtrace:
#0 malloc (bytes=4096) at libc/stdlib/malloc-standard/malloc.c:844
#1 canonicalize_file_name.
(name="/etc/systemd/system/systemd-sysctl.service.d") at.
libc/stdlib/canonicalize.c:30
#2 path_strv_resolve (...) at src/shared/path-util.c:275
Solution:
Do not use temporary buffer like in eglibc.
Function realpath() will be responsible for allocation.
From: Wojciech Nizinski <w.nizinski@grinn-global.com>
Date: Tue, 20 Oct 2015 14:08:09 +0200
Subject: [PATCH]libc/stdlib: canonicalize_file_name() memory leak
Uclibc's canonicalize_file_name() is allocating temprary buffer of 4kB
(PATH_MAX), and passing it to realpath() as second argument. Function is
not checking if realpath() fails and memory is lost.
---
Upstream-Status: Submitted
libc/stdlib/canonicalize.c | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/libc/stdlib/canonicalize.c b/libc/stdlib/canonicalize.c
index 06e710a..da09d58 100644
--- a/libc/stdlib/canonicalize.c
+++ b/libc/stdlib/canonicalize.c
@@ -9,30 +9,11 @@
*/
#include <stdlib.h>
-#include <limits.h>
#ifdef __USE_GNU
-#ifndef PATH_MAX
-# ifdef _POSIX_VERSION
-# define PATH_MAX _POSIX_PATH_MAX
-# else
-# ifdef MAXPATHLEN
-# define PATH_MAX MAXPATHLEN
-# else
-# define PATH_MAX 1024
-# endif
-# endif
-#endif
-
char * canonicalize_file_name (const char *name)
{
- char *buf = (char *) malloc(PATH_MAX);
-
- if(unlikely(buf == NULL))
- return NULL;
-
- *buf='\0';
- return realpath (name, buf);
+ return realpath (name, NULL);
}
#endif

View File

@ -79,11 +79,11 @@ UCLIBC_HAS_GLIBC_CUSTOM_PRINTF=y
UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9
UCLIBC_HAS_SCANF_GLIBC_A_FLAG=y
# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set
UCLIBC_HAS_STDIO_BUFSIZ_256=y
# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_1024 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set
# UCLIBC_HAS_STDIO_BUFSIZ_4096 is not set
UCLIBC_HAS_STDIO_BUFSIZ_4096=y
# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set
UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y
# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set

View File

@ -13,7 +13,6 @@ SECTION = "libs"
LIC_FILES_CHKSUM = "file://COPYING.LIB;md5=a6f89e2100d9b6cdffcea4f398e37343 \
file://COPYING.LIB.boilerplate;md5=aaddeadcddeb918297e0e4afc52ce46f \
file://${S}/test/regex/testregex.c;beginline=1;endline=31;md5=234efb227d0a40677f895e4a1e26e960"
PR = "r9"
require uclibc-config.inc
@ -60,18 +59,13 @@ export V="2"
CFLAGS_arm := "${@oe_filter_out('-fno-omit-frame-pointer', '${CFLAGS}', d)}"
UCLIBC_EXTRA_CFLAGS := "${@oe_filter_out('(-I\S+|-i\S+)', '${CFLAGS}', d)}"
do_compile_prepend () {
unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
oe_runmake pregen
}
configmangle = '/^KERNEL_HEADERS/d; \
/^RUNTIME_PREFIX/d; \
/^DEVEL_PREFIX/d; \
/^SHARED_LIB_LOADER_PREFIX/d; \
/^UCLIBC_EXTRA_CFLAGS/d; \
s,.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g; \
${@["","s,.*COMPILE_IN_THUMB_MODE.*,COMPILE_IN_THUMB_MODE=y,;"][d.getVar("ARM_INSTRUCTION_SET", True) != "arm"]} \
${@["","s,.*COMPILE_IN_THUMB_MODE.*,COMPILE_IN_THUMB_MODE=y,;"][d.getVar("ARM_INSTRUCTION_SET", True) == "thumb"]} \
${@["","s,.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=y,;"][d.getVar("USE_NLS", True) == "yes"]} \
${@["","s,.*LDSO_GNU_HASH_SUPPORT.*,# LDSO_GNU_HASH_SUPPORT is not set,;"][d.getVar("TARGET_ARCH", True) in ['mips', 'mipsel', 'mips64', 'mips64el', 'avr32']]} \
/^CROSS/d; \