aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
AgeCommit message (Collapse)Author
2022-05-16linux: Use /sys/devices/system/cpu on __get_nprocs_conf (BZ#28991)Adhemerval Zanella
Currently on Linux __get_nprocs_conf first tries to enumerate the cpus present in the system by iterating on /sys/devices/system/cpuX directories. This only enumerates the CPUs that are present in system (but possibly offline), not taking in account possible CPU that might added in the system through hotplugging. Linux provides the maximum number of configured cpus on the /sys/devices/system/cpu file. Although it might present a larger value of possible active CPUs on some system (where kernel either get the information from firmaware or is configured at boot time), the information is what kernel presents to userland. This also change the returned value of _SC_NPROCESSORS_CONF, which aligns as the maximum configure cpu in the system. Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-05-16csu: Implement and use _dl_early_allocate during static startupFlorian Weimer
This implements mmap fallback for a brk failure during TLS allocation. scripts/tls-elf-edit.py is updated to support the new patching method. The script no longer requires that in the input object is of ET_DYN type. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-05-16Linux: Introduce __brk_call for invoking the brk system callFlorian Weimer
Alpha and sparc can now use the generic implementation. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-05-13stdio: Remove the usage of $(fno-unit-at-a-time) for siglist.cAdhemerval Zanella
The siglist.c is built with -fno-toplevel-reorder to avoid compiler to reorder the compat assembly directives due an assembler issue [1] (fixed on 2.39). This patch removes the compiler flags by split the compat symbol generation in two phases. First the __sys_siglist and __sys_sigabbrev without any compat symbol directive is preprocessed to generate an assembly source code. This generate assembly is then used as input on a platform agnostic siglist.S which then creates the compat definitions. This prevents compiler to move any compat directive prior the _sys_errlist definition itself. Checked on a make check run-built-tests=no on all affected ABIs. Reviewed-by: Fangrui Song <maskray@google.com>
2022-05-13stdio: Remove the usage of $(fno-unit-at-a-time) for errlist.cAdhemerval Zanella
The errlist.c is built with -fno-toplevel-reorder to avoid compiler to reorder the compat assembly directives due an assembler issue [1] (fixed on 2.39). This patch removes the compiler flags by split the compat symbol generation in two phases. First the _sys_errlist_internal internal without any compat symbol directive is preprocessed to generate an assembly source code. This generate assembly is then used as input on a platform agnostic errlist-data.S which then creates the compat definitions. This prevents compiler to move any compat directive prior the _sys_errlist_internal definition itself. Checked on a make check run-built-tests=no on all affected ABIs. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=29012
2022-05-09Linux: Implement a useful version of _startup_fatalFlorian Weimer
On i386 and ia64, the TCB is not available at this point. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-05-09ia64: Always define IA64_USE_NEW_STUB as a flag macroFlorian Weimer
And keep the previous definition if it exists. This allows disabling IA64_USE_NEW_STUB while keeping USE_DL_SYSINFO defined. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-05-06linux: Fix posix_spawn return code if clone fails (BZ#29109)Adhemerval Zanella
The __clone_internal returns the error on errno. Checked on x86_64-linux-gnu.
2022-05-05clock_adjtime: Use __nonnull to avoid null pointerXiaoming Ni
clock_adjtime()/clock_adjtime64() Add __nonnull((2)) to avoid null pointer access. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662 Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-05-05ntp_xxxtimex: Use __nonnull to avoid null pointerXiaoming Ni
ntp_gettime() ntp_gettime64() ntp_gettimex() ntp_gettimex64() ntp_adjtime() Add __nonnull((1)) to avoid null pointer access. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662 Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-05-05adjtimex/adjtimex64: Use __nonnull to avoid null pointerXiaoming Ni
Add __nonnull((1)) to the adjtimex()/adjtimex64() function declaration to avoid null pointer access. Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662 Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084 Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-05-04Linux: Define MMAP_CALL_INTERNALFlorian Weimer
Unlike MMAP_CALL, this avoids a TCB dependency for an errno update on failure. <mmap_internal.h> cannot be included as is on several architectures due to the definition of page_unit, so introduce a separate header file for the definition of MMAP_CALL and MMAP_CALL_INTERNAL, <mmap_call.h>. Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
2022-05-04i386: Honor I386_USE_SYSENTER for 6-argument Linux system callsFlorian Weimer
Introduce an int-80h-based version of __libc_do_syscall and use it if I386_USE_SYSENTER is defined as 0. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2022-05-04i386: Remove OPTIMIZE_FOR_GCC_5 from Linux libc-do-syscall.SFlorian Weimer
After commit a78e6a10d0b50d0ca80309775980fc99944b1727 ("i386: Remove broken CAN_USE_REGISTER_ASM_EBP (bug 28771)"), it is never defined. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2022-04-28linux: Fix fchmodat with AT_SYMLINK_NOFOLLOW for 64 bit time_t (BZ#29097)Adhemerval Zanella
The AT_SYMLINK_NOFOLLOW emulation ues the default 32 bit stat internal calls, which fails with EOVERFLOW if the file constains timestamps beyond 2038. Checked on i686-linux-gnu.
2022-04-27posix/glob.c: update from gnulibDJ Delorie
Copied from gnulib/lib/glob.c in order to fix rhbz 1982608 Also fixes swbz 25659 Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2022-04-27linux: Fix missing internal 64 bit time_t stat usageAdhemerval Zanella
These are two missing spots initially done by 52a5fe70a2c77935. Checked on i686-linux-gnu.
2022-04-22Default to --with-default-link=no (bug 25812)Florian Weimer
This is necessary to place the libio vtables into the RELRO segment. New tests elf/tst-relro-ldso and elf/tst-relro-libc are added to verify that this is what actually happens. The new tests fail on ia64 due to lack of (default) RELRO support inbutils, so they are XFAILed there.
2022-04-19elf: Remove __libc_init_secureFangrui Song
After 73fc4e28b9464f0e13edc719a5372839970e7ddb, __libc_enable_secure_decided is always 0 and a statically linked executable may overwrite __libc_enable_secure without considering AT_SECURE. The __libc_enable_secure has been correctly initialized in _dl_aux_init, so just remove __libc_enable_secure_decided and __libc_init_secure. This allows us to remove some startup_get*id functions from 22b79ed7f413cd980a7af0cf258da5bf82b6d5e5. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-04-18mips: Fix mips64n32 64 bit time_t stat support (BZ#29069)=Joshua Kinard
Add missing support initially added by 4e8521333bea6e89fcef1020 (which missed n32 stat).
2022-04-13Replace {u}int_fast{16|32} with {u}int32_tNoah Goldstein
On 32-bit machines this has no affect. On 64-bit machines {u}int_fast{16|32} are set as {u}int64_t which is often not ideal. Particularly x86_64 this change both saves code size and may save instruction cost. Full xcheck passes on x86_64.
2022-04-10powerpc: Relocate stinfo->mainAlan Modra
start_addresses in sysdeps/powerpc/powerpc64/start.S is historical baggage that should disappear. Until someone does that, relocating stinfo->main by hand is one solution to the fact that the field may be unrelocated at the time it is accessed. This is similar to what is done for dynamic tags via the D_PTR macro. stinfo->init and stinfo->fini are zero in both powerpc64/start.S and powerpc32/start.S, so make it a little more obvious they are unused by passing NULLs to LIBC_START_MAIN. The makefile change is needed to pick up elf/dl-static-tls.h from dl-machine.h. Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2022-04-10linux: Constify rfv variable in dl_vdso_vsymAlan Modra
Compilers may decide to put the rfv variable in .data rather than on the stack. It's slightly better to put it in .data.rel.ro.local instead. Regardles of that, making it const may enable further optimisations. Found when examining relative relocations (GOT ones in particular) as part of enabling static-pie for PowerPC64.
2022-04-05linux: Fix __closefrom_fallback iterates until max int (BZ#28993)Adhemerval Zanella
The __closefrom_fallback tries to get a available file descriptor if the initial open ("/proc/self/fd/", ...) fails. It assumes the failure would be only if procfs is not mount (ENOENT), however if the the proc file is not accessible (due some other kernel filtering such apparmor) it will iterate over a potentially large file set issuing close calls. It should only try the close fallback if open returns EMFILE, ENFILE, or ENOMEM. Checked on x86_64-linux-gnu.
2022-03-28Add HWCAP2_AFP, HWCAP2_RPRES from Linux 5.17 to AArch64 bits/hwcap.hJoseph Myers
Add the new HWCAP2_AFP and HWCAP2_RPRES constants from Linux 5.17. Tested with build-many-glibcs.py for aarch64-linux-gnu.
2022-03-24Update kernel version to 5.17 in tst-mman-consts.pyJoseph Myers
This patch updates the kernel version in the test tst-mman-consts.py to 5.17. (There are no new MAP_* constants covered by this test in 5.17 that need any other header changes.) Tested with build-many-glibcs.py.
2022-03-23Update syscall lists for Linux 5.17Joseph Myers
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 Zanella
It is only called for legacy ABIs.
2022-03-15hppa: Use END instead of PSEUDO_END in swapcontext.SJohn David Anglin
2022-03-15hppa: Implement swapcontext in assembler (bug 28960)John David Anglin
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 Grubb
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. Lu
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 Schwab
The variable sysdep-dl-routines has only an effect in the elf subdir.
2022-02-28Linux: Consolidate auxiliary vector parsing (redo)Florian Weimer
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. Lu
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 Anglin
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 Myers
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 Anglin
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 Zanella
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 Myers
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 Zanella
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 Weimer
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 Weimer
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 Weimer
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 Weimer
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 Weimer
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 Weimer
They are always defined. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2022-02-10elf: Merge dl-sysdep.c into the Linux versionFlorian Weimer
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. Levin
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 Zanella
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.