summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* elf: Remove incorrect dynamic-link.h from _dl_relocate_static_piemaskray/grte-oldFangrui Song2021-08-271-1/+0
| | | | | The header is included without STATIC_PIE_BOOTSTRAP. This may introduce harmful GOT relocation on aarch64.
* aarch64: Make elf_machine_{load_address,dynamic} robust [BZ #28203]Fangrui Song2021-08-261-15/+9
| | | | | | | | | | | | | | | | | | | | | The AArch64 ABI is largely platform agnostic and does not specify _GLOBAL_OFFSET_TABLE_[0] ([1]). glibc ld.so turns out to be probably the only user of _GLOBAL_OFFSET_TABLE_[0] and GNU ld defines the value to the link-time address _DYNAMIC. [2] In 2012, __ehdr_start was implemented in GNU ld and gold in binutils 2.23. Using adrp+add / (-mcmodel=tiny) adr to access __ehdr_start/_DYNAMIC gives us a robust way to get the load address and the link-time address of _DYNAMIC. [1]: From a psABI maintainer, https://bugs.llvm.org/show_bug.cgi?id=49672#c2 [2]: LLD's aarch64 port does not set _GLOBAL_OFFSET_TABLE_[0] to the link-time address _DYNAMIC. LLD is widely used on aarch64 Android and ChromeOS devices. Software just works without the need for _GLOBAL_OFFSET_TABLE_[0]. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com> (cherry picked from commit 43d06ed218fc8be58987bdfd00e21e5720f0b862)
* elf: Unconditionally use __ehdr_startFangrui Song2021-08-264-98/+4
| | | | | | | | | | | | | | We can consider __ehdr_start (from binutils 2.23 onwards) unconditionally supported, since configure.ac requires binutils>=2.25. The configure.ac check is related to an ia64 bug fixed by binutils 2.24. See https://sourceware.org/pipermail/libc-alpha/2014-August/053503.html Tested on x86_64-linux-gnu. Tested build-many-glibcs.py with aarch64-linux-gnu and s390x-linux-gnu. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com> (cherry picked from commit 302247c89121e8d4c7629e589edbb4974fff6edb)
* Revert "Add a workaround for lld placing the _GLOBAL_OFFSET_TABLE_ at an ↵Fangrui Song2021-08-261-10/+0
| | | | | | | | | unexpected location" This reverts commit 575707c22f901b0adcce2478cc32da62afff287e. The issue has been fixed by LLD patch https://reviews.llvm.org/D59594 and fixed by glibc upstream as well.
* wordexp: handle overflow in positional parameter number (bug 28011)Andreas Schwab2021-07-232-1/+2
| | | | Use strtoul instead of atoi so that overflow can be detected.
* Disable tests that need more-recent infrastructureStan Shebs2021-07-232-1/+3
|
* intl: Handle translation output codesets with suffixes [BZ #26383]Arjun Shankar2021-07-238-57/+60
| | | | | | | | | | | | | | Commit 91927b7c7643 (Rewrite iconv option parsing [BZ #19519]) did not handle cases where the output codeset for translations (via the `gettext' family of functions) might have a caller specified encoding suffix such as TRANSLIT or IGNORE. This led to a regression where translations did not work when the codeset had a suffix. This commit fixes the above issue by parsing any suffixes passed to __dcigettext and adds two new test-cases to intl/tst-codeset.c to verify correct behaviour. The iconv-internal function __gconv_create_spec and the static iconv-internal function gconv_destroy_spec are now visible internally within glibc and used in intl/dcigettext.c.
* Rewrite iconv option parsing [BZ #19519]Arjun Shankar2021-07-2311-143/+988
| | | | | | | | | | | | | | | | This commit replaces string manipulation during `iconv_open' and iconv_prog option parsing with a structured, flag based conversion specification. In doing so, it alters the internal `__gconv_open' interface and accordingly adjusts its uses. This change fixes several hangs in the iconv program and therefore includes a new test to exercise iconv_prog options that originally led to these hangs. It also includes a new regression test for option handling in the iconv function. Reviewed-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* iconv: Accept redundant shift sequences in IBM1364 [BZ #26224]Arjun Shankar2021-07-231-12/+2
| | | | | | | | | | | | | | | The IBM1364, IBM1371, IBM1388, IBM1390 and IBM1399 character sets share converter logic (iconvdata/ibm1364.c) which would reject redundant shift sequences when processing input in these character sets. This led to a hang in the iconv program (CVE-2020-27618). This commit adjusts the converter to ignore redundant shift sequences and adds test cases for iconv_prog hangs that would be triggered upon their rejection. This brings the implementation in line with other converters that also ignore redundant shift sequences (e.g. IBM930 etc., fixed in commit 692de4b3960d). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* iconv: Fix incorrect UCS4 inner loop bounds (BZ#26923)Michael Colavita2021-07-233-13/+56
| | | | | | | | | | | | | | Previously, in UCS4 conversion routines we limit the number of characters we examine to the minimum of the number of characters in the input and the number of characters in the output. This is not the correct behavior when __GCONV_IGNORE_ERRORS is set, as we do not consume an output character when we skip a code unit. Instead, track the input and output pointers and terminate the loop when either reaches its limit. This resolves assertion failures when resetting the input buffer in a step of iconv, which assumes that the input will be fully consumed given sufficient output space.
* math/test-sinl-pseudo: Use stack protector only if availableFlorian Weimer2021-07-221-0/+2
| | | | | This fixes commit 9333498794cde1d5cca518bad ("Avoid ldbl-96 stack corruption from range reduction of pseudo-zero (bug 25487).").
* Avoid ldbl-96 stack corruption from range reduction of pseudo-zero (bug 25487).Joseph Myers2021-07-223-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug 25487 reports stack corruption in ldbl-96 sinl on a pseudo-zero argument (an representation where all the significand bits, including the explicit high bit, are zero, but the exponent is not zero, which is not a valid representation for the long double type). Although this is not a valid long double representation, existing practice in this area (see bug 4586, originally marked invalid but subsequently fixed) is that we still seek to avoid invalid memory accesses as a result, in case of programs that treat arbitrary binary data as long double representations, although the invalid representations of the ldbl-96 format do not need to be consistently handled the same as any particular valid representation. This patch makes the range reduction detect pseudo-zero and unnormal representations that would otherwise go to __kernel_rem_pio2, and returns a NaN for them instead of continuing with the range reduction process. (Pseudo-zero and unnormal representations whose unbiased exponent is less than -1 have already been safely returned from the function before this point without going through the rest of range reduction.) Pseudo-zero representations would previously result in the value passed to __kernel_rem_pio2 being all-zero, which is definitely unsafe; unnormal representations would previously result in a value passed whose high bit is zero, which might well be unsafe since that is not a form of input expected by __kernel_rem_pio2. Tested for x86_64.
* posix: Sync gnulib regex implementationAdhemerval Zanella2021-07-2211-1161/+1591
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch syncs the regex implementation with gnulib (commit 0ee5212). Only two changes in GLIBC regex testing are required: 1. posix/bug-regex28.c: as previously discussed [1] the change of expected results on the pattern should be safe. 2. posix/PCRE.tests: the ERE (a)|\1 is malformed (in the sense that the \1 doesn't mean anything) and although current GLIBC accepts it has undefined behavior. This patch removes the specific test. This sync contains some patches from thread 'Regex: Make libc regex more usable outside GLIBC.' [2] which have been pushed upstream in gnulib. This patches also fixes some regex issues (BZ #23233, BZ #21163, BZ #18986, BZ #13762) and I did not add testcases for both #23233 and #13762 because I couldn't think a simple way to trigger the expected failure path to trigger them. Checked on x86_64-linux-gnu and i686-linux-gnu. [BZ #23233] [BZ #21163] [BZ #18986] [BZ #13762] * posix/Makefile (tests): Add bug-regex37 and bug-regex38. * posix/PCRE.tests: Remove invalid test. * posix/bug-regex28.c: Fix expected values for used syntax. * posix/bug-regex37.c: New file. * posix/bug-regex38.c: Likewise. * posix/regcomp.c: Sync with gnulib. * posix/regex.c: Likewise. * posix/regex.h: Likewise. * posix/regex_internal.c: Likewise. * posix/regex_internal.h: Likewise. * posix/regexec.c: Likewise. [1] https://sourceware.org/ml/libc-alpha/2017-12/msg00807.html [2] https://sourceware.org/ml/libc-alpha/2017-12/msg00237.html
* Fix use-after-free in glob when expanding ~user (bug 25414)Andreas Schwab2021-07-221-12/+13
| | | | | The value of `end_name' points into the value of `dirname', thus don't deallocate the latter before the last use of the former.
* Fix a return type in elf unload testStan Shebs2021-07-221-1/+2
|
* Fix buffer overrun in EUC-KR conversion module (bz #24973)Andreas Schwab2021-07-223-8/+57
| | | | | | | The byte 0xfe as input to the EUC-KR conversion denotes a user-defined area and is not allowed. The from_euc_kr function used to skip two bytes when told to skip over the unknown designation, potentially running over the buffer end.
* gconv: Fix assertion failure in ISO-2022-JP-3 module (bug 27256)Florian Weimer2021-07-223-20/+179
| | | | | | | | | | | | | | | | | | The conversion loop to the internal encoding does not follow the interface contract that __GCONV_FULL_OUTPUT is only returned after the internal wchar_t buffer has been filled completely. This is enforced by the first of the two asserts in iconv/skeleton.c: /* We must run out of output buffer space in this rerun. */ assert (outbuf == outerr); assert (nstatus == __GCONV_FULL_OUTPUT); This commit solves this issue by queuing a second wide character which cannot be written immediately in the state variable, like other converters already do (e.g., BIG5-HKSCS or TSCII). Reported-by: Tavis Ormandy <taviso@gmail.com>
* Read f->func.cxa under the lock.Vitaly Buka2021-07-153-11/+135
|
* Fix bug where ld.so hashtable would retain strings passed to dlopen().Ambrose Feinstein2021-07-151-11/+2
|
* Extend elf/unload8 to test an additional load/unload patternStan Shebs2021-07-153-1/+55
|
* Don't crash if /var/tmp doesn't existShu-Chun Weng2021-07-151-2/+1
| | | | | | `xstat` is checked `stat64` crashing the program if the latter returns failure. In this loop, we are trying to find one folder that satisfies the condition, no reason to crash the program if one folder doesn't.
* More aggressively prevent a buffer from being optimized outShu-Chun Weng2021-07-151-2/+2
| | | | | | | The volatile global variable was first introduced in e86f9654c. I have noticed the compiler still optimizing the buffer out on AArch64 presumably because the assignment is after all other observable behaviors so it's still valid to eliminate it.
* x86_64: Remove unneeded static PIE check for undefined weak diagnosticFangrui Song2021-07-082-58/+0
| | | | | | | | | | | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=21782 dropped an ld diagnostic for R_X86_64_PC32 referencing an undefined weak symbol in -pie links. Arguably keeping the diagnostic like other ports is more correct, since statically resolving movl foo(%rip), %eax to the link-time zero address produces a corrupted output. It turns out that --enable-static-pie builds do not depend on the ld behavior. GCC generates GOT indirection for weak declarations for -fPIE/-fPIC, so what ld does with the PC-relative relocation doesn't really matter. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* [PATCH 7/7] sin/cos slow paths: refactor sincos implementationWilco Dijkstra2021-07-012-45/+52
| | | | | | | | | | | | | Refactor the sincos implementation - rather than rely on odd partial inlining of preprocessed portions from sin and cos, explicitly write out the cases. This makes sincos much easier to maintain and provides an additional 16-20% speedup between 0 and 2^27. The overall speedup of sincos is 48% over this range. Between 0 and PI it is 66% faster. * sysdeps/ieee754/dbl-64/s_sin.c (__sin): Cleanup ifdefs. (__cos): Likewise. * sysdeps/ieee754/dbl-64/s_sin.c (__sincos): Refactor using the same logic as sin and cos.
* [PATCH 6/7] sin/cos slow paths: refactor duplicated code into dosinWilco Dijkstra2021-07-011-27/+13
| | | | | | | | | | | | | | Refactor duplicated code into do_sin. Since all calls to do_sin use copysign to set the sign of the result, move it inside do_sin. Small inputs use a separate polynomial, so move this into do_sin as well (the check is based on the more conservative case when doing large range reduction, but could be relaxed). * sysdeps/ieee754/dbl-64/s_sin.c (do_sin): Use TAYLOR_SIN for small inputs. Return correct sign. (do_sincos): Remove small input check before do_sin, let do_sin set the sign. (__sin): Likewise. (__cos): Likewise.
* [PATCH 5/7] sin/cos slow paths: remove unused slowpath functionsWilco Dijkstra2021-07-011-444/+3
| | | | | | | | | | | | | | | | | | | Remove all unused slowpath functions. * sysdeps/ieee754/dbl-64/s_sin.c (TAYLOR_SLOW): Remove. (do_cos_slow): Likewise. (do_sin_slow): Likewise. (reduce_and_compute): Likewise. (slow): Likewise. (slow1): Likewise. (slow2): Likewise. (sloww): Likewise. (sloww1): Likewise. (sloww2): Likewise. (bslow): Likewise. (bslow1): Likewise. (bslow2): Likewise. (cslow2): Likewise.
* [PATCH 4/7] sin/cos slow paths: remove slow paths from huge range reductionWilco Dijkstra2021-07-012-64/+34
| | | | | | | | | | | | | | For huge inputs use the improved do_sincos function as well. Now no cases use the correction factor returned by do_sin, do_cos and TAYLOR_SIN, so remove it. * sysdeps/ieee754/dbl-64/s_sin.c (TAYLOR_SIN): Remove cor parameter. (do_cos): Remove corp parameter and calculations. (do_sin): Likewise. (do_sincos): Remove cor variable. (__sin): Use do_sincos for huge inputs. (__cos): Likewise. * sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Likewise. (reduce_and_compute_sincos): Remove unused function.
* [PATCH 3/7] sin/cos slow paths: remove slow paths from small range reductionWilco Dijkstra2021-07-012-53/+47
| | | | | | | | | | | | | | | | This patch improves the accuracy of the range reduction. When the input is large (2^27) and very close to a multiple of PI/2, using 110 bits of PI is not enough. Improve range reduction accuracy to 136 bits. As a result the special checks for results close to zero can be removed. The ULP of the polynomials is at worst 0.55ULP, so there is no reason for the slow functions, and they can be removed. * sysdeps/ieee754/dbl-64/s_sin.c (reduce_sincos_1): Rename to reduce_sincos, improve accuracy to 136 bits. (do_sincos_1): Rename to do_sincos, remove fallbacks to slow functions. (__sin): Use improved reduction and simplified do_sincos calculation. (__cos): Likewise. * sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Likewise.
* [PATCH 2/7] sin/cos slow paths: remove large range reductionWilco Dijkstra2021-07-012-103/+2
| | | | | | | | | | | | | | | | | | | | This patch removes the large range reduction code and defers to the huge range reduction code. The first level range reducer supports inputs up to 2^27, which is way too large given that inputs for sin/cos are typically small (< 10), and optimizing for a smaller range would give a significant speedup. Input values above 2^27 are practically never used, so there is no reason for supporting range reduction between 2^27 and 2^48. Removing it significantly simplifies code and enables further speedups. There is about a 2.3x slowdown in this range due to __branred being extremely slow (a better algorithm could easily more than double performance). * sysdeps/ieee754/dbl-64/s_sin.c (reduce_sincos_2): Remove function. (do_sincos_2): Likewise. (__sin): Remove middle range reduction case. (__cos): Likewise. * sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Remove middle range reduction case.
* [PATCH 1/7] sin/cos slow paths: avoid slow paths for small inputsWilco Dijkstra2021-07-013-26/+26
| | | | | | | | | | | | | | | | | | | | | | | | This series of patches removes the slow patchs from sin, cos and sincos. Besides greatly simplifying the implementation, the new version is also much faster for inputs up to PI (41% faster) and for large inputs needing range reduction (27% faster). ULP is ~0.55 with no errors found after testing 1.6 billion inputs across most of the range with mpsin and mpcos. The number of incorrectly rounded results (ie. ULP >0.5) is at most ~2750 per million inputs between 0.125 and 0.5, the average is ~850 per million between 0 and PI. Tested on AArch64 and x86_64 with no regressions. The first patch removes the slow paths for the cases where the input is small and doesn't require range reduction. Update ULP tables for sin, cos and sincos on AArch64 and x86_64. * sysdeps/aarch64/libm-test-ulps: Update ULP for sin, cos, sincos. * sysdeps/ieee754/dbl-64/s_sin.c (__sin): Remove slow paths for small inputs. (__cos): Likewise. * sysdeps/x86_64/fpu/libm-test-ulps: Update ULP for sin, cos, sincos.
* locale: Align _nl_C_LC_CTYPE_class and _nl_C_LC_CTYPE_class32Lirong Yuan2021-05-031-2/+3
| | | | | Otherwise, programs that use character classification macros such as isspace may observe unaligned pointers.
* Work around clang arm not handling tlsgd relocsOwen Anderson2020-11-137-7/+20
|
* Change this offsetof computation to use c89 offsetof. Tested:Nick Lewycky2020-11-051-1/+1
|
* Update build process to create libnsl stubStan Shebs2020-11-033-3/+4
|
* Forward-port google-nsl-stubPaul Pluzhnikov2020-11-034-0/+81
|
* Fix memory leak in TLS allocationJames Y Knight2020-10-211-0/+1
|
* Add a test of TLS support that will fail if leakyStan Shebs2020-10-213-2/+151
|
* Fix section type of .eh_frame on Linux x86_64Fangrui Song2020-10-201-1/+1
|
* Compile dl-reloc-static-pie.c with -Wa,-mrelax-relocations=yesFangrui Song2020-10-201-0/+3
|
* Let time and gettimeofday use vdso by removing old clang workaroundStan Shebs2020-10-062-8/+2
|
* Use crt*.o files from llvm compiler-rt when building with clangStan Shebs2020-06-091-0/+20
|
* Do not use ppc-specific long double pack/unpack when compiling with clangStan Shebs2020-06-091-0/+5
|
* Remove old workaround in power7 logb functions, clang no longer crashes on ↵Stan Shebs2020-02-063-24/+0
| | | | the inline assembly
* Additional fixes for llvm-asJosh Kunz2020-01-242-2/+2
| | | | | | | | | | | | | Unlike GCC, llvm always uses an integrated assembler, which attempts to recognized all `asm` statements written in the C code. glibc uses some syntactically invalid asm statements to emit constants into assembly that are later extracted with a sed or AWK script. This change fixes two such invalid `asm` statements by wrapping the output in a `.ascii` directive.. This does not break the sed/AWK (the same special sequence is output) but it makes the statement syntactically valid. See cf8e3f8757 for a previous fix for the same issue.
* Add workaround for infinite looping in ppc vsyscall for sched_getcpu.Stan Shebs2020-01-241-0/+17
|
* Add -Wno-incomplete-setjmp-declaration to prevent clang from unhelpfully ↵Stan Shebs2020-01-241-0/+1
| | | | complaining about __sigsetjmp, both in library build and testsuite runs.
* Remove excess quote chars from DOT_MACHINE macrosStan Shebs2020-01-243-3/+3
|
* Update passwd.borg handling to use passwd.borg.realStan Shebs2019-12-201-64/+151
|
* Add a case to async-signal-safe TLS to set static TLS instead of waiting for ↵Stan Shebs2019-11-081-2/+25
| | | | a dlopen that may not actually be happening.
* Add an LD_DEBUG=tls option to help debug thread-local storage handling in ld.soStan Shebs2019-11-084-8/+189
|