aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/mach
AgeCommit message (Collapse)AuthorFilesLines
2021-05-06Annotate additional APIs with GCC attribute access.Martin Sebor1-1/+1
This change continues the improvements to compile-time out of bounds checking by decorating more APIs with either attribute access, or by explicitly providing the array bound in APIs such as tmpnam() that expect arrays of some minimum size as arguments. (The latter feature is new in GCC 11.) The only effects of the attribute and/or the array bound is to check and diagnose calls to the functions that fail to provide a sufficient number of elements, and the definitions of the functions that access elements outside the specified bounds. (There is no interplay with _FORTIFY_SOURCE here yet.) Tested with GCC 7 through 11 on x86_64-linux.
2021-05-03linux: Add execveat system call wrapperAlexandra Hájková1-0/+1
It operates similar to execve and it is is already used to implement fexecve without requiring /proc to be mounted. However, different than fexecve, if the syscall is not supported by the kernel an error is returned instead of trying a fallback. Checked on x86_64-linux-gnu and powerpc64le-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-05-03Add pthread-in-libc, libpthread-routines-var, librt-routines-varFlorian Weimer2-0/+6
These make variables can be used to add routines to different libraries for the Hurd and Linux builds. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
2021-04-12hurd: Export _hurd_libc_proc_initSamuel Thibault1-0/+1
hurd's libdiskfs needs to be able to call _hurd_init + _hurd_libc_proc_init for bootstrap initialization.
2021-03-30Move __isnanf128 to libc.soSiddhesh Poyarekar2-1/+2
All of the isnan functions are in libc.so due to printf_fp, so move __isnanf128 there too for consistency. Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@ascii.art.br> Reviewed-by: Florian Weimer <fweimer@redhat.com>
2021-03-23hurd: handle EINTR during critical sectionsSamuel Thibault22-2/+102
During critical sections, signal handling is deferred and thus RPCs return EINTR, even if SA_RESTART is set. We thus have to restart the whole critical section in that case. This also adds HURD_CRITICAL_UNLOCK in the cases where one wants to break the section in the middle.
2021-03-18signal: Add __libc_sigactionAdhemerval Zanella1-7/+5
The generic implementation basically handle the system agnostic logic (filtering out the invalid signals) while the __libc_sigaction is the function with implements the system and architecture bits. Checked on x86_64-linux-gnu and i686-linux-gnu.
2021-03-12posix: Consolidate register-atforkAdhemerval Zanella1-11/+4
Both htl and nptl uses a different data structure to implement atfork handlers. The nptl one was refactored by 27761a1042d to use a dynarray which simplifies the code. This patch moves the nptl one to be the generic implementation and replace Hurd linked one. Different than previous NPTL, Hurd also uses a global lock, so performance should be similar. Checked on x86_64-linux-gnu, i686-linux-gnu, and with a build for i686-gnu.
2021-03-01Implement <unwind-link.h> for dynamically loading the libgcc_s unwinderFlorian Weimer1-0/+3
This will be used to consolidate the libgcc_s access for backtrace and pthread_cancel. Unlike the existing backtrace implementations, it provides some hardening based on pointer mangling. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-02-25Reduce the statically linked startup code [BZ #23323]Florian Weimer1-0/+1
It turns out the startup code in csu/elf-init.c has a perfect pair of ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, "return-to-csu: A New Method to Bypass 64-bit Linux ASLR"). These functions are not needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY are already processed by the dynamic linker. However, the dynamic linker skipped the main program for some reason. For maximum backwards compatibility, this is not changed, and instead, the main map is consulted from __libc_start_main if the init function argument is a NULL pointer. For statically linked binaries, the old approach based on linker symbols is still used because there is nothing else available. A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because new binaries running on an old libc would not run their ELF constructors, leading to difficult-to-debug issues.
2021-02-11hurd: Fix fstatfs build failureAdhemerval Zanella1-1/+1
It was added by 1bfbaf7130 where it added a libc_hidden_proto for __fstatfs but it didn't update the Hurd version as well. Checked with a build for i686-gnu.
2021-02-01hurd TIOCFLUSH: fix fixing argumentSamuel Thibault1-2/+2
The argument actually used inside send_rpc is argptr, not arg.
2021-02-01hurd TIOCFLUSH: Cope BSD 4.1 semanticSamuel Thibault1-0/+4
BSD 4.1 did not have an argument for TIOCFLUSH, BSD 4.2 added it. There are still a lot of applications out there that pass a NULL argument to TIOCFLUSH, so we should rather cope with it.
2021-01-21Revert "linux: Move {f}xstat{at} to compat symbols" for static buildAdhemerval Zanella8-12/+9
This reverts commit 20b39d59467b0c1d858e89ded8b0cebe55e22f60 for static library. This avoids the need to rebuild the world for the case where libstdc++ (and potentially other libraries) are linked to a old glibc. To avoid requering to provide xstat symbols for newer ABIs (such as riscv32) a new LIB_COMPAT macro is added. It is similar to SHLIB_COMPAT but also works for static case (thus evaluating similar to SHLIB_COMPAT for both shared and static case). Checked with a check-abi on all affected ABIs. I also check if the static library does contains the xstat symbols.
2021-01-21<sys/platform/x86.h>: Remove the C preprocessor magicH.J. Lu2-1/+1
In <sys/platform/x86.h>, define CPU features as enum instead of using the C preprocessor magic to make it easier to wrap this functionality in other languages. Move the C preprocessor magic to internal header for better GCC codegen when more than one features are checked in a single expression as in x86-64 dl-hwcaps-subdirs.c. 1. Rename COMMON_CPUID_INDEX_XXX to CPUID_INDEX_XXX. 2. Move CPUID_INDEX_MAX to sysdeps/x86/include/cpu-features.h. 3. Remove struct cpu_features and __x86_get_cpu_features from <sys/platform/x86.h>. 4. Add __x86_get_cpuid_feature_leaf to <sys/platform/x86.h> and put it in libc. 5. Make __get_cpu_features() private to glibc. 6. Replace __x86_get_cpu_features(N) with __get_cpu_features(). 7. Add _dl_x86_get_cpu_features to GLIBC_PRIVATE. 8. Use a single enum index for each CPU feature detection. 9. Pass the CPUID feature leaf to __x86_get_cpuid_feature_leaf. 10. Return zero struct cpuid_feature for the older glibc binary with a smaller CPUID_INDEX_MAX [BZ #27104]. 11. Inside glibc, use the C preprocessor magic so that cpu_features data can be loaded just once leading to more compact code for glibc. 256 bits are used for each CPUID leaf. Some leaves only contain a few features. We can add exceptions to such leaves. But it will increase code sizes and it is harder to provide backward/forward compatibilities when new features are added to such leaves in the future. When new leaves are added, _rtld_global_ro offsets will change which leads to race condition during in-place updates. We may avoid in-place updates by 1. Rename the old glibc. 2. Install the new glibc. 3. Remove the old glibc. NB: A function, __x86_get_cpuid_feature_leaf , is used to avoid the copy relocation issue with IFUNC resolver as shown in IFUNC resolver tests.
2021-01-19Hurd: Add rtld-strncpy-c.cH.J. Lu1-0/+1
All IFUNC functions which are used in ld.so must have a rtld version if the IFUNC version isn't safe to use in ld.so.
2021-01-04hurd: Fix mmap(!MAP_FIXED) on bogus addressSamuel Thibault1-3/+6
In the !MAP_FIXED case, when a bogus address is given mmap should pick up a valide address rather than returning EINVAL: Posix only talks about EINVAL for the MAP_FIXED case. This fixes long-running ghc processes.
2021-01-02Update copyright dates with scripts/update-copyrightsPaul Eggert383-383/+383
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 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
2020-12-29io: Remove xmknod{at} implementationsAdhemerval Zanella2-31/+1
With xmknod wrapper functions removed (589260cef8), the mknod functions are now properly exported, and version is done using symbols versioning instead of the extra _MKNOD_* argument. It also allows us to consolidate Linux and Hurd mknod implementation. Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-12-29io: Remove xstat implementationsAdhemerval Zanella1-1/+3
With xstat wrapper functions removed (8ed005daf0), the stat functions are now properly exported, and version is done using symbols versioning instead of the extra _STAT_* argument. Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-12-28hurd: Add WSTOPPED/WCONTINUED/WEXITED/WNOWAIT support [BZ #23091]Samuel Thibault1-10/+30
The new __proc_waitid RPC now expects WEXITED to be passed, allowing to properly implement waitid, and thus define the missing W* macros (according to FreeBSD values).
2020-12-26hurd: set sigaction for signal preemptors in arch-independent fileSamuel Thibault1-15/+2
Instead of having the arch-specific trampoline setup code detect whether preemption happened or not, we'd rather pass it the sigaction. In the future, this may also allow to change sa_flags from post_signal().
2020-12-26hurd: Fix spawni SPAWN_XFLAGS_TRY_SHELL with empty argvSamuel Thibault1-1/+5
When argv is empty, we need to add the original script to be run on the shell command line.
2020-12-26hurd: Try shell in posix_spawn* only in compat modeSamuel Thibault1-1/+1
Reported by Bruno Haible <bruno@clisp.org>
2020-12-21hurd: Make trampoline fill siginfo ss_sp from sc_uespSamuel Thibault1-1/+1
Mach actually rather fills the uesp field, not esp.
2020-12-21hurd: implement SA_SIGINFO signal handlers.Jeremie Koenig6-62/+198
SA_SIGINFO is actually just another way of expressing what we were already passing over with struct sigcontext. This just introduces the SIGINFO interface and fixes the posix values when that interface is requested by the application.
2020-12-20hurd: Note when the vm_map kernel bug was fixedSamuel Thibault1-1/+1
dl-sysdep has been wanting to use high bits in the vm_map mask for decades, but that was only implemented lately.
2020-12-16Replace __libc_multiple_libcs with __libc_initial flagFlorian Weimer2-6/+6
Change sbrk to fail for !__libc_initial (in the generic implementation). As a result, sbrk is (relatively) safe to use for the __libc_initial case (from the main libc). It is therefore no longer necessary to avoid using it in that case (or updating the brk cache), and the __libc_initial flag does not need to be updated as part of dlmopen or static dlopen. As before, direct brk system calls on Linux may lead to memory corruption. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-16htl: Get sem_open/sem_close/sem_unlink support [BZ #25524]Samuel Thibault1-7/+0
This just moves the existing nptl implementation to reuse as it is in htl.
2020-12-16htl: Add pshared semaphore supportSamuel Thibault1-1/+0
The implementation is extremely similar to the nptl implementation, but with slight differences in the futex interface. This fixes some of BZ 25521.
2020-12-16hurd: Add __libc_open and __libc_closeSamuel Thibault1-0/+1
Needed by libpthread for sem_open and sem_close
2020-12-16hurd: make lll_* take a variable instead of a ptrSamuel Thibault9-26/+26
To be coherent with other ports, let's make lll_* take a variable, and rename those that keep taking a ptr into __lll_*.
2020-12-16hurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZERSamuel Thibault1-4/+4
To get coherent with other ports.
2020-12-04nss: Implement <nss_database.h>Florian Weimer1-0/+8
This code manages the mappings of the available databases in NSS (i.e. passwd, hosts, netgroup, etc) with the actions that should be taken to do a query on those databases. This is the main API between query functions scattered throughout glibc and the underlying code (actions, modules, etc). Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2020-11-16hurd: Enable using ifuncSamuel Thibault2-6/+0
Bugs have been fixed in binutils/gcc/glibc.
2020-11-16Add {,sysdep-}ld-library-path make variableSamuel Thibault1-0/+2
On GNU/Hurd we not only need $(common-objpfx) in LD_LIBRARY_PATH when loading dynamic objects, but also $(common-objpfx)/mach and $(common-objpfx)/hurd. This adds an ld-library-path variable to be used as LD_LIBRARY_PATH basis in Makefiles, and a sysdep-ld-library-path variable for sysdeps to add some more paths, here mach/ and hurd/.
2020-11-15hurd: let _dl_argv and __libc_stack_end be relroSamuel Thibault1-7/+0
libpthread does not switch stacks.
2020-11-15hurd: Remove some remnants of cthreadsSamuel Thibault6-8/+10
Libc has actually been using mach's lock-internal.h mutex for a long time already.
2020-11-14hurd: Drop CLOCK_MONOTONIC change which slipped inSamuel Thibault1-1/+0
2020-11-14hurd: make ptsname fail with ENOTTY on non-master-ptySamuel Thibault1-0/+8
2020-11-14mach: Add missing assert.h includeSamuel Thibault1-0/+2
2020-11-14hurd: break relocation loop between libc.so and lib{mach,hurd}user.soSamuel Thibault1-0/+12
See https://sourceware.org/pipermail/libc-alpha/2020-November/119575.html lib{mach,hurd}user.so gets relocated before libc.so, but its references to strpcpy and memcpy would need an ifunc decision, which e.g. on x86 relies on cpu_features, but libc.so's _rtld_global_ro is not relocated yet. We can however just make lib{mach,hurd}user.so only call non-ifunc functions, which can be relocated before libc.so is relocated.
2020-11-13Remove tls.h inclusion from internal errno.hAdhemerval Zanella2-0/+2
The tls.h inclusion is not really required and limits possible definition on more arch specific headers. This is a cleanup to allow inline functions on sysdep.h, more specifically on i386 and ia64 which requires to access some tls definitions its own. No semantic changes expected, checked with a build against all affected ABIs.
2020-11-13hurd: Make sure signals get startedSamuel Thibault1-3/+3
Now that _hurd_libc_proc_init is idempotent, we can always call it, independently of the __libc_multiple_libcs test which may not match whether signals should be started or not.
2020-11-11hurd: Move {,f,l}xstat{,at} and xmknod{at} to compat symbolsSamuel Thibault25-188/+510
We do not actually need them, so we can move their implementations into the standard {,f,l}stat{,at} variants and only keep compatibility wrappers.
2020-11-11hurd: Notify the proc server later during initializationSamuel Thibault1-0/+3
Notifying the proc server is an involved task, and unleashes various signal handling etc. so we have to do this after e.g. ifunc relocations are completed.
2020-11-11htl: Initialize laterSamuel Thibault6-116/+29
Since htl does not actually need a stack switch, we can initialize it like nptl is, avoiding all sorts of startup issues with ifunc. More precisely, htl defines __pthread_initialize_minimal instead of the elder _cthread_init_routine. We can then drop the stack switching dances.
2020-11-11hurd: keep only required PLTs in ld.soSamuel Thibault4-17/+5
We need NO_RTLD_HIDDEN because of the need for PLT calls in ld.so. See Roland's comment in https://sourceware.org/bugzilla/show_bug.cgi?id=15605 "in the Hurd it's crucial that calls like __mmap be the libc ones instead of the rtld-local ones after the bootstrap phase, when the dynamic linker is being used for dlopen and the like." We used to just avoid all hidden use in the rtld ; this commit switches to keeping only those that should use PLT calls, i.e. essentially those defined in sysdeps/mach/hurd/dl-sysdep.c: __assert_fail __assert_perror_fail __*stat64 _exit This fixes a few startup issues, notably the call to __tunable_get_val that is made before PLTs are set up.
2020-11-11hurd: Add missing startup callsSamuel Thibault1-0/+16
DL_SYSDEP_INIT and DL_PLATFORM_INIT were not getting called, leading to missing x86 platform tuning, now mandatory with 0f09154c6400 ("x86: Initialize CPU info via IFUNC relocation [BZ 26203]")
2020-10-31hurd: Correct 'ethenet' spellingJonny Grant1-1/+1
Signed-off-by: Jonny Grant <jg@jguk.org>