about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* AArch64: Remove SVE erf and erfc tablesJoe Ramsay4 days16-2691/+50
| | | | | | | | | | By using a combination of mask-and-add instead of the shift-based index calculation the routines can share the same table as other variants with no performance degradation. The tables change name because of other changes in downstream AOR. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* x86_64: Add exp2m1f with FMAAdhemerval Zanella4 days4-0/+41
| | | | | | | | | The CORE-MATH exp2m1f implementation showed slight worse latency when using x86_64 baseline ABI. This patch adds a ifunc variant with similar performance for x86_64-v3. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com> Reviewed-by: DJ Delorie <dj@redhat.com>
* x86_64: Add exp10m1f with FMAAdhemerval Zanella4 days4-0/+41
| | | | | | | | | The CORE-MATH exp10m1f implementation showed slight worse latency when using x86_64 baseline ABI. This patch adds a ifunc variant with similar performance for x86_64-v3. Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com> Reviewed-by: DJ Delorie <dj@redhat.com>
* math: Use log10p1f from CORE-MATHAdhemerval Zanella4 days19-62/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows slight better performance to the generic log10p1f. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (M1, gcc 13.2.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 68.5251 32.2627 52.92% x86_64v2 68.8912 32.7887 52.41% x86_64v3 59.3427 27.0521 54.41% i686 162.026 103.383 36.19% aarch64 26.8513 14.5695 45.74% power10 12.7426 8.4929 33.35% powerpc 16.6768 9.29135 44.29% reciprocal-throughput master patched improvement x86_64 26.0969 12.4023 52.48% x86_64v2 25.0045 11.0748 55.71% x86_64v3 20.5610 10.2995 49.91% i686 89.8842 78.5211 12.64% aarch64 17.1200 9.4832 44.61% power10 6.7814 6.4258 5.24% powerpc 15.769 7.6825 51.28% Signed-off-by: Alexei Sibidanov <sibid@uvic.ca> Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
* math: Use log1pf from CORE-MATHAdhemerval Zanella4 days30-340/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows slight better performance to the generic log1pf. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (M1, gcc 13.2.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 71.8142 38.9668 45.74% x86_64v2 71.9094 39.1321 45.58% x86_64v3 60.1000 32.4016 46.09% i686 147.105 104.258 29.13% aarch64 26.4439 14.0050 47.04% power10 19.4874 9.4146 51.69% powerpc 17.6145 8.00736 54.54% reciprocal-throughput master patched improvement x86_64 19.7604 12.7254 35.60% x86_64v2 19.0039 11.9455 37.14% x86_64v3 16.8559 11.9317 29.21% i686 82.3426 73.9718 10.17% aarch64 14.4665 7.9614 44.97% power10 11.9974 8.4117 29.89% powerpc 7.15222 6.0914 14.83% Signed-off-by: Alexei Sibidanov <sibid@uvic.ca> Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
* math: Use log2p1f from CORE-MATHAdhemerval Zanella4 days20-67/+252
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows better performance compared to the generic log2p1f. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1, gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 70.1462 47.0090 32.98% x86_64v2 70.2513 47.6160 32.22% x86_64v3 60.4840 39.9443 33.96% i686 164.068 122.909 25.09% aarch64 25.9169 16.9207 34.71% power10 18.1261 9.8592 45.61% powerpc 17.2683 9.38665 45.64% reciprocal-throughput master patched improvement x86_64 26.2240 16.4082 37.43% x86_64v2 25.0911 15.7480 37.24% x86_64v3 20.9371 11.7264 43.99% i686 90.4209 95.3073 -5.40% aarch64 16.8537 8.9561 46.86% power10 12.9401 6.5555 49.34% powerpc 9.01763 7.54745 16.30% The performance decrease for i686 is mostly due the use of x87 fpu, when building with '-msse2 -mfpmath=sse: master patched improvement latency 164.068 102.982 37.23% reciprocal-throughput 89.1968 82.5117 7.49% Signed-off-by: Alexei Sibidanov <sibid@uvic.ca> Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
* math: Use log10f from CORE-MATHAdhemerval Zanella4 days3-110/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows better performance compared to the generic log10f. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1, gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 49.9017 33.5143 32.84% x86_64v2 50.4878 33.5623 33.52% x86_64v3 50.0991 27.6078 44.89% i686 140.874 106.086 24.69% aarch64 19.2846 11.3573 41.11% power10 14.0994 7.7739 44.86% powerpc 14.2898 7.92497 44.54% reciprocal-throughput master patched improvement x86_64 17.8336 12.9074 27.62% x86_64v2 16.4418 11.3220 31.14% x86_64v3 15.6002 10.5158 32.59% i686 66.0678 80.2287 -21.43% aarch64 9.4906 6.8393 27.94% power10 7.5255 5.5084 26.80% powerpc 9.5204 6.98055 26.68% The performance decrease for i686 is mostly due the use of x87 fpu, when building with '-msse2 -mfpmath=sse': master patched improvement latency 140.874 77.1137 45.26% reciprocal-throughput 64.481 56.4397 12.47% Signed-off-by: Alexei Sibidanov <sibid@uvic.ca> Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
* math: Use expm1f from CORE-MATHAdhemerval Zanella4 days29-320/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows better performance compared to the generic expm1f. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1, gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 96.7402 36.4026 62.37% x86_64v2 97.5391 33.4625 65.69% x86_64v3 82.1778 30.8668 62.44% i686 120.58 94.8302 21.35% aarch64 32.3558 12.8881 60.17% power10 23.5087 9.8574 58.07% powerpc 23.4776 9.06325 61.40% reciprocal-throughput master patched improvement x86_64 27.8224 15.9255 42.76% x86_64v2 27.8364 9.6438 65.36% x86_64v3 20.3227 9.6146 52.69% i686 63.5629 59.4718 6.44% aarch64 17.4838 7.1082 59.34% power10 12.4644 8.7829 29.54% powerpc 14.2152 5.94765 58.16% Signed-off-by: Alexei Sibidanov <sibid@uvic.ca> Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
* math: Use exp2m1f from CORE-MATHAdhemerval Zanella4 days20-66/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows better performance compared to the generic exp2m1f. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). The only change is to handle FLT_MAX_EXP for FE_DOWNWARD or FE_TOWARDZERO. The benchmark inputs are based on exp2f ones. Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1, gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 40.6042 48.7104 -19.96% x86_64v2 40.7506 35.9032 11.90% x86_64v3 35.2301 31.7956 9.75% i686 102.094 94.6657 7.28% aarch64 18.2704 15.1387 17.14% power10 11.9444 8.2402 31.01% reciprocal-throughput master patched improvement x86_64 20.8683 16.1428 22.64% x86_64v2 19.5076 10.4474 46.44% x86_64v3 19.2106 10.4014 45.86% i686 56.4054 59.3004 -5.13% aarch64 12.0781 7.3953 38.77% power10 6.5306 5.9388 9.06% The generic implementation calls __ieee754_exp2f and x86_64 provides an optimized ifunc version (built with -mfma -mavx2, not correctly rounded). This explains the performance difference for x86_64. Same for i686, where the ABI provides an optimized __ieee754_exp2f version built with '-msse2 -mfpmath=sse'. When built wth same flags, the new algorithm shows a better performance: master patched improvement latency 102.094 91.2823 10.59% reciprocal-throughput 56.4054 52.7984 6.39% Signed-off-by: Alexei Sibidanov <sibid@uvic.ca> Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
* math: Use exp10m1f from CORE-MATHAdhemerval Zanella4 days20-66/+229
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows better performance compared to the generic exp10m1f. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). I mostly fixed some small issues in corner cases (sNaN handling, -INFINITY, a specific overflow check). Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1, gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 45.4690 49.5845 -9.05% x86_64v2 46.1604 36.2665 21.43% x86_64v3 37.8442 31.0359 17.99% i686 121.367 93.0079 23.37% aarch64 21.1126 15.0165 28.87% power10 12.7426 8.4929 33.35% reciprocal-throughput master patched improvement x86_64 19.6005 17.4005 11.22% x86_64v2 19.6008 11.1977 42.87% x86_64v3 17.5427 10.2898 41.34% i686 59.4215 60.9675 -2.60% aarch64 13.9814 7.9173 43.37% power10 6.7814 6.4258 5.24% The generic implementation calls __ieee754_exp10f which has an optimized version, although it is not correctly rounded, which is the main culprit of the the latency difference for x86_64 and throughp for i686. Signed-off-by: Alexei Sibidanov <sibid@uvic.ca> Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
* benchtests: Add log10p1f benchmarkAdhemerval Zanella4 days2-0/+2889
| | | | | | It is based on log2f data. Reviewed-by: DJ Delorie <dj@redhat.com>
* benchtests: Add log1p benchmarkAdhemerval Zanella4 days2-0/+1006
| | | | | | Random inputs x*2^e where x is random in [1/2,1] and e in [-29,127]. Reviewed-by: DJ Delorie <dj@redhat.com>
* benchtests: Add log2p1f benchmarkAdhemerval Zanella4 days2-0/+2889
| | | | | | It is based on log2f data. Reviewed-by: DJ Delorie <dj@redhat.com>
* benchtests: Add log10f benchmarkAdhemerval Zanella4 days2-0/+1006
| | | | | | | The inputs are random numbers in the form x*2^e where x is random in [0x1p-1,0x1p+0] and e in [-126,127]. Reviewed-by: DJ Delorie <dj@redhat.com>
* benchtests: Add expm1f benchmarkAdhemerval Zanella4 days2-0/+800
| | | | | | | The inputs are modeled based on expm1-inputs, with the range adapted to binary32 range. Reviewed-by: DJ Delorie <dj@redhat.com>
* benchtests: Add exp2m1f benchmarkAdhemerval Zanella4 days2-0/+2389
| | | | | | The input is based on exp2f benchmark. Reviewed-by: DJ Delorie <dj@redhat.com>
* benchtests: Add exp10m1f benchmarkAdhemerval Zanella4 days2-0/+2390
| | | | | | The input is based on exp10f benchmark. Reviewed-by: DJ Delorie <dj@redhat.com>
* math: Add e_gammaf_r to glibc code and styleAdhemerval Zanella4 days2-78/+103
| | | | | | | | | | | | Also remove the use of builtins in favor of standard names, compiler already inline them (if supported) with current compiler options. It also fixes and issue where __builtin_roundeven is not support on gcc older than version 10. Checked on x86_64-linux-gnu and i686-linux_gnu. Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: DJ Delorie <dj@redhat.com>
* LoongArch: Add RSEQ_SIG in rseq.h.caiyinyu4 days1-0/+36
| | | | Signed-off-by: caiyinyu <caiyinyu@loongson.cn>
* nptl: Add <thread_pointer.h> for LoongArchMichael Jeanson4 days1-0/+36
| | | | | | | | | | | | | | | This will be required by the rseq extensible ABI implementation on all Linux architectures exposing the '__rseq_size' and '__rseq_offset' symbols to set the initial value of the 'cpu_id' field which can be used by applications to test if rseq is available and registered. As long as the symbols are exposed it is valid for an application to perform this test even if rseq is not yet implemented in libc for this architecture. Both code paths are compile tested with build-many-glibcs.py but I don't have access to any hardware to run the tests. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Reviewed-by: Arjun Shankar <arjun@redhat.com>
* Link tst-clock_gettime with $(librt)Joseph Myers5 days1-0/+2
| | | | | | | This is needed to avoid link failures for the timer_* functions on Hurd. Tested with build-many-glibcs.py for i686-gnu.
* powerpc64: Obviate the need for ROP protection in clone/clone3Sachin Monga5 days2-21/+21
| | | | | | | | | Save lr in a non-volatile register before scv in clone/clone3. For clone, the non-volatile register was unused and already saved/restored. Remove the dead code from clone. Signed-off-by: Sachin Monga <smonga@linux.ibm.com> Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
* Add tests of time, gettimeofday, clock_gettimeJoseph Myers6 days7-0/+337
| | | | | | | | | There are no tests specifically focused on the functions time, gettimeofday and clock_gettime, although there are some incidental uses in tests of other functions. Add tests specifically for these three functions. Tested for x86_64 and x86.
* Add more tests of pthread attributes initial valuesJoseph Myers7 days2-0/+63
| | | | | | | | | | | | | | | | | | | | There are various existing tests that call pthread_attr_init and then verify properties of the resulting initial values retrieved with pthread_attr_get* functions. However, those are missing coverage of the initial values retrieved with pthread_attr_getschedparam and pthread_attr_getstacksize. Add testing for initial values from those functions as well. (tst-attr2 covers pthread_attr_getdetachstate, pthread_attr_getguardsize, pthread_attr_getinheritsched, pthread_attr_getschedpolicy, pthread_attr_getscope. tst-attr3 covers some of those together with pthread_attr_getaffinity_np. tst-pthread-attr-sigmask covers pthread_attr_getsigmask_np. pthread_attr_getstack has unspecified results if called before the relevant attributes have been set, while pthread_attr_getstackaddr is deprecated.) Tested for x86_64.
* Document further requirement on mixing streams / file descriptorsJoseph Myers7 days1-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gilbc manual has some documentation in llio.texi of requirements for moving between I/O on FILE * streams and file descriptors on the same open file description. The documentation of what must be done on a FILE * stream to move from it to either a file descriptor or another FILE * for the same open file description seems to match POSIX. However, there is an additional requirement in POSIX on the *second* of the two handles being moved between, which is not mentioned in the glibc manual: "If any previous active handle has been used by a function that explicitly changed the file offset, except as required above for the first handle, the application shall perform an lseek() or fseek() (as appropriate to the type of handle) to an appropriate location.". Document this requirement on seeking in the glibc manual, limited to the case that seems relevant to glibc (the new channel is a previously active stream, on which the seeking previously occurred). Note that I'm not sure what the "except as required above for the first handle" is meant to be about, so I haven't documented anything for it. As far as I can tell, nothing specified for moving from the first handle actually list calling a seek function as one of the steps to be done. (Current POSIX doesn't seem to have any relevant rationale for this section. The rationale in the 1996 edition says "In requiring the seek to an appropriate location for the new handle, the application is required to know what it is doing if it is passing streams with seeks involved. If the required seek is not done, the results are undefined (and in fact the program probably will not work on many common implementations)." - which also doesn't help in understanding the purpose of "except as required above for the first handle".) Tested with "make info" and "make pdf".
* powerpc64le: Adhere to ABI stack alignment requirementSachin Monga7 days1-1/+1
| | | | | | The ABI requires all stack frames be 16-byte aligned. Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
* AArch64: Small optimisation in AdvSIMD erf and erfcJoe Ramsay8 days2-15/+23
| | | | | | | | In both routines, reduce register pressure such that GCC 14 emits no spills for erf and fewer spills for erfc. Also use more efficient comparison for the special-case in erf. Benchtests show erf improves by 6.4%, erfc by 1.0%.
* Revert "elf: Run constructors on cyclic recursive dlopen (bug 31986)"Florian Weimer8 days7-167/+7
| | | | | | | This reverts commit 9897ced8e78db5d813166a7ccccfd5a42c69ef20. Adjust the test expectations in elf/tst-dlopen-auditdup-auditmod.c accordingly.
* elf: Change ldconfig auxcache magic number (bug 32231)Florian Weimer8 days1-1/+1
| | | | | | | | | | | | | In commit c628c2296392ed3bf2cb8d8470668e64fe53389f (elf: Remove ldconfig kernel version check), the layout of auxcache entries changed because the osversion field was removed from struct aux_cache_file_entry. However, AUX_CACHEMAGIC was not changed, so existing files are still used, potentially leading to unintended ldconfig behavior. This commit changes AUX_CACHEMAGIC, so that the file is regenerated. Reported-by: DJ Delorie <dj@redhat.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* SHARED-FILES: Mention bundled Linux 6.10 headers.Carlos O'Donell10 days1-0/+9
| | | | Reviewed-by: Florian Weimer <fweimer@redhat.com>
* libio: Fix crash in fputws [BZ #20632]Peter Ammon11 days4-4/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a buffer overflow in wide character string output, reproducing when output fails, such as if the output fd is closed or is redirected to a full device. Wide character output data attempts to maintain the invariant that `_IO_buf_base <= _IO_write_base <= _IO_write_end <= _IO_buf_end` (that is, that the write region is a sub-region of `_IO_buf`). Prior to this commit, this invariant is violated by the `_IO_wfile_overflow` function as so: 1. `_IO_wsetg` is called, assigning `_IO_write_base` to `_IO_buf_base` 2. `_IO_doallocbuf` is called, which jumps to `_IO_wfile_doallocate` via the _IO_wfile_jumps vtable. This function then assigns the wide data `_IO_buf_base` and `_IO_buf_end` to a malloc'd buffer. Thus the invariant is violated. The fix is simply to reverse the order: malloc the `_IO_buf` first and then assign `_IO_write_base` to it. We also take this opportunity to defensively guard the initialization of the number of unwritten characters via pointer arithmetic. We now check that the buffer end is not before the buffer beginning; this matches a similar defensive check in the narrow analogue `fileops.c`. Add a test which fails without the fix. Signed-off-by: Peter Ammon <corydoras@ridiculousfish.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* stdio-common: Fix scanf parsing for NaN types [BZ #30647]Avinal Kumar11 days3-1/+129
| | | | | | | | | | | | | | | | | The scanf family of functions like sscanf and fscanf currently ignore nan() and nan(n-char-sequence). This happens because __vfscanf_internal only checks for 'nan'. This commit adds support for all valid nan types i.e. nan, nan() and nan(n-char-sequence), where n-char-sequence can be [a-zA-Z0-9_]+, thus fixing the bug 30647. Any other representation of NaN should result in conversion error. New tests are also added to verify the correct parsing of NaN types for float, double and long double formats. Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Fix map_complete Systemtap probe in dl_open_workerFlorian Weimer11 days1-1/+1
| | | | | | | The refactoring did not take the change of variable into account. Fixes commit 43db5e2c0672cae7edea7c9685b22317eae25471 ("elf: Signal RT_CONSISTENT after relocation processing in dlopen (bug 31986)").
* elf: Signal RT_CONSISTENT after relocation processing in dlopen (bug 31986)Florian Weimer11 days5-15/+219
| | | | | | | | | | | | | | | | | | | Previously, a la_activity audit event was generated before relocation processing completed. This does did not match what happened during initial startup in elf/rtld.c (towards the end of dl_main). It also caused various problems if an auditor tried to open the same shared object again using dlmopen: If it was the directly loaded object, it had a search scope associated with it, so the early exit in dl_open_worker_begin was taken even though the object was unrelocated. This caused the r_state == RT_CONSISTENT assert to fail. Avoidance of the assert also depends on reversing the order of r_state update and auditor event (already implemented in a previous commit). At the later point, args->map can be NULL due to failure, so use the assigned namespace ID instead if that is available. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Signal LA_ACT_CONSISTENT to auditors after RT_CONSISTENT switchFlorian Weimer11 days3-13/+13
| | | | | | | | | | | | | Auditors can call into the dynamic loader again if LA_ACT_CONSISTENT, and those recursive calls could observe r_state != RT_CONSISTENT. We should consider failing dlopen/dlmopen/dlclose if r_state != RT_CONSISTENT. The dynamic linker is probably not in a state in which it can handle reentrant calls. This needs further investigation. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Run constructors on cyclic recursive dlopen (bug 31986)Florian Weimer11 days6-0/+165
| | | | | | | | | | This is conceptually similar to the reported bug, but does not depend on auditing. The fix is simple: just complete execution of the constructors. This exposed the fact that the link map for statically linked executables does not have l_init_called set, even though constructors have run. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Linux: Match kernel text for SCHED_ macrosFlorian Weimer11 days1-3/+5
| | | | | | | | | | This avoids -Werror build issues in strace, which bundles UAPI headers, but does not include them as system headers. Fixes commit c444cc1d8335243c5c4e636d6a26c472df85522c ("Linux: Add missing scheduler constants to <sched.h>"). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* libio: Correctly link tst-popen-fork against libpthreadArjun Shankar11 days1-0/+2
| | | | | | | | | tst-popen-fork failed to build for Hurd due to not being linked with libpthread. This commit fixes that. Tested with build-many-glibcs.py for i686-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Add more tests of pthread_mutexattr_gettype and pthread_mutexattr_settypeJoseph Myers13 days2-0/+61
| | | | | | | | Add basic tests of pthread_mutexattr_gettype and pthread_mutexattr_settype with each valid mutex kind, plus test for EINVAL with an invalid mutex kind. Tested for x86_64.
* libio: Fix a deadlock after fork in popenArjun Shankar13 days5-0/+110
| | | | | | | | | | | | | | | popen modifies its file handler book-keeping under a lock that wasn't being taken during fork. This meant that a concurrent popen and fork could end up copying the lock in a "locked" state into the fork child, where subsequently calling popen would lead to a deadlock due to the already (spuriously) held lock. This commit fixes the deadlock by appropriately taking the lock before fork, and releasing/resetting it in the parent/child after the fork. A new test for concurrent popen and fork is also added. It consistently hangs (and therefore fails via timeout) without the fix applied. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* configure: default to --prefix=/usr on GNU/LinuxDJ Delorie13 days2-2/+7
| | | | | | | I'm getting tired of always typing --prefix=/usr so making it the default. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* manual: Document stdio.h functions that may be macrosDJ Delorie2024-10-211-0/+12
| | | | | | | | | | Glibc has two gnu-extension functions that are implemented as macros but not documented as such: fread_unlocked and fwrite_unlocked. Document them as such. Additionally, putc_unlocked and getc_unlocked are documented in POSIX as possibly being macros. Update the manual to add a warning about those also, depite glibc not implementing them as macros.
* Check time arguments to pthread_timedjoin_np and pthread_clockjoin_npJoseph Myers2024-10-214-0/+96
| | | | | | | | | | | | | | | | | | | The pthread_timedjoin_np and pthread_clockjoin_np functions do not check that a valid time has been specified. The documentation for these functions in the glibc manual isn't sufficiently detailed to say if they should, but consistency with POSIX functions such as pthread_mutex_timedlock and pthread_cond_timedwait strongly indicates that an EINVAL error is appropriate (even if there might be some ambiguity about exactly where such a check should go in relation to other checks for whether the thread exists, whether it's immediately joinable, etc.). Copy the logic for such a check used in pthread_rwlock_common.c. pthread_join_common had some logic calling valid_nanoseconds before commit 9e92278ffad441daf588ff1ff5bd8094aa33fbfd, "nptl: Remove clockwait_tid"; I haven't checked exactly what cases that detected. Tested for x86_64 and x86.
* Add .b4-config fileJonathan Wakely2024-10-211-0/+4
| | | | | | | | This makes b4 use inbox.sourceware.org instead of the default host lore.kernel.org, so that every b4 user doesn't have to configure this themselves for the glibc repo. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* linux: Fix tst-syscall-restart.c on old gcc (BZ 32283)Adhemerval Zanella2024-10-181-1/+1
| | | | To avoid a parameter name omitted error.
* sparc: Fix restartable syscalls (BZ 32173)Adhemerval Zanella2024-10-167-36/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit 'sparc: Use Linux kABI for syscall return' (86c5d2cf0ce046279baddc7faa27da71f1a89fde) did not take into account a subtle sparc syscall kABI constraint. For syscalls that might block indefinitely, on an interrupt (like SIGCONT) the kernel will set the instruction pointer to just before the syscall: arch/sparc/kernel/signal_64.c 476 static void do_signal(struct pt_regs *regs, unsigned long orig_i0) 477 { [...] 525 if (restart_syscall) { 526 switch (regs->u_regs[UREG_I0]) { 527 case ERESTARTNOHAND: 528 case ERESTARTSYS: 529 case ERESTARTNOINTR: 530 /* replay the system call when we are done */ 531 regs->u_regs[UREG_I0] = orig_i0; 532 regs->tpc -= 4; 533 regs->tnpc -= 4; 534 pt_regs_clear_syscall(regs); 535 fallthrough; 536 case ERESTART_RESTARTBLOCK: 537 regs->u_regs[UREG_G1] = __NR_restart_syscall; 538 regs->tpc -= 4; 539 regs->tnpc -= 4; 540 pt_regs_clear_syscall(regs); 541 } However, on a SIGCONT it seems that 'g1' register is being clobbered after the syscall returns. Before 86c5d2cf0ce046279, the 'g1' was always placed jus before the 'ta' instruction which then reloads the syscall number and restarts the syscall. On master, where 'g1' might be placed before 'ta': $ cat test.c #include <unistd.h> int main () { pause (); } $ gcc test.c -o test $ strace -f ./t [...] ppoll(NULL, 0, NULL, NULL, 0 On another terminal $ kill -STOP 2262828 $ strace -f ./t [...] --- SIGSTOP {si_signo=SIGSTOP, si_code=SI_USER, si_pid=2521813, si_uid=8289} --- --- stopped by SIGSTOP --- And then $ kill -CONT 2262828 Results in: --- SIGCONT {si_signo=SIGCONT, si_code=SI_USER, si_pid=2521813, si_uid=8289} --- restart_syscall(<... resuming interrupted ppoll ...>) = -1 EINTR (Interrupted system call) Where the expected behaviour would be: $ strace -f ./t [...] ppoll(NULL, 0, NULL, NULL, 0) = ? ERESTARTNOHAND (To be restarted if no handler) --- SIGSTOP {si_signo=SIGSTOP, si_code=SI_USER, si_pid=2521813, si_uid=8289} --- --- stopped by SIGSTOP --- --- SIGCONT {si_signo=SIGCONT, si_code=SI_USER, si_pid=2521813, si_uid=8289} --- ppoll(NULL, 0, NULL, NULL, 0 Just moving the 'g1' setting near the syscall asm is not suffice, the compiler might optimize it away (as I saw on cancellation.c by trying this fix). Instead, I have change the inline asm to put the 'g1' setup in ithe asm block. This would require to change the asm constraint for INTERNAL_SYSCALL_NCS, since the syscall number is not constant. Checked on sparc64-linux-gnu. Reported-by: René Rebe <rene@exactcode.de> Tested-by: Sam James <sam@gentoo.org> Reviewed-by: Sam James <sam@gentoo.org>
* support: Make support_process_state_wait return the found stateAdhemerval Zanella2024-10-163-8/+24
| | | | | | | | | So caller can check which state was found if multiple ones are asked. Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Enable transliteration rules with two input characters in scn_IT [BZ #32280]Mike FABIAN2024-10-161-9/+5
| | | | Should work now because https://sourceware.org/bugzilla/show_bug.cgi?id=31859 has been fixed.
* locale: Fix some spelling typosJonathan Wakely2024-10-148-8/+8
| | | | | | Replace several cases of "Ingore" with "Ignore". Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* LoongArch: Regenerate loongarch/arch-syscall.h by build-many-glibcs.py ↵caiyinyu2024-10-121-2/+0
| | | | update-syscalls.