aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
AgeCommit message (Collapse)AuthorFilesLines
2022-03-23Update syscall lists for Linux 5.17Joseph Myers27-2/+29
Linux 5.17 has one new syscall, set_mempolicy_home_node. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
2022-03-23Fix ununsed fstatat64_time64_statxAdhemerval Zanella1-5/+5
It is only called for legacy ABIs.
2022-03-15hppa: Use END instead of PSEUDO_END in swapcontext.SJohn David Anglin1-1/+1
2022-03-15hppa: Implement swapcontext in assembler (bug 28960)John David Anglin2-82/+72
When swapcontext.c is compiled without -g, the following error occurs: Error: CFI instruction used without previous .cfi_startproc Fix by converting swapcontext routine to assembler.
2022-03-14Add access function attributes to epoll_waitSteve Grubb1-4/+8
This patch adds write access function attributes to the epoll_wait family of functions Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-03-03i386: Remove libc-do-syscall from sysdep-dl-routines [BZ #28936]H.J. Lu1-1/+0
Remove libc-do-syscall from sysdep-dl-routines added by: commit 3b33d6ed6096c1d20d05a650b06026d673f7399a Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Sun Jan 8 11:38:23 2017 -0200 Rework -fno-omit-frame-pointer support on i386 and use auto-generated io/rtld-libc-do-syscall.os instead. This fixes BZ #28936.
2022-03-03linux/i386: remove dead assignment of sysdep-dl-routinesAndreas Schwab1-1/+0
The variable sysdep-dl-routines has only an effect in the elf subdir.
2022-02-28Linux: Consolidate auxiliary vector parsing (redo)Florian Weimer5-107/+104
And optimize it slightly. This is commit 8c8510ab2790039e58995ef3a22309582413d3ff revised. In _dl_aux_init in elf/dl-support.c, use an explicit loop and -fno-tree-loop-distribute-patterns to avoid memset. Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2022-02-25build: Properly generate .d dependency files [BZ #28922]H.J. Lu1-0/+3
1. Also generate .d dependency files for $(tests-container) and $(tests-printers). 2. elf: Add tst-auditmod17.os to extra-test-objs. 3. iconv: Add tst-gconv-init-failure-mod.os to extra-test-objs. 4. malloc: Rename extra-tests-objs to extra-test-objs. 5. linux: Add tst-sysconf-iov_max-uapi.o to extra-test-objs. 6. x86_64: Add tst-x86_64mod-1.o, tst-platformmod-2.o, test-libmvec.o, test-libmvec-avx.o, test-libmvec-avx2.o and test-libmvec-avx512f.o to extra-test-objs. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-02-22hppa: Revise gettext trampoline designJohn David Anglin3-31/+35
The current getcontext return trampoline is overly complex and it unnecessarily clobbers several registers. By saving the context pointer (r26) in the context, __getcontext_ret can restore any registers not restored by setcontext. This allows getcontext to save and restore the entire register context present when getcontext is entered. We use the unused oR0 context slot for the return from __getcontext_ret. While this is not directly useful in C, it can be exploited in assembly code. Registers r20, r23, r24 and r25 are not clobbered in the call path to getcontext. This allows a small simplification of swapcontext. It also allows saving and restoring the 6-bit SAR register in the LSB of the oSAR context slot. The getcontext flag value can be stored in the MSB of the oSAR slot.
2022-02-21Add SOL_MPTCP, SOL_MCTP from Linux 5.16 to bits/socket.hJoseph Myers1-0/+2
Linux 5.16 adds constants SOL_MPTCP and SOL_MCTP to the getsockopt / setsockopt levels; add these constants to bits/socket.h. Tested for x86_64.
2022-02-18hppa: Fix swapcontextJohn David Anglin3-7/+58
This change fixes the failure of stdlib/tst-setcontext2 and stdlib/tst-setcontext7 on hppa. The implementation of swapcontext in C is broken. C saves the return pointer (rp) and any non call-clobbered registers (in this case r3, r4 and r5) on the stack. However, the setcontext call in swapcontext pops the stack and subsequent calls clobber the saved registers. When the context in oucp is restored, both tests fault. Here we rewrite swapcontext in assembly code to avoid using the stack for register values that need to be used after restoration. The getcontext and setcontext routines are revised to save and restore register ret1 for normal returns. We copy the oucp pointer to ret1. This allows access to the old context after calling getcontext and setcontext.
2022-02-16microblaze: Use the correct select syscall (BZ #28883)Adhemerval Zanella1-1/+1
On Microblaze only __NR_newselect is implemented, even though kernel advertise __NR_select on asm/unistd.h. Since microblaze is the only architecture that undef __ASSUME_PSELECT, the generic code change is simpler than chaging the architecture syscall number. Acked-by: Mark Hatle <mark.hatle@xilinx.com>
2022-02-16Update kernel version to 5.16 in tst-mman-consts.pyJoseph Myers1-1/+1
This patch updates the kernel version in the test tst-mman-consts.py to 5.16. (There are no new MAP_* constants covered by this test in 5.16 that need any other header changes.) Tested with build-many-glibcs.py.
2022-02-14linux: Use socket-constants-time64.h on tst-socket-timestamp-compatAdhemerval Zanella1-12/+13
The kernel header might not define the SO_TIMESTAMP{NS}_OLD or SO_TIMESTAMP{NS}_NEW if it older than v5.1. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2022-02-11Linux: Include <dl-auxv.h> in dl-sysdep.c only for SHAREDFlorian Weimer1-1/+2
Otherwise, <dl-auxv.h> on POWER ends up being included twice, once in dl-sysdep.c, once in dl-support.c. That leads to a linker failure due to multiple definitions of _dl_cache_line_size. Fixes commit d96d2995c1121d3310102afda2deb1f35761b5e6 ("Revert "Linux: Consolidate auxiliary vector parsing").
2022-02-11Revert "Linux: Consolidate auxiliary vector parsing"Florian Weimer5-102/+104
This reverts commit 8c8510ab2790039e58995ef3a22309582413d3ff. The revert is not perfect because the commit included a bug fix for _dl_sysdep_start with an empty argv, introduced in commit 2d47fa68628e831a692cba8fc9050cef435afc5e ("Linux: Remove DL_FIND_ARG_COMPONENTS"), and this bug fix is kept. The revert is necessary because the reverted commit introduced an early memset call on aarch64, which leads to crash due to lack of TCB initialization.
2022-02-10Linux: Consolidate auxiliary vector parsingFlorian Weimer5-105/+103
And optimize it slightly. The large switch statement in _dl_sysdep_start can be replaced with a large array. This reduces source code and binary size. On i686-linux-gnu: Before: text data bss dec hex filename 7791 12 0 7803 1e7b elf/dl-sysdep.os After: text data bss dec hex filename 7135 12 0 7147 1beb elf/dl-sysdep.os Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-02-10Linux: Assume that NEED_DL_SYSINFO_DSO is always definedFlorian Weimer2-9/+3
The definition itself is still needed for generic code. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-02-10Linux: Remove DL_FIND_ARG_COMPONENTSFlorian Weimer1-15/+10
The generic definition is always used since the Native Client port has been removed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-02-10Linux: Remove HAVE_AUX_SECURE, HAVE_AUX_XID, HAVE_AUX_PAGESIZEFlorian Weimer2-66/+1
They are always defined. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-02-10elf: Merge dl-sysdep.c into the Linux versionFlorian Weimer1-12/+335
The generic version is the de-facto Linux implementation. It requires an auxiliary vector, so Hurd does not use it. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-02-07linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865]Dmitry V. Levin1-31/+63
get_nprocs() and get_nprocs_conf() use various methods to obtain an accurate number of processors. Re-introduce __get_nprocs_sched() as a source of information, and fix the order in which these methods are used to return the most accurate information. The primary source of information used in both functions remains unchanged. This also changes __get_nprocs_sched() error return value from 2 to 0, but all its users are already prepared to handle that. Old fallback order: get_nprocs: /sys/devices/system/cpu/online -> /proc/stat -> 2 get_nprocs_conf: /sys/devices/system/cpu/ -> /proc/stat -> 2 New fallback order: get_nprocs: /sys/devices/system/cpu/online -> /proc/stat -> sched_getaffinity -> 2 get_nprocs_conf: /sys/devices/system/cpu/ -> /proc/stat -> sched_getaffinity -> 2 Fixes: 342298278e ("linux: Revert the use of sched_getaffinity on get_nproc") Closes: BZ #28865 Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-02-03linux: Fix missing __convert_scm_timestamps (BZ #28860)Adhemerval Zanella1-2/+2
Commit 948ce73b31 made recvmsg/recvmmsg to always call __convert_scm_timestamps for 64 bit time_t symbol, so adjust it to always build it for __TIMESIZE != 64. It fixes build for architecture with 32 bit time_t support when configured with minimum kernel of 5.1.
2022-02-03linux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage [BZ #28850]Gleb Fotengauer-Malinovskiy1-1/+1
Pass the actual number of bytes returned by the kernel. Fixes: 33099d72e41c ("linux: Simplify get_nprocs") Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
2022-02-03Regenerate configure.Carlos O'Donell1-1/+7
2022-02-02Linux: Use ptrdiff_t for __rseq_offsetFlorian Weimer11-11/+12
This matches the data size initial-exec relocations use on most targets. Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-02-02posix: Replace posix_spawnattr_tc{get,set}pgrp_np with ↵Adhemerval Zanella34-77/+43
posix_spawn_file_actions_addtcsetpgrp_np The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the controlling terminal), so it would make more sense to actually fit it on the file actions API. Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is implicit by the presence of tcsetpgrp file action. The posix/tst-spawn6.c is also fixed when TTY can is not present. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2022-01-29tst-socket-timestamp-compat.c: Check __TIMESIZE [BZ #28837]H.J. Lu1-1/+1
time_t size is defined by __TIMESIZE, not __WORDSIZE. Check __TIMESIZE, instead of __WORDSIZE, for time_t size. This fixes BZ #28837.
2022-01-28Linux: Only generate 64 bit timestamps for 64 bit time_t recvmsg/recvmmsgAdhemerval Zanella5-24/+322
The timestamps created by __convert_scm_timestamps only make sense for 64 bit time_t programs, 32 bit time_t programs will ignore 64 bit time_t timestamps since SO_TIMESTAMP will be defined to old values (either by glibc or kernel headers). Worse, if the buffer is not suffice MSG_CTRUNC is set to indicate it (which breaks some programs [1]). This patch makes only 64 bit time_t recvmsg and recvmmsg to call __convert_scm_timestamps. Also, the assumption to called it is changed from __ASSUME_TIME64_SYSCALLS to __TIMESIZE != 64 since the setsockopt might be called by libraries built without __TIME_BITS=64. The MSG_CTRUNC is only set for the 64 bit symbols, it should happen only if 64 bit time_t programs run older kernels. Checked on x86_64-linux-gnu and i686-linux-gnu. [1] https://github.com/systemd/systemd/pull/20567 Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-01-28linux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ#28350)Adhemerval Zanella4-6/+348
The __convert_scm_timestamps only updates the control message last pointer for SOL_SOCKET type, so if the message control buffer contains multiple ancillary message types the converted timestamp one might overwrite a valid message. The test checks if the extra ancillary space is correctly handled by recvmsg/recvmmsg, where if there is no extra space for the 64-bit time_t converted message the control buffer should be marked with MSG_TRUNC. It also check if recvmsg/recvmmsg handle correctly multiple ancillary data. Checked on x86_64-linux and on i686-linux-gnu on both 5.11 and 4.15 kernel. Co-authored-by: Fabian Vogt <fvogt@suse.de> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-01-27Fix glibc 2.34 ABI omission (missing GLIBC_2.34 in dynamic loader)Florian Weimer29-0/+29
The glibc 2.34 release really should have added a GLIBC_2.34 symbol to the dynamic loader. With it, we could move functions such as dlopen or pthread_key_create that work on process-global state into the dynamic loader (once we have fixed a longstanding issue with static linking). Without the GLIBC_2.34 symbol, yet another new symbol version would be needed because old glibc will fail to load binaries due to the missing symbol version in ld.so that newly linked programs will require. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2022-01-25posix: Add terminal control setting support for posix_spawnAdhemerval Zanella35-1/+80
Currently there is no proper way to set the controlling terminal through posix_spawn in race free manner [1]. This forces shell implementations to keep using fork+exec when launching background process groups, even when using posix_spawn yields better performance. This patch adds a new GNU extension so the creating process can configure the created process terminal group. This is done with a new flag, POSIX_SPAWN_TCSETPGROUP, along with two new attribute functions: posix_spawnattr_tcsetpgrp_np, and posix_spawnattr_tcgetpgrp_np. The function sets a new attribute, spawn-tcgroupfd, that references to the controlling terminal. The controlling terminal is set after the spawn-pgroup attribute, and uses the spawn-tcgroupfd along with current creating process group (so it is composable with POSIX_SPAWN_SETPGROUP). To create a process and set the controlling terminal, one can use the following sequence: posix_spawnattr_t attr; posix_spawnattr_init (&attr); posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP); posix_spawnattr_tcsetpgrp_np (&attr, tcfd); If the idea is also to create a new process groups: posix_spawnattr_t attr; posix_spawnattr_init (&attr); posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP | POSIX_SPAWN_SETPGROUP); posix_spawnattr_tcsetpgrp_np (&attr, tcfd); posix_spawnattr_setpgroup (&attr, 0); The controlling terminal file descriptor is ignored if the new flag is not set. This interface is slight different than the one provided by QNX [2], which only provides the POSIX_SPAWN_TCSETPGROUP flag. The QNX documentation does not specify how the controlling terminal is obtained nor how it iteracts with POSIX_SPAWN_SETPGROUP. Since a glibc implementation is library based, it is more straightforward and avoid requires additional file descriptor operations to request the caller to setup the controlling terminal file descriptor (and it also allows a bit less error handling by posix_spawn). Checked on x86_64-linux-gnu and i686-linux-gnu. [1] https://github.com/ksh93/ksh/issues/79 [2] https://www.qnx.com/developers/docs/7.0.0/index.html#com.qnx.doc.neutrino.lib_ref/topic/p/posix_spawn.html Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2022-01-24Linux: Detect user namespace support in io/tst-getcwd-smallbuffFlorian Weimer1-0/+18
Otherwise the test fails with certain container runtimes. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-01-24getcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999)Siddhesh Poyarekar2-1/+247
No valid path returned by getcwd would fit into 1 byte, so reject the size early and return NULL with errno set to ERANGE. This change is prompted by CVE-2021-3999, which describes a single byte buffer underflow and overflow when all of the following conditions are met: - The buffer size (i.e. the second argument of getcwd) is 1 byte - The current working directory is too long - '/' is also mounted on the current working directory Sequence of events: - In sysdeps/unix/sysv/linux/getcwd.c, the syscall returns ENAMETOOLONG because the linux kernel checks for name length before it checks buffer size - The code falls back to the generic getcwd in sysdeps/posix - In the generic func, the buf[0] is set to '\0' on line 250 - this while loop on line 262 is bypassed: while (!(thisdev == rootdev && thisino == rootino)) since the rootfs (/) is bind mounted onto the directory and the flow goes on to line 449, where it puts a '/' in the byte before the buffer. - Finally on line 458, it moves 2 bytes (the underflowed byte and the '\0') to the buf[0] and buf[1], resulting in a 1 byte buffer overflow. - buf is returned on line 469 and errno is not set. This resolves BZ #28769. Reviewed-by: Andreas Schwab <schwab@linux-m68k.org> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Qualys Security Advisory <qsa@qualys.com> Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-01-17Linux: Add epoll_pwait2 (BZ #27359)Adhemerval Zanella39-1/+338
It is similar to epoll_wait, with the difference the timeout has nanosecond resoluting by using struct timespec instead of int. Although Linux interface only provides 64 bit time_t support, old 32 bit interface is also provided (so keep in sync with current practice and to no force opt-in on 64 bit time_t). Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-01-13Update syscall lists for Linux 5.16Joseph Myers27-2/+29
Linux 5.16 has one new syscall, futex_waitv. Update syscall-names.list and regenerate the arch-syscall.h headers with build-many-glibcs.py update-syscalls. Tested with build-many-glibcs.py.
2022-01-13i386: Remove broken CAN_USE_REGISTER_ASM_EBP (bug 28771)Florian Weimer3-251/+27
The configure check for CAN_USE_REGISTER_ASM_EBP tried to compile a simple function that uses %ebp as an inline assembly operand. If compilation failed, CAN_USE_REGISTER_ASM_EBP was set 0, which eventually had these consequences: (1) %ebx was avoided as an inline assembly operand, with an assembler macro hack to avoid unnecessary register moves. (2) %ebp was avoided as an inline assembly operand, using an out-of-line syscall function for 6-argument system calls. (1) is no longer needed for any GCC version that is supported for building glibc. %ebx can be used directly as a register operand. Therefore, this commit removes the %ebx avoidance completely. This avoids the assembler macro hack, which turns out to be incompatible with the current Systemtap probe macros (which switch to .altmacro unconditionally). (2) is still needed in many build configurations. The existing configure check cannot really capture that because the simple function succeeds to compile, while the full glibc build still fails. Therefore, this commit removes the check, the CAN_USE_REGISTER_ASM_EBP macro, and uses the out-of-line syscall function for 6-argument system calls unconditionally. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2022-01-12Revert "linux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ ↵Adhemerval Zanella4-354/+5
#28350)" This reverts commit 21e0f45c7d73df6fe30c77ffcc9f81410e2ee369.
2022-01-12linux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ #28350)Adhemerval Zanella4-5/+354
The __convert_scm_timestamps() only updates the control message last pointer for SOL_SOCKET type, so if the message control buffer contains multiple ancillary message types the converted timestamp one might overwrite a valid message. The test check if the extra ancillary space is correctly handled by recvmsg/recvmmsg, where if there is no extra space for the 64-bit time_t converted message the control buffer should be marked with MSG_TRUNC. It also check if recvmsg/recvmmsg handle correctly multiple ancillary data. Checked on x86_64-linux and on i686-linux-gnu on both 5.11 and 4.15 kernel. Co-authored-by: Fabian Vogt <fvogt@suse.de>
2022-01-11aarch64: Add HWCAP2_ECV from Linux 5.16Szabolcs Nagy1-0/+1
Indicates the availability of enhanced counter virtualization extension of armv8.6-a with self-synchronized virtual counter CNTVCTSS_EL0 usable in userspace.
2022-01-06debug: Remove catchsegv and libSegfault (BZ #14913)Adhemerval Zanella15-2837/+0
Trapping SIGSEGV within the process is error-prone, adds security issues, and modern analysis design tends to happen out of the process (either by attaching a debugger or by post-mortem analysis). The libSegfault also has some design problems, it uses non async-signal-safe function (backtrace) on signal handler. There are multiple alternatives if users do want to use similar functionality, such as sigsegv gnulib module or libsegfault.
2022-01-05or1k: Build InfrastructureStafford Horne5-0/+20
Here we define the minumum linux kernel version at 5.4.0, as that is the long term support version where 32-bit architectures start to support 64-bit time API's. The OpenRISC kernel had some bugs up until version 5.8 which caused issues with glibc fork/clone, they have been backported to 5.4 but not previous versions. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-01-05or1k: ABI listsStafford Horne10-0/+3095
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-01-05or1k: Linux ABIStafford Horne9-0/+519
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-01-05or1k: Linux Syscall InterfaceStafford Horne6-0/+738
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-01-05linux/syscalls: Add or1k_atomic syscall for OpenRISCStafford Horne1-0/+1
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-01-01Update copyright dates not handled by scripts/update-copyrights.Paul Eggert1-1/+1
I've updated copyright dates in glibc for 2022. This is the patch for the changes not generated by scripts/update-copyrights and subsequent build / regeneration of generated files. As well as the usual annual updates, mainly dates in --version output (minus csu/version.c which previously had to be handled manually but is now successfully updated by update-copyrights), there is a small change to the copyright notice in NEWS which should let NEWS get updated automatically next year. Please remember to include 2022 in the dates for any new files added in future (which means updating any existing uncommitted patches you have that add new files to use the new copyright dates in them).
2022-01-01Update copyright dates with scripts/update-copyrightsPaul Eggert1529-1530/+1529
I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 7061 files FOO. I then removed trailing white space from math/tgmath.h, support/tst-support-open-dev-null-range.c, and sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following obscure pre-commit check failure diagnostics from Savannah. I don't know why I run into these diagnostics whereas others evidently do not. remote: *** 912-#endif remote: *** 913: remote: *** 914- remote: *** error: lines with trailing whitespace found ... remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
2021-12-31time: Refactor timesize.h for some ABIsAdhemerval Zanella4-11/+15
Commit a4b413135535c83a changed default __TIMESIZE to 64, however it added sub-architecture timesize.h for powerpc, s390, and sparc. Also simplify mips by removing _MIPS_SIM usage (which would require to add sgidefs inclusion.