aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux
AgeCommit message (Collapse)AuthorFilesLines
26 hoursAArch64: Avoid memset ifunc in cpu-features.c [BZ #33112]Wilco Dijkstra1-0/+1
During early startup memcpy or memset must not be called since many targets use ifuncs for them which won't be initialized yet. Security hardening may use -ftrivial-auto-var-init=zero which inserts calls to memset. Redirect memset to memset_generic by including dl-symbol-redir-ifunc.h in cpu-features.c. This fixes BZ #33112. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 daysLinux: Convert '__close_nocancel_nostatus' to a standalone handlerMaciej W. Rozycki4-8/+34
Make '__close_nocancel_nostatus' standalone. This is a generic version analogous to '__close_nocancel'. Platforms may choose to implement an inline variant instead where the syscall invocation code sequence is short enough to be beneficial over a function call. Reviewed-by: Florian Weimer <fweimer@redhat.com>
7 daysLinux: Fix '__close_nocancel_nostatus' clobbering 'errno' [BZ #33035]Maciej W. Rozycki1-1/+1
Fix fallout from commit c181840c93d3 ("Consolidate non cancellable close call") that caused '__close_nocancel_nostatus' to clobber 'errno' on a close(2) failure, a 2.27 regression. The problem came from a rewrite from 'close_not_cancel_no_status' to '__close_nocancel_nostatus' switching from an inline implementation that used INTERNAL_SYSCALL macro (which stays away from 'errno') to a call to '__close_nocancel' function that uses INLINE_SYSCALL_CALL macro (which does poke at 'errno'). Implement '__close_nocancel_nostatus' in terms of INTERNAL_SYSCALL_CALL then, which leaves 'errno' intact. Reviewed-by: Florian Weimer <fweimer@redhat.com>
8 daysriscv: linux: Add support for getrandom vDSOXi Ruoyao1-1/+2
Linux kernel >= 6.16 has getrandom() in vDSO for RISC-V. Enable the use of it in Glibc so it would benefit the programs using the Glibc high quality random number functions. Link: https://git.kernel.org/torvalds/c/ee0d03053e70 Signed-off-by: Xi Ruoyao <xry111@xry111.site> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 daysx86: Update tst-gnu2-tls2 testsH.J. Lu1-4/+4
Update tst-gnu2-tls2 tests to set XMM0...XMM7 to all 1s in malloc to verify that XMM registers are preserved when _dl_tlsdesc_dynamic is called by clearing vectors with zeroed XMM registers before _dl_tlsdesc_dynamic and using these XMM registers to clear vectors after _dl_tlsdesc_dynamic. This improves the BZ #31372 test. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
13 daysFix termios related targetsAndreas Schwab1-9/+18
Move Linux-specific termios headers and tests from misc to termios subdir and install newly added bits/termios-cbaud.h.
13 daysaarch64: simplify calls to __libc_arm_za_disable in assemblyYury Khrustalev1-14/+9
There is no functional change in this patch. We remove stores and loads to stack, return address signing, and redundant CFI directives before and after call to __libc_arm_za_disable(). The __libc_arm_za_disable implementation follows special calling convention that allows to avoid most of the operations that would be necessary for a call to a normal function (see [1] for details). First, we rely on __libc_arm_za_disable() not clobbering certain registers, and we put return address into one of these registers. Now we don't need to store it on stack, so we don't need to sign return address using PAC. Second, as a result of the above, we don't need to update the CFI offset. This patch provides small optimisation avoiding unnecessary store and load on stack also simplifies assembly code and CFI directives. [1]: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
13 daysaarch64: GCS: use internal struct in __alloc_gcsYury Khrustalev1-3/+1
No functional change here, just a small refactoring to simplify using __alloc_gcs() for allocating shadow stacks. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-06-17linux/termios: regression test for termios speed functionsH. Peter Anvin (Intel)2-0/+593
Test that runs through a fairly large combination of the various termios speed functions, for the new speed_t interface, for the old speed_t interface (if enabled), and for the new baud_t interface. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-06-17termios: unify the naming of the termios speed fieldsH. Peter Anvin (Intel)2-4/+18
The generic code has __ispeed and __ospeed; Linux has c_ispeed and c_ospeed. Use an anonymous union member to allow both set of names on all platforms. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
2025-06-17termios: add new baud_t interface, defined to be explicitly numericH. Peter Anvin (Intel)34-0/+165
Add an explicitly numeric interface for baudrate setting. For glibc, this only announces what is a fair accompli, but this is a plausible way forward for standardization, and may be possible to infill on non-compliant systems. The POSIX committee has stated: [https://www.austingroupbugs.net/view.php?id=1916#c7135] A future version of this standard is expected to add at least the following symbolic constants for use as values of objects of type speed_t: B57600, B115200, B230400, B460800, and B921600. Implementations are encouraged to propose additional interfaces which will make it possible to set and query a wider range of speeds than just those enumerated by the constants beginning with B. If a set of common interfaces emerges between several implementations, a future version of this standard will likely add those interfaces. This is exactly that interface. The use of the term "baud" is due to the need to have a term contrasting "speed", and it is already well established as a legacy term -- including in the names of the legacy Bxxx constants. Futhermore, it *is* valid from the point of view that the termios interface fundamentally emulates an RS-232 serial port as far as the application software is concerned. The documentation states that for the current version of glibc, speed_t == baud_t, but explicitly declares that this may not be the case in the future. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-06-17termios: merge the termios baud definitionsH. Peter Anvin (Intel)3-67/+3
Now all platforms unconditionally use the "sane" definitions of the termios baud constants. Unify them into a common file. Note: I have made them explicitly unsigned to avoid problems with compiler warnings for comparisons of unequal signedness or similar. These constants were historically octal on most platforms, and so unsigned by default. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-06-17linux: implement arbitrary and split speeds in termiosH. Peter Anvin (Intel)61-456/+1129
Linux has supported arbitrary speeds and split speeds in the kernel since 2008 on all platforms except Alpha (fixed in 2020), but glibc was never updated to match. This is further complicated by POSIX uses of macros for the cf[gs]et[io]speed interfaces, rather than plain numbers, as it really ought to have. On most platforms, the glibc ABI includes the c_[io]speed fields in struct termios, but they are incorrectly used. On MIPS and SPARC, they are entirely missing. For backwards compatibility, the kernel will still use the legacy speed fields unless they are set to BOTHER, and will use the legacy output speed as the input speed if the latter is 0 (== B0). However, the specific encoding used is visible to user space applications, including ones other than the one running. - SPARC and MIPS get a new struct termios, and tc[gs]etattr() is versioned accordingly. However, the new struct termios is set to be a strict extension of the old one, which means that cf* interfaces other than the speed-related ones do not need versioning. - The Bxxx constants are redefined as equivalent to their integer values and the legacy Bxxx constants are renamed __Bxxx. - cf[gs]et[io]speed() and cfsetspeed() are versioned accordingly. - tcgetattr() and cfset[io]speed() are adjusted to always keep the c_[io]speed fields correct (unlike earlier versions), but to canonicalize the representation to ALSO configure the legacy fields if a valid legacy representation exists. - tcsetattr(), too, canonicalizes the representation in this way before passing it to the kernel, to maximize compatibility with older applications/tools. - The old IBAUD0 hack is removed; it is no longer necessary since even the legacy c_cflag baud rate fields have had separate input values for a long time. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-06-17linux/termios/powerpc: deal with powerpc-unique ioctl emulationH. Peter Anvin (Intel)1-0/+36
The powerpc architecture, only, emulates the termios ioctls using the glibc termios structure. Export the real kernel ones as the termios2 interface; although the kernel doesn't call it termios2, it is exactly the termios2 interface, and it avoids the namespace clash between the emulated ioctls and the real kernel ioctls. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-06-17linux/ioctls: use <linux/sockios.h> for sockios ioctlsH. Peter Anvin (Intel)1-84/+1
In the kernel, these are <linux/sockios.h>. The differences between <linux/sockios.h> and the copied data in <bits/ioctls.h> are minor; mainly some #ifdefs, so try to use <linux/sockios.h> directly; it is hopefully clean enough these days to use directly. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-06-17io: replace local_isatty() with a proper function __isatty_nostatus()H. Peter Anvin (Intel)1-0/+29
Replace local_isatty() inlined in libio with a proper function __isatty_nostatus(). This allows simpler system-specific implementations that don't need to touch errno at all. Note: I left the prototype in include/unistd.h (the internal header file.) It didn't much make sense to me to put it in a different header (not-cancel.h), but perhaps someone can elucidate the need. Add such an implementation for Linux, with a generic fallback. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-06-17termios: make __tcsetattr() the internal interfaceH. Peter Anvin (Intel)1-1/+1
There is a prototype for an internal __tcsetattr() function in include/termios.h, but tcsetattr without __ were still declared as the actual functions. Make this match the comment and make __tcsetattr() an internal interface. This will be required to version struct termios for Linux on MIPS and SPARC. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2025-06-13riscv: Correct __riscv_hwprobe function prototype [BZ #32932]Mark Harris2-13/+31
The third argument to __riscv_hwprobe is the size in bytes of the cpu bitmask pointed to by the fourth argument, however in the access attribute (read_only, 4, 3) it is used as an element count (i.e., the number of unsigned longs that make up the bitmask), resulting in a false compiler warning: $ gcc -c hwprobe1.c hwprobe1.c: In function 'main': hwprobe1.c:15:11: warning: '__riscv_hwprobe' reading 1024 bytes from a region of size 128 [-Wstringop-overread] 15 | ret = __riscv_hwprobe (pairs, 1, sizeof(cpus), cpus, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ hwprobe1.c:9:23: note: source object 'cpus' of size 128 9 | unsigned long int cpus[16]; | ^~~~ In file included from hwprobe1.c:1: /usr/include/riscv64-linux-gnu/sys/hwprobe.h:66:12: note: in a call to function '__riscv_hwprobe' declared with attribute 'access (read_only, 4, 3)' 66 | extern int __riscv_hwprobe (struct riscv_hwprobe *__pairs, size_t __pair_count, | ^~~~~~~~~~~~~~~ $ The documentation (https://docs.kernel.org/arch/riscv/hwprobe.html) claims that the cpu bitmask has the type cpu_set_t *, which would be consistent with other functions that take a cpu bitmask such as sched_setaffinity and sched_getaffinity. It also uses the name cpusetsize for the third argument, which is much more accurate than cpu_count since it is a size in bytes and not a cpu count. The (read_only, 4, 3) access attribute in the glibc prototype claims that the cpu bitmask is only read, however when flags is RISCV_HWPROBE_WHICH_CPUS it is both read and written. Therefore, in the glibc prototype the type of the fourth argument is changed to cpu_set_t * to match the documentation, the name of the third argument is changed to cpusetsize as in the documentation, and the incorrect access attribute that applies to these arguments is removed. Almost all existing callers pass a null pointer for the fourth argument, however a transparent union is introduced for compatibility with callers that cast a pointer to the old argument type, and a macro is introduced allowing callers the ability to distinguish between the old and new prototype when needed. The access attributes are being specified with __fortified_attr_access, however this macro is for fortified functions; the regular __attr_access macro is for non-fortified functions such as this one. Using the incorrect macro results in no access checks at fortify level 3, because it is assumed that the fortified function will be doing the checking. It is changed to use the correct macro so that the access checks will work regardless of fortify level. Also because __riscv_hwprobe is not a cancellation point, __THROW is added, consistent with similar functions. (However, it is omitted from the typedef because GCC does not accept it there.) The __wur (warn_unused_result) attribute is helpful for functions that cannot be used safely without checking the result, however code such as the following does not require the result to be checked and should not produce a warning: struct riscv_hwprobe pair = { RISCV_HWPROBE_KEY_IMA_EXT_0, 0 }; __riscv_hwprobe (&pair, 1, 0, NULL, 0); if (pair.value & RISCV_HWPROBE_EXT_ZBB) ... Therefore this attribute is omitted. The comment claiming that the second argument to the ifunc selector is a pointer to the vDSO function is corrected. It is a pointer to the regular glibc function (which returns errors as positive values), not the vDSO function (which returns errors as negative values). Fixes commit 426d0e1aa8f17426d13707594111df712d2b8911 ("riscv: Add Linux hwprobe syscall support"). Fixes: BZ #32932 Signed-off-by: Mark Harris <mark.hsj@gmail.com> Signed-off-by: Mark Harris <mark.hsj@gmail.com> Reviewed-by: Palmer Dabbelt <palmer@dabbelt.com> Acked-by: Palmer Dabbelt <palmer@dabbelt.com>
2025-06-05Linux: Drop obsolete kernel support with `if_nameindex' and `if_nametoindex'Maciej W. Rozycki1-33/+8
Support for the SIOCGIFINDEX ioctl(2) Linux ABI (0x8933 command, called SIOGIFINDEX in the API originally) was added with kernel version 2.1.14 for AF_INET6 sockets, followed by general support with version 2.1.22. The Linux API was then updated by adding the current SIOCGIFINDEX name with kernel version 2.1.68, back in Nov 1997. All these kernel versions are well below our current default required minimum of 3.2.0, let alone some platform higher version requirements. Drop support for the absence of the SIOCGIFINDEX ioctl(2) in the API or ABI, by removing arrangements for the ENOSYS error condition. Discard the indirection from '__if_nameindex' to 'if_nameindex_netlink' and adjust the implementation of '__if_nametoindex' accordingly for a better code flow.
2025-06-03sigaction: don't sign-extend sa_flagsнаб2-2/+2
Before: rt_sigaction(SIGBUS, {sa_handler=0x55abb9960139, sa_mask=[], sa_flags=SA_RESTORER|SA_RESETHAND|SA_SIGINFO|0xffffffff00000000, sa_restorer=0x7fb1b2a82050}, NULL, 8) = 0 After: rt_sigaction(SIGBUS, {sa_handler=0x7f6a70dce139, sa_mask=[], sa_flags=SA_RESTORER|SA_RESETHAND|SA_SIGINFO, sa_restorer=0x7f6a70c28f60}, NULL, 8) = 0 Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-29Update syscall lists for Linux 6.15Joseph Myers26-2/+28
Linux 6.15 adds the new syscall open_tree_attr. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-28linux: use PKEY_UNRESTRICTED macro in tst-pkeyYury Khrustalev1-3/+3
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-28misc: add PKEY_UNRESTRICTED macroYury Khrustalev1-4/+3
A corresponding macro has been added to Linux UAPI headers in 6.15. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-05-19AArch64: Cleanup PAC and BTIWilco Dijkstra2-9/+5
Now we finally support modern GCC and binutils, it's time for a cleanup. Use PAC and BTI instructions unconditionally and use proper assembler syntax. Remove the PR target/94791 strip_pac workarounds for buggy GCCs. Remove the PAC/BTI configure checks - always emit GNU property notes on assembly files. Change cfi_window_save to the correct cfi_negate_ra_state unwind directive. Reviewed-by: Matthieu Longo <matthieu.longo@arm.com>
2025-05-19AArch64: Implement AdvSIMD and SVE atan2pi/fDylan Fleming1-0/+5
Implement double and single precision variants of the C23 routine atan2pi for both AdvSIMD and SVE. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2025-05-19AArch64: Implement AdvSIMD and SVE atanpi/fDylan Fleming1-0/+5
Implement double and single precision variants of the C23 routine atanpi for both AdvSIMD and SVE. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2025-05-19AArch64: Implement AdvSIMD and SVE asinpi/fDylan Fleming1-0/+5
Implement double and single precision variants of the C23 routine asinpi for both AdvSIMD and SVE. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2025-05-19AArch64: Implement AdvSIMD and SVE acospi/fDylan Fleming1-0/+5
Implement double and single precision variants of the C23 routine acospi for both AdvSIMD and SVE. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2025-05-15powerpc: Remove check for -mabi=ibmlongdoubleAndreas Schwab2-60/+2
The -mabi=ibmlongdouble option has been added in gcc 4.2, thus can be assumed to always exist.
2025-05-14Implement C23 rootn.Joseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the rootn functions, which compute the Yth root of X for integer Y (with a domain error if Y is 0, even if X is a NaN). The integer exponent has type long long int in C23; it was intmax_t in TS 18661-4, and as with other interfaces changed after their initial appearance in the TS, I don't think we need to support the original version of the interface. As with pown and compoundn, I strongly encourage searching for worst cases for ulps error for these implementations (necessarily non-exhaustively, given the size of the input space). I also expect a custom implementation for a given format could be much faster as well as more accurate, although the implementation is simpler than those for pown and compoundn. This completes adding to glibc those TS 18661-4 functions (ignoring DFP) that are included in C23. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118592 regarding the C23 mathematical functions (not just the TS 18661-4 ones) missing built-in functions in GCC, where such functions might usefully be added. Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-05-09Implement C23 compoundnJoseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the compoundn functions, which compute (1+X) to the power Y for integer Y (and X at least -1). The integer exponent has type long long int in C23; it was intmax_t in TS 18661-4, and as with other interfaces changed after their initial appearance in the TS, I don't think we need to support the original version of the interface. Note that these functions are "compoundn" with a trailing "n", *not* "compound" (CORE-MATH has the wrong name, for example). As with pown, I strongly encourage searching for worst cases for ulps error for these implementations (necessarily non-exhaustively, given the size of the input space). I also expect a custom implementation for a given format could be much faster as well as more accurate (I haven't tested or benchmarked the CORE-MATH implementation for binary32); this is one of the more complicated and less efficient functions to implement in a type-generic way. As with exp2m1 and exp10m1, this showed up places where the powerpc64le IFUNC setup is not as self-contained as one might hope (in this case, without the changes specific to powerpc64le, there were undefined references to __GI___expf128). Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-05-05S390: Add new s390 platform z17.Stefan Liebler1-1/+1
The glibc-hwcaps subdirectories are extended by "z17". Libraries are loaded if the z17 facility bits are active: - Miscellaneous-instruction-extensions facility 4 - Vector-enhancements-facility 3 - Vector-Packed-Decimal-Enhancement Facility 3 - CPU: Concurrent-Functions Facility tst-glibc-hwcaps.c is extended in order to test z17 via new marker6. In case of running on a z17 with a kernel not recognizing z17 yet, AT_PLATFORM will be z900 but vector-bit in AT_HWCAP is set. This situation is now recognized and this testcase does not fail. A fatal glibc error is dumped if glibc was build with architecture level set for z17, but run on an older machine (See dl-hwcap-check.h). Note, you might get an SIGILL before this check if you don't use: configure --with-rtld-early-cflags=-march=<older-machine> ld.so --list-diagnostics now also dumps information about s390.cpu_features. Independent from z17, the s390x kernel won't introduce new HWCAP-Bits if there is no special handling needed in kernel itself. For z17, we don't have new HWCAP flags, but have to check the facility bits retrieved by stfle-instruction. Instead of storing all the stfle-bits (currently four 64bit values) in the cpu_features struct, we now only store those bits, which are needed within glibc itself. Note that we have this list twice, one with original values and the other one which can be filtered with GLIBC_TUNABLES=glibc.cpu.hwcaps. Those new fields are stored in so far reserved space in cpu_features struct. Thus processes started in between the update of glibc package and we e.g. have a new ld.so and an old libc.so, won't crash. The glibc internal ifunc-resolvers would not select the best optimized variant. The users of stfle-bits are also updated: - parsing of GLIBC_TUNABLES=glibc.cpu.hwcaps - glibc internal ifunc-resolvers - __libc_ifunc_impl_list - sysconf
2025-04-28nptl: Fix pthread_getattr_np when modules with execstack are allowed (BZ 32897)Adhemerval Zanella1-5/+2
The BZ 32653 fix (12a497c716f0a06be5946cabb8c3ec22a079771e) kept the stack pointer zeroing from make_main_stack_executable on _dl_make_stack_executable. However, previously the 'stack_endp' pointed to temporary variable created before the call of _dl_map_object_from_fd; while now we use the __libc_stack_end directly. Since pthread_getattr_np relies on correct __libc_stack_end, if _dl_make_stack_executable is called (for instance, when glibc.rtld.execstack=2 is set) __libc_stack_end will be set to zero, and the call will always fail. The __libc_stack_end zero was used a mitigation hardening, but since 52a01100ad011293197637e42b5be1a479a2f4ae it is used solely on pthread_getattr_np code. So there is no point in zeroing anymore. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Sam James <sam@gentoo.org>
2025-04-25linux/termio: remove <termio.h> and struct termioH. Peter Anvin5-46/+0
The <termio.h> interface is absolutely ancient: it was obsoleted by <termios.h> already in the first version of POSIX (1988) and thus predates the very first version of Linux. Unfortunately, some constant macros are used both by <termio.h> and <termios.h>; particularly problematic is the baud rate constants since the termio interface *requires* that the baud rate is set via an enumeration as part of c_cflag. In preparation of revamping the termios interface to support the arbitrary baud rate capability that the Linux kernel has supported since 2008, remove <termio.h> in the hope that no one still uses this archaic interface. Note that there is no actual code in glibc to support termio: it is purely an unabstracted ioctl() interface. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-04-22Add AT_* constants from Linux 6.12Joseph Myers1-0/+2
Linux 6.12 adds AT_RENAME_* aliases for RENAME_* flags for renameat2, and also AT_HANDLE_MNT_ID_UNIQUE. Add the first set of aliases to stdio.h alongside the RENAME_* names, and AT_HANDLE_MNT_ID_UNIQUE to bits/fcntl-linux.h. Tested for x86_64.
2025-04-08stdlib: Implement C2Y uabs, ulabs, ullabs and uimaxabsLenard Mollenkopf32-0/+128
C2Y adds unsigned versions of the abs functions (see C2Y draft N3467 and proposal N3349). Tested for x86_64. Signed-off-by: Lenard Mollenkopf <glibc@lenardmollenkopf.de>
2025-04-02sysdeps: powerpc: restore -mlong-double-128 checkSam James2-0/+117
We mistakenly dropped the check in 27b96e069aad17cefea9437542180bff448ac3a0; there's some other checks which we *can* drop, but let's worry about that later. Fixes the build on ppc64le where GCC is configured with --with-long-double-format=ieee. Reviewed-by: Andreas Schwab <schwab@suse.de>
2025-04-01Update syscall lists for Linux 6.14Joseph Myers1-2/+2
Linux 6.14 has no new syscalls. Update the version number in syscall-names.list to reflect that it is still current for 6.14. Tested with build-many-glibcs.py.
2025-03-31Raise the minimum GCC version to 12.1 [BZ #32539]H.J. Lu2-117/+0
For all Linux distros with glibc 2.40 which I can find, GCC 14.2 is used to compile glibc 2.40: OS GCC URL AOSC 14.2.0 https://aosc.io/ Arch Linux 14.2.0 https://archlinux.org/ ArchPOWER 14.2.0 https://archlinuxpower.org/ Artix 14.2.0 https://artixlinux.org/ Debian 14.2.0 https://www.debian.org/ Devuan 14.2.0 https://www.devuan.org/ Exherbo 14.2.0 https://www.exherbolinux.org/ Fedora 14.2.1 https://fedoraproject.org/ Gentoo 14.2.1 https://gentoo.org/ Kali Linux 14.2.0 https://www.kali.org/ KaOS 14.2.0 https://kaosx.us/ LiGurOS 14.2.0 https://liguros.gitlab.io/ Mageia 14.2.0 https://www.mageia.org/en/ Manjaro 14.2.0 https://manjaro.org/ NixOS 14.2.0 https://nixos.org/ openmamba 14.2.0 https://openmamba.org/ OpenMandriva 14.2.0 https://openmandriva.org/ openSUSE 14.2.0 https://www.opensuse.org/ Parabola 14.2.0 https://www.parabola.nu/ PLD Linux 14.2.0 https://pld-linux.org/ PureOS 14.2.0 https://pureos.net/ Raspbian 14.2.0 http://raspbian.org/ Slackware 14.2.0 http://www.slackware.com/ Solus 14.2.0 https://getsol.us/ T2 SDE 14.2.0 http://t2sde.org/ Ubuntu 14.2.0 https://www.ubuntu.com/ Wikidata 14.2.0 https://wikidata.org/ Support older versions of GCC to build glibc 2.42: 1. Need to work around bugs in older versions of GCC. 2. Can't use the new features in newer versions of GCC, which may be required for new features, like _Float16 which requires GCC 12.1 or above, in glibc, The main benefit of supporting older versions of GCC is easier backport of bug fixes to the older releases of glibc, which can be mitigated by avoiding incompatible features in newer versions of GCC for critical bug fixes. Require GCC 12.1 or newer to build. Remove GCC version check for PowerPC and s390x. TEST_CC and TEST_CXX can be used to test the glibc build with the older versions of GCC. For glibc developers who are using Linux OSes which don't come with GCC 12.1 or newer, they should build and install GCC 12.1 or newer to work on glibc. This fixes BZ #32539. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
2025-03-31aarch64: Fix _dl_tlsdesc_dynamic unwind for pac-ret (BZ 32612)Adhemerval Zanella3-0/+88
When libgcc is built with pac-ret, it requires to autenticate the unwinding frame based on CFI information. The _dl_tlsdesc_dynamic uses a custom calling convention, where it is responsible to save and restore all registers it might use (even volatile). The pac-ret support added by 1be3d6eb823d8b952fa54b7bbc90cbecb8981380 was added only on the slow-path, but the fast path also adds DWARF Register Rule Instruction (cfi_adjust_cfa_offset) since it requires to save/restore some auxiliary register. It seems that this is not fully supported neither by libgcc nor AArch64 ABI [1]. Instead, move paciasp/autiasp to function prologue/epilogue to be used on both fast and slow paths. I also corrected the _dl_tlsdesc_dynamic comment description, it was copied from i386 implementation without any adjustment. Checked on aarch64-linux-gnu with a toolchain built with --enable-standard-branch-protection on a system with pac-ret support. [1] https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst#id1 Reviewed-by: Yury Khrustalev <yury.khrustalev@arm.com>
2025-03-27Implement C23 pownJoseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the pown functions, which are like pow but with an integer exponent. That exponent has type long long int in C23; it was intmax_t in TS 18661-4, and as with other interfaces changed after their initial appearance in the TS, I don't think we need to support the original version of the interface. The test inputs are based on the subset of test inputs for pow that use integer exponents that fit in long long. As the first such template implementation that saves and restores the rounding mode internally (to avoid possible issues with directed rounding and intermediate overflows or underflows in the wrong rounding mode), support also needed to be added for using SET_RESTORE_ROUND* in such template function implementations. This required math-type-macros-float128.h to include <fenv_private.h>, so it can tell whether SET_RESTORE_ROUNDF128 is defined. In turn, the include order with <fenv_private.h> included before <math_private.h> broke loongarch builds, showing up that sysdeps/loongarch/math_private.h is really a fenv_private.h file (maybe implemented internally before the consistent split of those headers in 2018?) and needed to be renamed to fenv_private.h to avoid errors with duplicate macro definitions if <math_private.h> is included after <fenv_private.h>. The underlying implementation uses __ieee754_pow functions (called more than once in some cases, where the exponent does not fit in the floating type). I expect a custom implementation for a given format, that only handles integer exponents but handles larger exponents directly, could be faster and more accurate in some cases. I encourage searching for worst cases for ulps error for these implementations (necessarily non-exhaustively, given the size of the input space). Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-03-25linux: Fix integer overflow warnings when including <sys/mount.h> [BZ #32708]Collin Funk1-1/+1
Using gcc -Wshift-overflow=2 -Wsystem-headers to compile a file including <sys/mount.h> will cause a warning since 1 << 31 is undefined behavior on platforms where int is 32-bits. Signed-off-by: Collin Funk <collin.funk1@gmail.com> Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-03-24Add _FORTIFY_SOURCE support for inet_ptonAaron Merey32-0/+32
Add function __inet_pton_chk which calls __chk_fail when the size of argument dst is too small. inet_pton is redirected to __inet_pton_chk or __inet_pton_warn when _FORTIFY_SOURCE is > 0. Also add tests to debug/tst-fortify.c, update the abilist with __inet_pton_chk and mention inet_pton fortification in maint.texi. Co-authored-by: Frédéric Bérat <fberat@redhat.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-24Update kernel version to 6.13 in header constant testsJoseph Myers3-4/+4
There are no new constants covered by tst-mman-consts.py, tst-mount-consts.py or tst-sched-consts.py in Linux 6.13 that need any header changes, so update the kernel version in those tests. (tst-pidfd-consts.py will need updating separately along with adding new constants to glibc.) Tested with build-many-glibcs.py.
2025-03-21debug: Improve '%n' fortify detection (BZ 30932)Adhemerval Zanella1-13/+8
The 7bb8045ec0 path made the '%n' fortify check ignore EMFILE errors while trying to open /proc/self/maps, and this added a security issue where EMFILE can be attacker-controlled thus making it ineffective for some cases. The EMFILE failure is reinstated but with a different error message. Also, to improve the false positive of the hardening for the cases where no new files can be opened, the _dl_readonly_area now uses _dl_find_object to check if the memory area is within a writable ELF segment. The procfs method is still used as fallback. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Arjun Shankar <arjun@redhat.com>
2025-03-21Add _FORTIFY_SOURCE support for inet_ntopFrédéric Bérat32-0/+32
- Create the __inet_ntop_chk routine that verifies that the builtin size of the destination buffer is at least as big as the size given by the user. - Redirect calls from inet_ntop to __inet_ntop_chk or __inet_ntop_warn - Update the abilist for this new routine - Update the manual to mention the new fortification Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-03-14Implement C23 powrJoseph Myers30-0/+209
C23 adds various <math.h> function families originally defined in TS 18661-4. Add the powr functions, which are like pow, but with simpler handling of special cases (based on exp(y*log(x)), so negative x and 0^0 are domain errors, powers of -0 are always +0 or +Inf never -0 or -Inf, and 1^+-Inf and Inf^0 are also domain errors, while NaN^0 and 1^NaN are NaN). The test inputs are taken from those for pow, with appropriate adjustments (including removing all tests that would be domain errors from those in auto-libm-test-in and adding some more such tests in libm-test-powr.inc). The underlying implementation uses __ieee754_pow functions after dealing with all special cases that need to be handled differently. It might be a little faster (avoiding a wrapper and redundant checks for special cases) to have an underlying implementation built separately for both pow and powr with compile-time conditionals for special-case handling, but I expect the benefit of that would be limited given that both functions will end up needing to use the same logic for computing pow outside of special cases. My understanding is that powr(negative, qNaN) should raise "invalid": that the rule on "invalid" for an argument outside the domain of the function takes precedence over a quiet NaN argument producing a quiet NaN result with no exceptions raised (for rootn it's explicit that the 0th root of qNaN raises "invalid"). I've raised this on the WG14 reflector to confirm the intent. Tested for x86_64 and x86, and with build-many-glibcs.py.
2025-03-13elf: Canonicalize $ORIGIN in an explicit ld.so invocation [BZ 25263]Adhemerval Zanella1-0/+23
When an executable is invoked directly, we calculate $ORIGIN by calling readlink on /proc/self/exe, which the Linux kernel resolves to the target of any symlinks. However, if an executable is run through ld.so, we cannot use /proc/self/exe and instead use the path given as an argument. This leads to a different calculation of $ORIGIN, which is most notable in that it causes ldd to behave differently (e.g., by not finding a library) from directly running the program. To make the behavior consistent, take advantage of the fact that the kernel also resolves /proc/self/fd/ symlinks to the target of any symlinks in the same manner, so once we have opened the main executable in order to load it, replace the user-provided path with the result of calling readlink("/proc/self/fd/N"). (On non-Linux platforms this resolution does not happen and so no behavior change is needed.) The __fd_to_filename requires _fitoa_word and _itoa_word, which for 32-bits pulls a lot of definitions from _itoa.c (due _ITOA_NEEDED being defined). To simplify the build move the required function to a new file, _fitoa_word.c. Checked on x86_64-linux-gnu and i686-linux-gnu. Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com> Reviewed-by: Geoffrey Thomas <geofft@ldpreload.com> Tested-by: Geoffrey Thomas <geofft@ldpreload.com>
2025-03-12Update syscall lists for Linux 6.13Joseph Myers26-2/+106
Linux 6.13 adds four new syscalls. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
2025-03-12Linux: Add new test misc/tst-sched_setattr-threadFlorian Weimer2-0/+117
The straightforward sched_getattr call serves as a test for bug 32781, too. Reviewed-by: Joseph Myers <josmyers@redhat.com>