about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux
Commit message (Collapse)AuthorAgeFilesLines
...
* Expose all MAP_ constants in <sys/mman.h> unconditionally (bug 29375)Andreas Schwab2022-10-109-110/+82
| | | | | POSIX reserves the MAP_ prefix for <sys/mman.h>, so there is no need to conditionalize their definitions on feature test macros.
* elf: Remove _dl_string_hwcapJavier Pello2022-10-062-24/+0
| | | | | | | | Removal of legacy hwcaps support from the dynamic loader left no users of _dl_string_hwcap. Signed-off-by: Javier Pello <devel@otheo.eu> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Update kernel version to 6.0 in header constant testsJoseph Myers2022-10-053-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.0. (There are no new constants covered by these tests in 6.0 that need any other header changes.) Tested with build-many-glibcs.py.
* Update syscall lists for Linux 6.0Joseph Myers2022-10-051-2/+2
| | | | | | | Linux 6.0 has no new syscalls. Update the version number in syscall-names.list to reflect that it is still current for 6.0. Tested with build-many-glibcs.py.
* malloc: Do not clobber errno on __getrandom_nocancel (BZ #29624)Adhemerval Zanella2022-09-301-1/+1
| | | | | | | | | | Use INTERNAL_SYSCALL_CALL instead of INLINE_SYSCALL_CALL. This requires emulate the semantic for hurd call (so __arc4random_buf uses the fallback). Checked on x86_64-linux-gnu. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* stdlib: Fix __getrandom_nocancel type and arc4random usage (BZ #29638)Adhemerval Zanella2022-09-301-1/+1
| | | | | | | | | Using an unsigned type prevents the fallback to be used if kernel does not support getrandom syscall. Checked on x86_64-linux-gnu. Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
* Use C11 atomics instead of atomic_increment(_val)Wilco Dijkstra2022-09-231-3/+3
| | | | | | | | | | | Replace atomic_increment and atomic_increment_val with atomic_fetch_add_relaxed. One case in sem_post.c uses release semantics (see comment above it). The others are simple counters and do not protect any shared data from concurrent accesses. Passes regress on AArch64. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hppa: undef __ASSUME_SET_ROBUST_LISTJohn David Anglin2022-09-201-0/+3
| | | | | | | QEMU does not support support set_robust_list. Thus, we need to enable detection of set_robust_list system call. Signed-off-by: John David Anglin <dave.anglin@bell.net>
* linux: Use same type for MMAP2_PAGE_UNITAdhemerval Zanella2022-09-204-4/+4
| | | | | | | It avoid a possible compiler warning where right size of operator is converted from a negative value to unsigned. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* m68k: Enforce 4-byte alignment on internal locks (BZ #29537)Adhemerval Zanella2022-09-201-0/+25
| | | | | | | | | A new internal definition, __LIBC_LOCK_ALIGNMENT, is used to force the 4-byte alignment only for m68k, other architecture keep the natural alignment of the type used internally (and hppa does not require 16-byte alignment for kernel-assisted CAS). Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Linux: Do not skip d_ino == 0 entries in readdir, readdir64 (bug 12165)Florian Weimer2022-09-192-108/+69
| | | | | | | | POSIX does not say this value is special. For example, old XFS file systems may still use inode number zero. Also update the comment regarding ENOENT. Linux may return ENOENT for some file systems.
* RISC-V: Allow long jumps to __syscall_errorŁukasz Stelmach2022-09-166-6/+6
| | | | | | | | | | __syscall_error may end up farther than 1MiB away from a caller, especially when linking statically large binaries. tail allows for 4GiB jumps and is reduced to j when a linked symbol is within range. Fixes: 36960f0c76 ("RISC-V: Linux Syscall Interface") Fixes: 7f33b09c65 ("RISC-V: Linux ABI") Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
* Use C11 atomics instead atomic_add(_zero)Wilco Dijkstra2022-09-091-3/+3
| | | | | | Replace atomic_add and atomic_add_zero with atomic_fetch_add_relaxed. Reviewed-by: DJ Delorie <dj@redhat.com>
* LoongArch: Add soft float support.caiyinyu2022-09-015-7/+79
|
* S390: Always use svc 0Stefan Liebler2022-08-3013-66/+46
| | | | | | | | | | | | | | | | | | | On s390x syscalls are triggered by svc instruction. One can pass the syscall number encoded in the instruction "svc 123" or by storing it in r1: lghi r1,123 svc 0 If the syscall number is encoded in the instruction, this can cause broken syscall restarts. Therefore this patch is now just passing the syscall number in r1. See also kernel-commit: "s390/signal: switch to using vdso for sigreturn and syscall restart" https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/s390/[%e2%80%a6]call.c?h=v6.0-rc1&id=df29a7440c4b5c65765c8f60396b3b13063e24e9 As information, the "svc 0" feature was introduced in kernel 2.5.62: commit b5aad611393ef2e132e3648fa4c6e56a9cfa8708
* LoongArch: Fix ptr mangling/demangling features.caiyinyu2022-08-301-17/+16
|
* s390: Move hwcaps/platform names out of _rtld_global_roFlorian Weimer2022-08-251-1/+1
| | | | | | | | | | | Changes to these arrays are often backported to stable releases, but additions to these arrays shift the offsets of the following _rltd_global_ro members, thus breaking the GLIBC_PRIVATE ABI. Obviously, this change is itself an internal ABI break, but at least it will avoid further ABI breaks going forward. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Add AArch64 HWCAP2_* constants from Linux 5.19Joseph Myers2022-08-221-0/+9
| | | | | | | Linux 5.19 adds more HWCAP2_* values for AArch64; add these to its bits/hwcap.h header in glibc. Tested with build-many-glibcs.py for aarch64-linux-gnu.
* Add AGROUP from Linux 5.19 to sys/acct.h, remove Alpha version (bug 29502)Joseph Myers2022-08-222-64/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux 5.19 adds a new accounting flag AGROUP; add it to the enumeration in sys/acct.h. This shows up that the Alpha-specific variant of this header has a different set of constants and struct acct, which appear to be the constants and structure layout from Linux 2.0. These were changed some time between Linux 2.0 and Linux 2.2; I see no evidence of an Alpha-specific layout or set of constants, but haven't checked the detailed Linux kernel history between those versions. Rather, it looks like tha Alpha-specific header was originally needed because of the use of types in the kernel structure (such as uid_t and gid_t) that had different sizes on Alpha, and when glibc was updated for changes to the structure and constants in the kernel 1998-10-02 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/sys/acct.h: Bring in sync with current linux 2.1 version. that simply omitted to do anything about the Alpha version. Thus, remove the Alpha version in order to get the updated definitions into use on Alpha, as I don't think the interfaces are actually different for Alpha with any kernel version supported by glibc. Tested for x86_64, and with build-many-glibcs.py for alpha-linux-gnu.
* alpha: Fix generic brk system call emulation in __brk_call (bug 29490)Florian Weimer2022-08-221-4/+3
| | | | | | | | The kernel special-cases the zero argument for alpha brk, and we can use that to restore the generic Linux error handling behavior. Fixes commit b57ab258c1140bc45464b4b9908713e3e0ee35aa ("Linux: Introduce __brk_call for invoking the brk system call").
* Linux: Fix enum fsconfig_command detection in <sys/mount.h>Florian Weimer2022-08-161-3/+3
| | | | | | | | | The #ifdef FSOPEN_CLOEXEC check did not work because the macro was always defined in this header prior to the check, so that the <linux/mount.h> contents did not matter. Fixes commit 774058d72942249f71d74e7f2b639f77184160a6 ("linux: Fix sys/mount.h usage with kernel headers").
* Move ip_mreqn structure from Linux to genericSamuel Thibault2022-08-151-8/+0
| | | | | | | | I.e. from sysdeps/unix/sysv/linux/bits/in.h to netinet/in.h It is following both the BSD and Linux definitions. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Linux: Terminate subprocess on late failure in tst-pidfd (bug 29485)Florian Weimer2022-08-151-2/+5
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* linux: Fix sys/mount.h usage with kernel headersAdhemerval Zanella2022-08-123-8/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | Now that kernel exports linux/mount.h and includes it on linux/fs.h, its definitions might clash with glibc exports sys/mount.h. To avoid the need to rearrange the Linux header to be always after glibc one, the glibc sys/mount.h is changed to: 1. Undefine the macros also used as enum constants. This covers prior inclusion of <linux/mount.h> (for instance MS_RDONLY). 2. Include <linux/mount.h> based on the usual __has_include check (needs to use __has_include ("linux/mount.h") to paper over GCC bugs. 3. Define enum fsconfig_command only if FSOPEN_CLOEXEC is not defined. (FSOPEN_CLOEXEC should be a very close proxy.) 4. Define struct mount_attr if MOUNT_ATTR_SIZE_VER0 is not defined. (Added in the same commit on the Linux side.) This patch also adds some tests to check if including linux/fs.h and linux/mount.h after and before sys/mount.h does work. Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* linux: Use compile_c_snippet to check linux/mount.h availabilityAdhemerval Zanella2022-08-121-0/+5
| | | | | | Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* linux: Mimic kernel defition for BLOCK_SIZEAdhemerval Zanella2022-08-121-1/+1
| | | | | | | To avoid possible warnings if the kernel header is included before sys/mount.h. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* linux: Use compile_c_snippet to check linux/pidfd.h availabilityAdhemerval Zanella2022-08-121-3/+5
| | | | | | | | Instead of tying to a specific kernel version. Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* LoongArch: Add pointer mangling support.caiyinyu2022-08-121-3/+60
|
* tst-process_madvise: Check process_madvise-syscall support.Stefan Liebler2022-08-111-2/+5
| | | | | | | | | | | | So far this test checks if pidfd_open-syscall is supported, which was introduced with linux 5.3. The process_madvise-syscall was introduced with linux 5.10. Thus you'll get FAILs if you are running a kernel in between. This patch adds a check if the first process_madvise-syscall returns ENOSYS and in this case will fail with UNSUPPORTED. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Remove ldd libc4 supportAdhemerval Zanella2022-08-0412-134/+0
| | | | The older libc versions are obsolete for over twenty years now.
* Assume only FLAG_ELF_LIBC6 suportLucas A. M. Magalhaes2022-08-0412-268/+0
| | | | | | | | | | | The older libc versions are obsolete for over twenty years now. This patch removes the special flags for libc5 and libc4 and assumes that all libraries cached are libc6 compatible and use FLAG_ELF_LIBC6. Checked with a build for all affected architectures. Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Remove left over LD_LIBRARY_VERSION usagesAdhemerval Zanella2022-08-045-11/+0
| | | | | The environment variable was removed by d2db60d8d830ef68c8d20a77ac3572d610aa40b1.
* Linux: Remove exit system call from _exitFlorian Weimer2022-08-041-1/+0
| | | | | | exit only terminates the current thread, not the whole process, so it is the wrong fallback system call in this context. All supported Linux versions implement the exit_group system call anyway.
* LoongArch: Add vdso support for gettimeofday.caiyinyu2022-08-042-0/+23
|
* Update kernel version to 5.19 in header constant testsJoseph Myers2022-08-033-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 5.18. (There are no new constants covered by these tests in 5.19, or in 5.17 or 5.18 in the case of tst-mount-consts.py that previously used version 5.16, that need any other header changes.) Tested with build-many-glibcs.py.
* Update syscall lists for Linux 5.19Joseph Myers2022-08-023-2/+4
| | | | | | | | | Linux 5.19 has no new syscalls, but enables memfd_secret in the uapi headers for RISC-V. Update the version number in syscall-names.list to reflect that it is still current for 5.19 and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
* socket: Check lengths before advancing pointer in CMSG_NXTHDRArjun Shankar2022-08-022-15/+61
| | | | | | | | | | | | | | | | | The inline and library functions that the CMSG_NXTHDR macro may expand to increment the pointer to the header before checking the stride of the increment against available space. Since C only allows incrementing pointers to one past the end of an array, the increment must be done after a length check. This commit fixes that and includes a regression test for CMSG_FIRSTHDR and CMSG_NXTHDR. The Linux, Hurd, and generic headers are all changed. Tested on Linux on armv7hl, i686, x86_64, aarch64, ppc64le, and s390x. [BZ #28846] Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* tst-pidfd.c: UNSUPPORTED if we get EPERM on valid pidfd_getfd callMark Wielaard2022-07-291-0/+7
| | | | | | | | pidfd_getfd can fail for a valid pidfd with errno EPERM for various reasons in a restricted environment. Use FAIL_UNSUPPORTED in that case. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* LoongArch: Add greg_t and gregset_t.caiyinyu2022-07-291-0/+3
|
* LoongArch: Fix VDSO_HASH and VDSO_NAME.caiyinyu2022-07-291-2/+2
|
* arc4random: simplify design for better safetyJason A. Donenfeld2022-07-273-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than buffering 16 MiB of entropy in userspace (by way of chacha20), simply call getrandom() every time. This approach is doubtlessly slower, for now, but trying to prematurely optimize arc4random appears to be leading toward all sorts of nasty properties and gotchas. Instead, this patch takes a much more conservative approach. The interface is added as a basic loop wrapper around getrandom(), and then later, the kernel and libc together can work together on optimizing that. This prevents numerous issues in which userspace is unaware of when it really must throw away its buffer, since we avoid buffering all together. Future improvements may include userspace learning more from the kernel about when to do that, which might make these sorts of chacha20-based optimizations more possible. The current heuristic of 16 MiB is meaningless garbage that doesn't correspond to anything the kernel might know about. So for now, let's just do something conservative that we know is correct and won't lead to cryptographic issues for users of this function. This patch might be considered along the lines of, "optimization is the root of all evil," in that the much more complex implementation it replaces moves too fast without considering security implications, whereas the incremental approach done here is a much safer way of going about things. Once this lands, we can take our time in optimizing this properly using new interplay between the kernel and userspace. getrandom(0) is used, since that's the one that ensures the bytes returned are cryptographically secure. But on systems without it, we fallback to using /dev/urandom. This is unfortunate because it means opening a file descriptor, but there's not much of a choice. Secondly, as part of the fallback, in order to get more or less the same properties of getrandom(0), we poll on /dev/random, and if the poll succeeds at least once, then we assume the RNG is initialized. This is a rough approximation, as the ancient "non-blocking pool" initialized after the "blocking pool", not before, and it may not port back to all ancient kernels, though it does to all kernels supported by glibc (≥3.2), so generally it's the best approximation we can do. The motivation for including arc4random, in the first place, is to have source-level compatibility with existing code. That means this patch doesn't attempt to litigate the interface itself. It does, however, choose a conservative approach for implementing it. Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> Cc: Florian Weimer <fweimer@redhat.com> Cc: Cristian Rodríguez <crrodriguez@opensuse.org> Cc: Paul Eggert <eggert@cs.ucla.edu> Cc: Mark Harris <mark.hsj@gmail.com> Cc: Eric Biggers <ebiggers@kernel.org> Cc: linux-crypto@vger.kernel.org Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* LoongArch: Build Infrastructurecaiyinyu2022-07-267-0/+211
|
* LoongArch: Add ABI Listscaiyinyu2022-07-2611-0/+3385
|
* LoongArch: Linux ABIcaiyinyu2022-07-2614-0/+710
|
* LoongArch: Linux Syscall Interfacecaiyinyu2022-07-266-0/+903
|
* LoongArch: Atomic and Locking Routinescaiyinyu2022-07-261-0/+147
|
* struct stat is not posix conformant on microblaze with __USE_FILE_OFFSET64Arnout Vandecappelle (Essensium/Mind)2022-07-251-1/+1
| | | | | | | | | | | Commit a06b40cdf5ba0d2ab4f9b4c77d21e45ff284fac7 updated stat.h to use __USE_XOPEN2K8 instead of __USE_MISC to add the st_atim, st_mtim and st_ctim members to struct stat. However, for microblaze, there are two definitions of struct stat, depending on the __USE_FILE_OFFSET64 macro. The second one was not updated. Change __USE_MISC to __USE_XOPEN2K8 in the __USE_FILE_OFFSET64 version of struct stat for microblaze.
* Linux: dirent/tst-readdir64-compat needs to use TEST_COMPAT (bug 27654)Florian Weimer2022-07-252-6/+8
| | | | | | | | | | | The hppa port starts libc at GLIBC_2.2, but has earlier symbol versions in other shared objects. This means that the compat symbol for readdir64 is not actually present in libc even though have-GLIBC_2.1.3 is defined as yes at the make level. Fixes commit 15e50e6c966fa0f26612602a95f0129543d9f9d5 ("Linux: dirent/tst-readdir64-compat can be a regular test") by mostly reverting it.
* stdlib: Add arc4random, arc4random_buf, and arc4random_uniform (BZ #4417)Adhemerval Zanella Netto2022-07-2236-7/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation is based on scalar Chacha20 with per-thread cache. It uses getrandom or /dev/urandom as fallback to get the initial entropy, and reseeds the internal state on every 16MB of consumed buffer. To improve performance and lower memory consumption the per-thread cache is allocated lazily on first arc4random functions call, and if the memory allocation fails getentropy or /dev/urandom is used as fallback. The cache is also cleared on thread exit iff it was initialized (so if arc4random is not called it is not touched). Although it is lock-free, arc4random is still not async-signal-safe (the per thread state is not updated atomically). The ChaCha20 implementation is based on RFC8439 [1], omitting the final XOR of the keystream with the plaintext because the plaintext is a stream of zeros. This strategy is similar to what OpenBSD arc4random does. The arc4random_uniform is based on previous work by Florian Weimer, where the algorithm is based on Jérémie Lumbroso paper Optimal Discrete Uniform Generation from Coin Flips, and Applications (2013) [2], who credits Donald E. Knuth and Andrew C. Yao, The complexity of nonuniform random number generation (1976), for solving the general case. The main advantage of this method is the that the unit of randomness is not the uniform random variable (uint32_t), but a random bit. It optimizes the internal buffer sampling by initially consuming a 32-bit random variable and then sampling byte per byte. Depending of the upper bound requested, it might lead to better CPU utilization. Checked on x86_64-linux-gnu, aarch64-linux, and powerpc64le-linux-gnu. Co-authored-by: Florian Weimer <fweimer@redhat.com> Reviewed-by: Yann Droneaud <ydroneaud@opteya.com> [1] https://datatracker.ietf.org/doc/html/rfc8439 [2] https://arxiv.org/pdf/1304.1916.pdf
* linux: return UNSUPPORTED from tst-mount if entering mount namespace failsMichael Hudson-Doyle2022-07-191-19/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this the test fails if run in a chroot by a non-root user: warning: could not become root outside namespace (Operation not permitted) ../sysdeps/unix/sysv/linux/tst-mount.c:36: numeric comparison failure left: 1 (0x1); from: errno right: 19 (0x13); from: ENODEV error: ../sysdeps/unix/sysv/linux/tst-mount.c:39: not true: fd != -1 error: ../sysdeps/unix/sysv/linux/tst-mount.c:46: not true: r != -1 error: ../sysdeps/unix/sysv/linux/tst-mount.c:48: not true: r != -1 ../sysdeps/unix/sysv/linux/tst-mount.c:52: numeric comparison failure left: 1 (0x1); from: errno right: 9 (0x9); from: EBADF error: ../sysdeps/unix/sysv/linux/tst-mount.c:55: not true: mfd != -1 ../sysdeps/unix/sysv/linux/tst-mount.c:58: numeric comparison failure left: 1 (0x1); from: errno right: 2 (0x2); from: ENOENT error: ../sysdeps/unix/sysv/linux/tst-mount.c:61: not true: r != -1 ../sysdeps/unix/sysv/linux/tst-mount.c:65: numeric comparison failure left: 1 (0x1); from: errno right: 2 (0x2); from: ENOENT error: ../sysdeps/unix/sysv/linux/tst-mount.c:68: not true: pfd != -1 error: ../sysdeps/unix/sysv/linux/tst-mount.c:75: not true: fd_tree != -1 ../sysdeps/unix/sysv/linux/tst-mount.c:88: numeric comparison failure left: 1 (0x1); from: errno right: 38 (0x26); from: ENOSYS error: 12 test failures Checking that the test can enter a new mount namespace is more correct than just checking the return value of support_become_root() as the test code changes the mount namespace it runs in so running it as root on a system that does not support mount namespaces should still skip. Also change the test to remove the unnecessary fork. Reviewed-by: Carlos O'Donell <carlos@redhat.com>