about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux
Commit message (Collapse)AuthorAgeFilesLines
* Implement strlcpy and strlcat [BZ #178]Florian Weimer2023-06-1434-0/+136
| | | | | | | | | | | These functions are about to be added to POSIX, under Austin Group issue 986. The fortified strlcat implementation does not raise SIGABRT if the destination buffer does not contain a null terminator, it just inherits the non-failing regular strlcat behavior. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* linux: Fail as unsupported if personality call is filteredAdhemerval Zanella2023-06-051-12/+21
| | | | | | | | | | | | | | | | | | | | | Container management default seccomp filter [1] only accepts personality(2) with PER_LINUX, (0x0), UNAME26 (0x20000), PER_LINUX32 (0x8), UNAME26 | PER_LINUX32, and 0xffffffff (to query current personality) Although the documentation only state it is blocked to prevent 'enabling BSD emulation' (PER_BSD, not implemented by Linux), checking on repository log the real reason is to block ASLR disable flag (ADDR_NO_RANDOMIZE) and other poorly support emulations. So handle EPERM and fail as UNSUPPORTED if we can really check for BZ#19408. Checked on aarch64-linux-gnu. [1] https://github.com/moby/moby/blob/master/profiles/seccomp/default.json Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Remove MAP_VARIABLE from hppa bits/mman.hJoseph Myers2023-06-051-1/+0
| | | | | | | | | As suggested in <https://sourceware.org/pipermail/libc-alpha/2023-February/145890.html>, remove the MAP_VARIABLE define from the hppa bits/mman.h, for consistency with Linux 6.2 which removed the define there. Tested with build-many-glibcs.py for hppa-linux-gnu.
* Use __nonnull for the epoll_wait(2) family of syscallsAlejandro Colomar2023-06-011-4/+4
| | | | | Signed-off-by: Alejandro Colomar <alx@kernel.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Fix invalid use of NULL in epoll_pwait2(2) testAlejandro Colomar2023-06-011-1/+3
| | | | | | | | | epoll_pwait2(2)'s second argument should be nonnull. We're going to add __nonnull to the prototype, so let's fix the test accordingly. We can use a dummy variable to avoid passing NULL. Reported-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
* getipv4sourcefilter: Get rid of allocaJoe Simmons-Talbott2023-06-011-17/+7
| | | | | | Use a scratch_buffer rather than alloca to avoid potential stack overflows. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* getsourcefilter: Get rid of alloca.Joe Simmons-Talbott2023-06-011-17/+7
| | | | | | Use a scratch_buffer rather than alloca to avoid potential stack overflows. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* io: Fix F_GETLK, F_SETLK, and F_SETLKW for powerpc64Adhemerval Zanella2023-05-311-0/+6
| | | | | | | | | | | | | | | | | | Different than other 64 bit architectures, powerpc64 defines the LFS POSIX lock constants with values similar to 32 ABI, which are meant to be used with fcntl64 syscall. Since powerpc64 kABI does not have fcntl, the constants are adjusted with the FCNTL_ADJUST_CMD macro. The 4d0fe291aed3a476a changed the logic of generic constants LFS value are equal to the default values; which is now wrong for powerpc64. Fix the value by explicit define the previous glibc constants (powerpc64 does not need to use the 32 kABI value, but it simplifies the FCNTL_ADJUST_CMD which should be kept as compatibility). Checked on powerpc64-linux-gnu and powerpc-linux-gnu.
* io: Fix record locking contants on 32 bit arch with 64 bit default time_t ↵Adhemerval Zanella2023-05-301-1/+1
| | | | | | | | | | | | | | | | | | (BZ#30477) For architecture with default 64 bit time_t support, the kernel does not provide LFS and non-LFS values for F_GETLK, F_GETLK, and F_GETLK (the default value used for 64 bit architecture are used). This is might be considered an ABI break, but the currenct exported values is bogus anyway. The POSIX lockf is not affected since it is aliased to lockf64, which already uses the LFS values. Checked on i686-linux-gnu and the new tests on a riscv32. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* LoongArch: Fix inconsistency in SHMLBA macro values between glibc and kernelcaiyinyu2023-05-301-0/+24
| | | | | | | | | The LoongArch glibc was using the value of the SHMLBA macro from common code, which is __getpagesize() (16k), but this was inconsistent with the value of the SHMLBA macro in the kernel, which is SZ_64K (64k). This caused several shmat-related tests in LTP (Linux Test Project) to fail. This commit fixes the issue by ensuring that the glibc's SHMLBA macro value matches the value used in the kernel like other architectures.
* riscv: Add the clone3 wrapperAdhemerval Zanella2023-05-292-0/+80
| | | | | | | | | | | It follows the internal signature: extern int clone3 (struct clone_args *__cl_args, size_t __size, int (*__func) (void *__arg), void *__arg); Checked on riscv64-linux-gnu-rv64imafdc-lp64d. Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
* setsourcefilter: Replace alloca with a scratch_buffer.Joe Simmons-Talbott2023-05-291-20/+7
| | | | | | | | Use a scratch_buffer rather than either alloca or malloc to reduce the possibility of a stack overflow. Suggested-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Add MFD_NOEXEC_SEAL, MFD_EXEC from Linux 6.3 to bits/mman-shared.hJoseph Myers2023-05-261-0/+4
| | | | | | | | | Linux 6.3 adds new constants MFD_NOEXEC_SEAL and MFD_EXEC. Add these to bits/mman-shared.h (conditional on MFD_NOEXEC_SEAL not already being defined, similar to the existing conditional on the older MFD_* macros). Tested for x86_64.
* Add IP_LOCAL_PORT_RANGE from Linux 6.3 to bits/in.hJoseph Myers2023-05-261-0/+1
| | | | | | | Linux 6.3 adds a new constant IP_LOCAL_PORT_RANGE. Add it to the corresponding bits/in.h in glibc. Tested for x86_64.
* setipv4sourcefilter: Avoid using alloca.Joe Simmons-Talbott2023-05-261-17/+7
| | | | | | | Use a scratch_buffer rather than alloca/malloc to avoid potential stack overflow. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Fix misspellings in sysdeps/unix -- BZ 25337Paul Pluzhnikov2023-05-2369-87/+87
| | | | | | | Applying this commit results in bit-identical rebuild of libc.so.6 math/libm.so.6 elf/ld-linux-x86-64.so.2 mathvec/libmvec.so.1 Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Add HWCAP2_SME* from Linux 6.3 to AArch64 bits/hwcap.hJoseph Myers2023-05-181-0/+6
| | | | | | | Linux 6.3 adds six HWCAP2_SME* constants for AArch64; add them to the corresponding bits/hwcap.h in glibc. Tested with build-many-glibcs.py for aarch64-linux-gnu.
* Update kernel version to 6.3 in header constant testsJoseph Myers2023-05-163-4/+4
| | | | | | | | | This patch updates the kernel version in the tests tst-mman-consts.py, tst-mount-consts.py and tst-pidfd-consts.py to 6.3. (There are no new constants covered by these tests in 6.3 that need any other header changes.) Tested with build-many-glibcs.py.
* i386: Use pthread_barrier for synchronization on tst-bz21269DJ Delorie2023-05-161-5/+28
| | | | | | | | | | | | | | | | | | | | | | | | So I was able to reproduce the hangs in the original source, and debug it, and fix it. In doing so, I realized that we can't use anything complex to trigger the thread because that "anything" might also cause the expected segfault and force everything out of sync again. Here's what I ended up with, and it doesn't seem to hang where the original one hung quite often (in a tight while..end loop). The key changes are: 1. Calls to futex are error checked, with retries, to ensure that the futexes are actually doing what they're supposed to be doing. In the original code, nearly every futex call returned an error. 2. The main loop has checks for whether the thread ran or not, and "unlocks" the thread if it didn't (this is how the original source hangs). Note: the usleep() is not for timing purposes, but just to give the kernel an excuse to run the other thread at that time. The test will not hang without it, but is more likely to test the right bugfix if the usleep() is present.
* linux: Reformat Makefile.Carlos O'Donell2023-05-161-6/+7
| | | | | | | | Reflow Makefile. Sort using scripts/sort-makefile-lines.py. No code generation changes observed in binary artifacts. No regressions on x86_64 and i686.
* Update syscall lists for Linux 6.3Joseph Myers2023-05-151-2/+2
| | | | | | | Linux 6.3 has no new syscalls. Update the version number in syscall-names.list to reflect that it is still current for 6.3. Tested with build-many-glibcs.py.
* Enable libmvec support for AArch64Joe Ramsay2023-05-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | This patch enables libmvec on AArch64. The proposed change is mainly implementing build infrastructure to add the new routines to ABI, tests and benchmarks. I have demonstrated how this all fits together by adding implementations for vector cos, in both single and double precision, targeting both Advanced SIMD and SVE. The implementations of the routines themselves are just loops over the scalar routine from libm for now, as we are more concerned with getting the plumbing right at this point. We plan to contribute vector routines from the Arm Optimized Routines repo that are compliant with requirements described in the libmvec wiki. Building libmvec requires minimum GCC 10 for SVE ACLE. To avoid raising the minimum GCC by such a big jump, we allow users to disable libmvec if their compiler is too old. Note that at this point users have to manually call the vector math functions. This seems to be acceptable to some downstream users. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
* hurd 64bit: Fix struct msqid_ds and shmid_ds fieldsSamuel Thibault2023-05-011-2/+0
| | | | | | | | The standards want msg_lspid/msg_lrpid/shm_cpid/shm_lpid to be pid_t, see BZ 23083 and 23085. We can leave them __rpc_pid_t on i386 for ABI compatibility, but avoid hitting the issue on 64bit.
* hurd 64bit: Fix ipc_perm fields typesSamuel Thibault2023-05-012-41/+0
| | | | | | | | | | | The standards want uid/cuid to be uid_t, gid/cgid to be gid_t and mode to be mode_t, see BZ 23082. We can leave them short ints on i386 for ABI compatibility, but avoid hitting the issue on 64bit. bits/ipc.h ends up being exactly the same in sysdeps/gnu/ and sysdeps/unix/sysv/linux/, so remove the latter.
* __check_pf: Add a cancellation cleanup handler [BZ #20975]H.J. Lu2023-04-282-0/+17
| | | | | | | | | | | | | | | | | | | | There are reports for hang in __check_pf: https://github.com/JoeDog/siege/issues/4 It is reproducible only under specific configurations: 1. Large number of cores (>= 64) and large number of threads (> 3X of the number of cores) with long lived socket connection. 2. Low power (frequency) mode. 3. Power management is enabled. While holding lock, __check_pf calls make_request which calls __sendto and __recvmsg. Since __sendto and __recvmsg are cancellation points, lock held by __check_pf won't be released and can cause deadlock when thread cancellation happens in __sendto or __recvmsg. Add a cancellation cleanup handler for __check_pf to unlock the lock when cancelled by another thread. This fixes BZ #20975 and the siege hang issue.
* if_index: Remove unneeded alloca.h includeJoe Simmons-Talbott2023-04-261-1/+0
| | | | | Nothing is being used from this header. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* gethostid: Do not include alloca.hJoe Simmons-Talbott2023-04-261-1/+0
| | | | | Nothing from alloca.h is being used here. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* hurd: Implement prefer_map_32bit_exec tunableSergey Bugaev2023-04-245-120/+0
| | | | | | | This makes the prefer_map_32bit_exec tunable no longer Linux-specific. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230423215526.346009-4-bugaevc@gmail.com>
* linux: Re-flow and sort multiline Makefile definitionsAdhemerval Zanella2023-04-201-48/+158
|
* malloc: Assure that THP mode read do write OOB end of stringtAdhemerval Zanella2023-04-141-0/+2
|
* malloc: Assure that THP mode is always null terminatedAdhemerval Zanella2023-04-131-0/+1
|
* hppa: Revise __TIMESIZE define to use __WORDSIZEJohn David Anglin2023-04-051-1/+3
| | | | | | Handle both 32 and 64-bit ABIs. Signed-off-by: John David Anglin <dave.anglin@bell.net>
* math: Remove the error handling wrapper from fmod and fmodfAdhemerval Zanella Netto2023-04-0323-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The error handling is moved to sysdeps/ieee754 version with no SVID support. The compatibility symbol versions still use the wrapper with SVID error handling around the new code. There is no new symbol version nor compatibility code on !LIBM_SVID_COMPAT targets (e.g. riscv). The ia64 is unchanged, since it still uses the arch specific __libm_error_region on its implementation. For both i686 and m68k, which provive arch specific implementation, wrappers are added so no new symbol are added (which would require to change the implementations). It shows an small improvement, the results for fmod: Architecture | Input | master | patch -----------------|-----------------|----------|-------- x86_64 (Ryzen 9) | subnormals | 12.5049 | 9.40992 x86_64 (Ryzen 9) | normal | 296.939 | 296.738 x86_64 (Ryzen 9) | close-exponents | 16.0244 | 13.119 aarch64 (N1) | subnormal | 6.81778 | 4.33313 aarch64 (N1) | normal | 155.620 | 152.915 aarch64 (N1) | close-exponents | 8.21306 | 5.76138 armhf (N1) | subnormal | 15.1083 | 14.5746 armhf (N1) | normal | 244.833 | 241.738 armhf (N1) | close-exponents | 21.8182 | 22.457 Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* x86: Set FSGSBASE to active if enabled by kernelH.J. Lu2023-04-031-0/+27
| | | | | | | | | | | | | Linux kernel uses AT_HWCAP2 to indicate if FSGSBASE instructions are enabled. If the HWCAP2_FSGSBASE bit in AT_HWCAP2 is set, FSGSBASE instructions can be used in user space. Define dl_check_hwcap2 to set the FSGSBASE feature to active on Linux when the HWCAP2_FSGSBASE bit is set. Add a test to verify that FSGSBASE is active on current kernels. NB: This test will fail if the kernel doesn't set the HWCAP2_FSGSBASE bit in AT_HWCAP2 while fsgsbase shows up in /proc/cpuinfo. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* getlogin_r: fix missing fallback if loginuid is unset (bug 30235)Andreas Schwab2023-03-301-4/+1
| | | | | When /proc/self/loginuid is not set, we should still fall back to using the traditional utmp lookup, instead of failing right away.
* Remove --enable-tunables configure optionAdhemerval Zanella Netto2023-03-296-32/+4
| | | | | | | | | | | | And make always supported. The configure option was added on glibc 2.25 and some features require it (such as hwcap mask, huge pages support, and lock elisition tuning). It also simplifies the build permutations. Changes from v1: * Remove glibc.rtld.dynamic_sort changes, it is orthogonal and needs more discussion. * Cleanup more code. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* LoongArch: ldconfig: Add comments for using EF_LARCH_OBJABI_V1caiyinyu2023-03-281-0/+6
| | | | | We added Adhemerval Zanella's comment to explain the reason for using EF_LARCH_OBJABI_V1.
* libio: Do not autogenerate stdio_lim.hAdhemerval Zanella Netto2023-03-271-0/+28
| | | | | | | | | | | | | Instead define the required fields in system dependend files. The only system dependent definition is FILENAME_MAX, which should match POSIX PATH_MAX, and it is obtained from either kernel UAPI or mach headers. Currently set pre-defined value from current kernels. It avoids a circular dependendy when including stdio.h in gen-as-const-headers files. Checked on x86_64-linux-gnu and i686-linux-gnu Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Move libc_freeres_ptrs and libc_subfreeres to hidden/weak functionsAdhemerval Zanella Netto2023-03-276-7/+31
| | | | | | | | | | | | | | | | | | | | They are both used by __libc_freeres to free all library malloc allocated resources to help tooling like mtrace or valgrind with memory leak tracking. The current scheme uses assembly markers and linker script entries to consolidate the free routine function pointers in the RELRO segment and to be freed buffers in BSS. This patch changes it to use specific free functions for libc_freeres_ptrs buffers and call the function pointer array directly with call_function_static_weak. It allows the removal of both the internal macros and the linker script sections. Checked on x86_64-linux-gnu, i686-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* LoongArch: ldconfig: Ignore EF_LARCH_OBJABI_V1 in shared objectsXi Ruoyao2023-03-271-1/+1
| | | | | | | | | | | | | | | | Binutils 2.40 sets EF_LARCH_OBJABI_V1 for shared objects: $ ld --version | head -n1 GNU ld (GNU Binutils) 2.40 $ echo 'int dummy;' > dummy.c $ cc dummy.c -shared $ readelf -h a.out | grep Flags Flags: 0x43, DOUBLE-FLOAT, OBJ-v1 We need to ignore it in ldconfig or ldconfig will consider all shared objects linked by Binutils 2.40 "unsupported". Maybe we should stop setting EF_LARCH_OBJABI_V1 for shared objects, but Binutils 2.40 is already released and we cannot change it.
* ARC: run child from the separate start block in __clonePavel Kozlov2023-03-131-15/+25
| | | | | | | For better debug experience use separate code block with extra cfi_* directives to run child (same as in __clone3). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* ARC: Add the clone3 wrapperPavel Kozlov2023-03-132-0/+92
| | | | | | | | | | | Use the clone3 wrapper on ARC. It doesn't care about stack alignment. All callers should provide an aligned stack. It follows the internal signature: extern int clone3 (struct clone_args *__cl_args, size_t __size, int (*__func) (void *__arg), void *__arg); Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* LoongArch: Add support for ldconfig.caiyinyu2023-03-132-0/+152
|
* linux: fix ntp_gettime abi break (BZ# 30156)Kacper Piwiński2023-03-101-2/+9
| | | | | | | | | | | | | | | | Between versions v2.11 and v2.12 struct ntptimeval got new fields. That wasn't a problem because new function ntp_gettimex was created (and made default) to support new struct. Old ntp_gettime was not using new fields so it was safe to call with old struct definition. Then commits 5613afe9e3dff and b6ad64b907a (added for 64 bit time_t support), ntp_gettime start setting new fields. Sets fields manually to maintain compatibility with v2.11 struct definition. Resolves #30156 Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Update kernel version to 6.2 in header constant testsJoseph Myers2023-03-063-4/+4
| | | | | | | | | | This patch updates the kernel version in the tests tst-mman-consts.py, tst-mount-consts.py and tst-pidfd-consts.py to 6.2. (There are no new constants covered by these tests in 6.2 that need any other header changes, and the removed MAP_VARIABLE for hppa was addressed separately.) Tested with build-many-glibcs.py.
* C2x scanf binary constant handlingJoseph Myers2023-03-0234-0/+516
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | C2x adds binary integer constants starting with 0b or 0B, and supports those constants for the %i scanf format (in addition to the %b format, which isn't yet implemented for scanf in glibc). Implement that scanf support for glibc. As with the strtol support, this is incompatible with previous C standard versions, in that such an input string starting with 0b or 0B was previously required to be parsed as 0 (with the rest of the input potentially matching subsequent parts of the scanf format string). Thus this patch adds 12 new __isoc23_* functions per long double format (12, 24 or 36 depending on how many long double formats the glibc configuration supports), with appropriate header redirection support (generally very closely following that for the __isoc99_* scanf functions - note that __GLIBC_USE (DEPRECATED_SCANF) takes precedence over __GLIBC_USE (C2X_STRTOL), so the case of GNU extensions to C89 continues to get old-style GNU %a and does not get this new feature). The function names would remain as __isoc23_* even if C2x ends up published in 2024 rather than 2023. When scanf %b support is added, I think it will be appropriate for all versions of scanf to follow C2x rules for inputs to the %b format (given that there are no compatibility concerns for a new format). Tested for x86_64 (full glibc testsuite). The first version was also tested for powerpc (32-bit) and powerpc64le (stdio-common/ and wcsmbs/ tests), and with build-many-glibcs.py.
* Add AArch64 HWCAP2 values from Linux 6.2 to bits/hwcap.hJoseph Myers2023-02-281-0/+3
| | | | | | | Linux 6.2 adds three new AArch64 HWCAP2 values; add them to glibc's AArch64 bits/hwcap.h. Tested with build-many-glibcs.py for aarch64-linux-gnu.
* Add Arm HWCAP values from Linux 6.2 to bits/hwcap.hJoseph Myers2023-02-283-6/+13
| | | | | | | | Linux 6.2 adds six new Arm HWCAP values and two new HWCAP2 values; add them to glibc's Arm bits/hwcap.h, with corresponding dl-procinfo.c and dl-procinfo.h updates. Tested with build-many-glibcs.py for arm-linux-gnueabi.
* hppa: Drop old parisc-specific MADV_* constantsJohn David Anglin2023-02-251-28/+0
| | | | | | | | | | | | | | | | | | | The Linux kernel upstream commit 71bdea6f798b ("parisc: Align parisc MADV_XXX constants with all other architectures") dropped the parisc-specific MADV_* values in favour of the same constants as other architectures. In the same commit a wrapper was added which translates the old values to the standard MADV_* values to avoid breakage of existing programs. This upstream patch has been downported to all stable kernel trees as well. This patch now drops the parisc specific constants from glibc to allow newly compliled programs to use the standard MADV_* constants. v2: Added NEWS section, based on feedback from Florian Weimer Signed-off-by: Helge Deller <deller@gmx.de>
* Update syscall lists for Linux 6.2Joseph Myers2023-02-231-2/+2
| | | | | | | Linux 6.2 has no new syscalls. Update the version number in syscall-names.list to reflect that it is still current for 6.2. Tested with build-many-glibcs.py.