From 13fcd46ea7d2d93858061748d6428b900150f6ad Mon Sep 17 00:00:00 2001 From: Christophe Lyon Date: Wed, 4 Jul 2018 17:55:38 +0200 Subject: nptl: Clear TLS area for static binaries. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit busybox init checks it has pid 1, but getpid() returns another value when building busybox statically. This is because the corresponding area is not cleared when allocated (it is allocated with MAP_UNINITIALIZED, whose behavior depends on the Linux kernel's CONFIG_MMAP_ALLOW_UNINITIALIZED). This patch fixes the problem by explicitly clearing the memory area. * libpthread/nptl/sysdeps/generic/libc-tls.c (__libc_tls_setup): Clear tlsblock. Signed-off-by: Mickaël Guêné Signed-off-by: Christophe Lyon --- libpthread/nptl/sysdeps/generic/libc-tls.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libpthread/nptl/sysdeps') diff --git a/libpthread/nptl/sysdeps/generic/libc-tls.c b/libpthread/nptl/sysdeps/generic/libc-tls.c index 725f3dfc7..5f89c9172 100644 --- a/libpthread/nptl/sysdeps/generic/libc-tls.c +++ b/libpthread/nptl/sysdeps/generic/libc-tls.c @@ -162,6 +162,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign) tcb_offset = roundup (tcbsize, align ?: 1); tlsblock = sbrk (tcb_offset + memsz + max_align + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); + memset(tlsblock, '\0', tcb_offset + memsz + max_align + TLS_PRE_TCB_SIZE + GL(dl_tls_static_size)); tlsblock += TLS_PRE_TCB_SIZE; # else /* In case a model with a different layout for the TCB and DTV -- cgit v1.2.3