Your message dated Tue, 16 May 2023 19:50:11 +0000 with message-id <E1pz0gV-00DW3d-Jz@fasolo.debian.org> and subject line Bug#1028200: fixed in glibc 2.37-1 has caused the Debian Bug report #1028200, regarding glibc: FTBFS on alpha due to buggy GL(dl_phdr) and GL(dl_phnum) [BZ #29864] to be marked as done. This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what this message is talking about, this may indicate a serious mail system misconfiguration somewhere. Please contact owner@bugs.debian.org immediately.) -- 1028200: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1028200 Debian Bug Tracking System Contact owner@bugs.debian.org with problems
--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: glibc: FTBFS on alpha due to buggy GL(dl_phdr) and GL(dl_phnum) [BZ #29864]
- From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
- Date: Sun, 08 Jan 2023 13:39:59 +0100
- Message-id: <167318159982.1878821.14614663297550225142.reportbug@nofan.physik.fu-berlin.de>
Source: glibc Version: 2.36-8 Severity: normal Tags: patch upstream User: debian-alpha@lists.debian.org Usertags: alpha X-Debbugs-Cc: debian-alpha@lists.debian.org Hello! glibc fails to build from source on alpha with many testsuite failures [1] due to a regression introduced in glibc 2.34 [2]. According to the discussion on the libc-alpha mailing list, this issue affects multiple architectures for static builds. It just happens that it causes segmentation faults on alpha [3]. A proposed patch by Adhemveral Zanella has been posted on the list [4] but not been merged yet. I tested the first version of the patch [3] and can confirm that it works. I will test the posted version [4] now. Adhemerval said that he plans to backport the patch down to 2.34, so it will eventually show up in 2.36 as well. Either way, it might be a good idea to already carry the patch in Debian but I'm not sure. Thanks, Adrian > [1] https://buildd.debian.org/status/logs.php?pkg=glibc&arch=alpha > [2] https://sourceware.org/pipermail/libc-alpha/2023-January/144445.html > [3] https://sourceware.org/pipermail/libc-alpha/2023-January/144452.html > [4] https://sourceware.org/pipermail/libc-alpha/2023-January/144457.html -- .''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913--- Begin Message ---
- To: libc-alpha@sourceware.org, Florian Weimer <fweimer@redhat.com>, Yago Gutiérrez <yagogl@protonmail.com>
- Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>, "debian-alpha @ lists . debian . org" <debian-alpha@lists.debian.org>, gentoo-alpha@lists.gentoo.org
- Subject: [PATCH] elf: Fix GL(dl_phdr) and GL(dl_phnum) for static builds [BZ #29864]
- From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
- Date: Tue, 3 Jan 2023 11:30:11 -0300
- Message-id: <20230103143011.3836234-1-adhemerval.zanella@linaro.org>
The 73fc4e28b9464f0e refactor did not add the GL(dl_phdr) and GL(dl_phnum) for static build, relying on the __ehdr_start symbol, which is always added by the static linker, to get the correct values. This is problematic in some ways: - The segment may see its in-memory size differ from its in-file size (or the binary may have holes). The Linux has fixed is to provide concise values for both AT_PHDR and AT_PHNUM (commit 0da1d5002745c - "fs/binfmt_elf: Fix AT_PHDR for unusual ELF files") - Some archs (alpha for instance) the hidden weak reference is not correctly pulled by the static linker and __ehdr_start address end up being 0, which makes GL(dl_phdr) and GL(dl_phnum) have both invalid values (and triggering a segfault later on libc.so while accessing TLS variables). The safer fix is to just restore the previous behavior to setup GL(dl_phdr) and GL(dl_phnum) for static based on kernel auxv. The __ehdr_start fallback can also be simplified by not assuming weak linkage (as for PIE). The libc-static.c auxv init logic is moved to dl-support.c, since the later is build without SHARED and then GLRO macro is defined to access the variables directly. The _dl_phdr is also assumed to be always non NULL, since an invalid NULL values does not trigger TLS initialization (which is used in various libc systems). Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. --- csu/libc-start.c | 21 ---------- csu/libc-tls.c | 25 ++++++------ elf/dl-support.c | 52 ++++++++++++++++--------- sysdeps/unix/sysv/linux/dl-parse_auxv.h | 1 + 4 files changed, 46 insertions(+), 53 deletions(-) diff --git a/csu/libc-start.c b/csu/libc-start.c index 543560f36c..bfeee6d851 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -262,28 +262,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), } # endif _dl_aux_init (auxvec); - if (GL(dl_phdr) == NULL) # endif - { - /* Starting from binutils-2.23, the linker will define the - magic symbol __ehdr_start to point to our own ELF header - if it is visible in a segment that also includes the phdrs. - So we can set up _dl_phdr and _dl_phnum even without any - information from auxv. */ - - extern const ElfW(Ehdr) __ehdr_start -# if BUILD_PIE_DEFAULT - __attribute__ ((visibility ("hidden"))); -# else - __attribute__ ((weak, visibility ("hidden"))); - if (&__ehdr_start != NULL) -# endif - { - assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); - GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; - GL(dl_phnum) = __ehdr_start.e_phnum; - } - } __tunables_init (__environ); diff --git a/csu/libc-tls.c b/csu/libc-tls.c index ca4def2613..51d3cf99bf 100644 --- a/csu/libc-tls.c +++ b/csu/libc-tls.c @@ -119,19 +119,18 @@ __libc_setup_tls (void) __tls_pre_init_tp (); /* Look through the TLS segment if there is any. */ - if (_dl_phdr != NULL) - for (phdr = _dl_phdr; phdr < &_dl_phdr[_dl_phnum]; ++phdr) - if (phdr->p_type == PT_TLS) - { - /* Remember the values we need. */ - memsz = phdr->p_memsz; - filesz = phdr->p_filesz; - initimage = (void *) phdr->p_vaddr + main_map->l_addr; - align = phdr->p_align; - if (phdr->p_align > max_align) - max_align = phdr->p_align; - break; - } + for (phdr = _dl_phdr; phdr < &_dl_phdr[_dl_phnum]; ++phdr) + if (phdr->p_type == PT_TLS) + { + /* Remember the values we need. */ + memsz = phdr->p_memsz; + filesz = phdr->p_filesz; + initimage = (void *) phdr->p_vaddr + main_map->l_addr; + align = phdr->p_align; + if (phdr->p_align > max_align) + max_align = phdr->p_align; + break; + } /* Calculate the size of the static TLS surplus, with 0 auditors. */ _dl_tls_static_surplus_init (0); diff --git a/elf/dl-support.c b/elf/dl-support.c index 614b5b3e0c..b5ec5bd6d1 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -250,12 +250,27 @@ _dl_aux_init (ElfW(auxv_t) *av) #endif _dl_auxv = av; - dl_parse_auxv_t auxv_values; - /* Use an explicit initialization loop here because memset may not - be available yet. */ - for (int i = 0; i < array_length (auxv_values); ++i) - auxv_values[i] = 0; + dl_parse_auxv_t auxv_values = { 0, }; _dl_parse_auxv (av, auxv_values); + + _dl_phdr = (void*) auxv_values[AT_PHDR]; + _dl_phnum = auxv_values[AT_PHNUM]; + + if (_dl_phdr == NULL) + { + /* Starting from binutils-2.23, the linker will define the + magic symbol __ehdr_start to point to our own ELF header + if it is visible in a segment that also includes the phdrs. + So we can set up _dl_phdr and _dl_phnum even without any + information from auxv. */ + + extern const ElfW(Ehdr) __ehdr_start attribute_hidden; + assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); + _dl_phdr = (const void *) &__ehdr_start + __ehdr_start.e_phoff; + _dl_phnum = __ehdr_start.e_phnum; + } + + assert (_dl_phdr != NULL); } #endif @@ -324,20 +339,19 @@ _dl_non_dynamic_init (void) if (_dl_platform != NULL) _dl_platformlen = strlen (_dl_platform); - if (_dl_phdr != NULL) - for (const ElfW(Phdr) *ph = _dl_phdr; ph < &_dl_phdr[_dl_phnum]; ++ph) - switch (ph->p_type) - { - /* Check if the stack is nonexecutable. */ - case PT_GNU_STACK: - _dl_stack_flags = ph->p_flags; - break; - - case PT_GNU_RELRO: - _dl_main_map.l_relro_addr = ph->p_vaddr; - _dl_main_map.l_relro_size = ph->p_memsz; - break; - } + for (const ElfW(Phdr) *ph = _dl_phdr; ph < &_dl_phdr[_dl_phnum]; ++ph) + switch (ph->p_type) + { + /* Check if the stack is nonexecutable. */ + case PT_GNU_STACK: + _dl_stack_flags = ph->p_flags; + break; + + case PT_GNU_RELRO: + _dl_main_map.l_relro_addr = ph->p_vaddr; + _dl_main_map.l_relro_size = ph->p_memsz; + break; + } call_function_static_weak (_dl_find_object_init); diff --git a/sysdeps/unix/sysv/linux/dl-parse_auxv.h b/sysdeps/unix/sysv/linux/dl-parse_auxv.h index bf9374371e..2bf3a0ca6b 100644 --- a/sysdeps/unix/sysv/linux/dl-parse_auxv.h +++ b/sysdeps/unix/sysv/linux/dl-parse_auxv.h @@ -21,6 +21,7 @@ #include <fpu_control.h> #include <ldsodefs.h> #include <link.h> +#include <dl-auxv.h> /* For DL_PLATFORM_AUXV */ typedef ElfW(Addr) dl_parse_auxv_t[AT_MINSIGSTKSZ + 1]; -- 2.34.1
--- End Message ---
--- End Message ---
--- Begin Message ---
- To: 1028200-close@bugs.debian.org
- Subject: Bug#1028200: fixed in glibc 2.37-1
- From: Debian FTP Masters <ftpmaster@ftp-master.debian.org>
- Date: Tue, 16 May 2023 19:50:11 +0000
- Message-id: <E1pz0gV-00DW3d-Jz@fasolo.debian.org>
- Reply-to: Aurelien Jarno <aurel32@debian.org>
Source: glibc Source-Version: 2.37-1 Done: Aurelien Jarno <aurel32@debian.org> We believe that the bug you reported is fixed in the latest version of glibc, which is due to be installed in the Debian FTP archive. A summary of the changes between this version and the previous one is attached. Thank you for reporting the bug, which will now be closed. If you have further comments please address them to 1028200@bugs.debian.org, and the maintainer will reopen the bug report if appropriate. Debian distribution maintenance software pp. Aurelien Jarno <aurel32@debian.org> (supplier of updated glibc package) (This message was generated automatically at their request; if you believe that there is a problem with it please contact the archive administrators by mailing ftpmaster@ftp-master.debian.org) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Format: 1.8 Date: Tue, 16 May 2023 21:17:22 +0200 Source: glibc Architecture: source Version: 2.37-1 Distribution: experimental Urgency: medium Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org> Changed-By: Aurelien Jarno <aurel32@debian.org> Closes: 806912 1028200 Changes: glibc (2.37-1) experimental; urgency=medium . [ Aurelien Jarno ] * New upstream release: - Fix GL(dl_phdr) and GL(dl_phnum) for static builds. Closes: #1028200. - debian/symbols.wildcard: add 2.36 and GLIBC_ABI_DT_RELR. - debian/patches/localedata/locales-fr.diff: rebased. - debian/patches/alpha/local-string-functions.diff: rebased. - debian/patches/arm/git-atomic-compiler-builtins.diff: upstreamed. - debian/patches/hurd-i386/git-htl-pthread-self-early.diff: upstreamed. - debian/patches/hurd-i386/git-static-pie.diff: upstreamed. - debian/patches/hurd-i386/git-ipv6.diff: upstreamed. - debian/patches/hurd-i386/git-ip_mreqn.diff: upstreamed. - debian/patches/hurd-i386/git-bootstrap-enable_secure.diff: upstreamed. - debian/patches/hurd-i386/git-cond-destroy.diff: upstreamed. - debian/patches/hurd-i386/git-strerror_X.diff: upstreamed. - debian/patches/hurd-i386/git-xpg_strerror.diff: upstreamed. - debian/patches/hurd-i386/git-readlink-fifo.diff: upstreamed. - debian/patches/hurd-i386/git-net-route.h.diff: upstreamed. - debian/patches/hurd-i386/git-SOMAXCONN.diff: upstreamed. - debian/patches/hurd-i386/git-sigtimedwait.diff: upstreamed. - debian/patches/hurd-i386/git-getrandom-chroot.diff: upstreamed. - debian/patches/hurd-i386/git-mach-headers-freestanding.diff: upstreamed. - debian/patches/hurd-i386/git-sem_wait_race.diff: upstreamed. - debian/patches/hurd-i386/local-enable-ldconfig.diff: rebased. - debian/patches/any/local-ldso-disable-hwcap.diff: removed, obsolete. - debian/patches/any/local-ldconfig-multiarch.diff: rebased. - debian/patches/any/git-floatn-gcc-13-support.diff: upstreamed. - debian/patches/hurd-i386/submitted-net.diff: rebased. - debian/patches/hurd-i386/local-no-bootstrap-fs-access.diff: removed, obsolete. * Stop building libc6.1-alphaev67 package, as support for legacy hwcaps has been removed upstream: - debian/control.in/libc: add a conflicts against libc6.1-alphaev67 on alpha. - debian/control.in/opt: remove libc6.1-alphaev67 entry. - debian/patches/alpha/local-string-functions.diff: remove, obsolete. - debian/rules: drop DEBUG_libc6.1-alphaev67. - debian/script.in/nohwcap.sh: drop code to support libc6.1-alphaev67. debian/testsuite-xfail-debian.mk: simplify alpha condition. * Drop support for optimized packages from the packaging (Closes: #806912): - debian/control.in/opt: removed. - debian/rules.d/control.mk: drop support for including control.in/opt. - debian/script.in/nohwcap.sh: removed. - debian/rules.d/debhelper.mk: dropped code to include nohwcap.sh. - debian/debhelper.in/libc.postinst: removed call to nohwcap code. - debian/debhelper.in/libc.preinst: remove code creating /etc/ld.so.nohwcap. - debian/debhelper.in/glibc-source.lintian-overrides: removed otherbuild entries. - debian/debhelper.in/libc-otherbuild.*: removed. * debian/sysdeps/alpha.mk: temporarily build for EV56 until the baseline is raised at the GCC level. . [ Samuel Thibault ] * debian/patches/hurd-i386/git-tst-system.diff: Fix tst-system link. Checksums-Sha1: f8c325d858eb62094c7f2f82daef441c8326e9a7 9646 glibc_2.37-1.dsc 91e3b13573d81b5736e9c09b5f8babbf5c8d4990 19503016 glibc_2.37.orig.tar.xz 0212e35f39a12358209c2bb6e0fdb127749bb396 783592 glibc_2.37-1.debian.tar.xz 496b9e8c7783583ca2e1b7f453a1400c68811084 9508 glibc_2.37-1_source.buildinfo Checksums-Sha256: 65037ecec0ea9278b736383d89201f3113f79b83fcf15974ba9e6acfe363f23a 9646 glibc_2.37-1.dsc d05f010158c16cef110fa1ab560c31477249ee2105360101858a5146aa6fe7d0 19503016 glibc_2.37.orig.tar.xz f8a2239537888990a806f18cab7c412d3b68e86a67eade1057118ebbe69cb198 783592 glibc_2.37-1.debian.tar.xz f56bec05eeb69c51b7c0420b3df76569aff65b19aeeddbf8a26d336f195e3709 9508 glibc_2.37-1_source.buildinfo Files: 97b2c7895b78104272af9243d1ca5e1e 9646 libs required glibc_2.37-1.dsc ba2cc04c085e1324235d6e7a1e947b58 19503016 libs required glibc_2.37.orig.tar.xz 2c05e4bda780bb8a257f16006a6d8d68 783592 libs required glibc_2.37-1.debian.tar.xz ece076b81cbbccd7cd27e4af1b09006f 9508 libs required glibc_2.37-1_source.buildinfo -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEUryGlb40+QrX1Ay4E4jA+JnoM2sFAmRj2ZsACgkQE4jA+Jno M2tXbBAAiUxqeaTjZ4Q7XwC327uC3A9yop3aI9oN0Xu1rmpSGc9vqJ4P2878foEE Qrh3TwiJw3488fCHC3SKgJvxMYIZy0HRKKRxHKlVQ0Iy0XiZ6dwtjazIHAGT32UJ LWjaV7rPr5tV458dmzD4PHfWJiA0Hi3Y6W7xVrosTl/tDbQsHcDOqLe4pqg9hJD5 OdYD9fZL3HDRKk8VTGjXqbghRW/mSZ42J19ncQIa+YJFRCZEuxMwflzfZmxcqze1 5tpvLDiWAT/Ys40l0lav3HWstG7gPv09ZUP721ThP0Wj7ftL3LxoWYGkRcsxDVlL aspyC55I0v53Xi/diX7g7zXi8pER3PRHxLdTIILptk0WEl+y/uw9I0k8LgO8cdPN HkyKcpWjqoEOEG7yG8g78vPBdxFuISL1qwdry4X6fdiSnKi6y3PN3lM65hkY+1WO K4y1CNxciYEStaocIA9GtmXngpBVYLIgE9+hBk+41qqPJ8BVCX8VUWKECk9xNdO6 pvnMaswAe16QGlsgTM+BHSVXeeDMzrW6OzQ1rUyRn7tWRHeLOkIpGSYdln0JQQYE Guf02GAdb7812UhXv0fZcNN0QJkbmp7sa+4oxHM3hX/qzuvVxxM+3eEDCSbWfbXL rIpa0fJQhl5ImZe3iKncgAKm8Ydl21U62+KDk26MQAnixub3ZLE= =+Q0z -----END PGP SIGNATURE-----
--- End Message ---