about summary refs log tree commit diff
path: root/hurd
Commit message (Collapse)AuthorAgeFilesLines
* hurd: Make exception subcode a longSergey Bugaev2023-08-293-4/+5
| | | | | | | | | On EXC_BAD_ACCESS, exception subcode is used to pass the faulting memory address, so it needs to be (at least) pointer-sized. Thus, make it into a long. This matches the corresponding change in GNU Mach. Message-Id: <20230319151017.531737-5-bugaevc@gmail.com> (cherry picked from commit d8ee5d614bc485f6d1752dfa0d60524b20945a56)
* Update copyright dates with scripts/update-copyrightsJoseph Myers2023-01-0688-88/+88
|
* hurd hurdstartup: Initialize remaining fields of hurd_startup_dataSamuel Thibault2023-01-021-0/+5
| | | | | In case we don't have a bootstrap port or __exec_startup_get_info failed, we should avoid leaking uninitialized fields of data.
* hurd _S_msg_add_auth: Initialize new arrays to 0Samuel Thibault2023-01-021-6/+9
| | | | | If make_list fails, they would be undefined, and freeup with free uninitialized pointers.
* Use PTR_MANGLE and PTR_DEMANGLE unconditionally in C sourcesFlorian Weimer2022-10-181-2/+0
| | | | | | | | | | | | | | | | | In the future, this will result in a compilation failure if the macros are unexpectedly undefined (due to header inclusion ordering or header inclusion missing altogether). Assembler sources are more difficult to convert. In many cases, they are hand-optimized for the mangling and no-mangling variants, which is why they are not converted. sysdeps/s390/s390-32/__longjmp.c and sysdeps/s390/s390-64/__longjmp.c are special: These are C sources, but most of the implementation is in assembler, so the PTR_DEMANGLE macro has to be undefined in some cases, to match the assembler style. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Introduce <pointer_guard.h>, extracted from <sysdep.h>Florian Weimer2022-10-181-1/+1
| | | | | | | | | | | | | | This allows us to define a generic no-op version of PTR_MANGLE and PTR_DEMANGLE. In the future, we can use PTR_MANGLE and PTR_DEMANGLE unconditionally in C sources, avoiding an unintended loss of hardening due to missing include files or unlucky header inclusion ordering. In i386 and x86_64, we can avoid a <tls.h> dependency in the C code by using the computed constant from <tcb-offsets.h>. <sysdep.h> no longer includes these definitions, so there is no cyclic dependency anymore when computing the <tcb-offsets.h> constants. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use atomic_exchange_release/acquireWilco Dijkstra2022-09-261-1/+1
| | | | | | | Rename atomic_exchange_rel/acq to use atomic_exchange_release/acquire since these map to the standard C11 atomic builtins. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: Fix vm_size_t incoherenciesSamuel Thibault2022-08-296-7/+8
| | | | | | | In gnumach, 3e1702a65fb3 ("add rpc_versions for vm types") changed the type of vm_size_t, making it always a unsigned long. This made it incompatible on x86 with size_t. Even if we may want to revert it to unsigned int, it's better to fix the types of parameters according to the .defs files.
* Replace {u}int_fast{16|32} with {u}int32_tNoah Goldstein2022-04-131-1/+1
| | | | | | | | | 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.
* hurd: Make RPC input array parameters constSamuel Thibault2022-01-163-10/+10
| | | | | This follows mig's cf4bcc3f1435 ("Also add const qualifiers on server side")
* hurd: optimize exec cleanupSamuel Thibault2022-01-161-12/+14
| | | | | When ports are nul we do not need to request their deallocation. It is also useless to look for them in portnames.
* hurd: Fix exec() leak on proc_task2proc failureSamuel Thibault2022-01-151-2/+2
| | | | env is allocated after args, so should be freed before it.
* hurd: nuke all unknown ports on execSamuel Thibault2022-01-041-7/+39
| | | | | | | Ports which are not in the ports table or dtable will not make sense for the new program, so we can nuke them. Actually we shall, otherwise we would be leaking various ports, for instance the file_t of the executed program itself.
* hurd: Fix auth port leakSamuel Thibault2022-01-041-5/+8
| | | | | | If access() was used before exec, _hurd_id.rid_auth would cache an "effective" auth port. We do not want this to leak into the executed program.
* hurd: Implement _S_msg_get_dtableSamuel Thibault2022-01-021-4/+47
| | | | This will be needed for implementing lsof.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2022-01-0188-88/+88
| | | | | | | | | | | | | | | | | | | | | | | 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
* hurd: Fix static-PIE startupSamuel Thibault2021-12-287-31/+21
| | | | | | | | hurd initialization stages use RUN_HOOK to run various initialization functions. That is however using absolute addresses which need to be relocated, which is done later by csu. We can however easily make the linker compute relative addresses which thus don't need a relocation. The new SET_RELHOOK and RUN_RELHOOK macros implement this.
* hurd: let csu initialize tlsSamuel Thibault2021-12-281-15/+24
| | | | | | | | Since 9cec82de715b ("htl: Initialize later"), we let csu initialize pthreads. We can thus let it initialize tls later too, to better align with the generic order. Initialization however accesses ports which links/unlinks into the sigstate for unwinding. We can however easily skip that during initialization.
* hurd: Let report-wait use a weak reference to _hurd_itimer_threadSamuel Thibault2021-11-281-5/+0
| | | | libc.so.0.3 does not seem to need this defined any more.
* Remove "Contributed by" linesSiddhesh Poyarekar2021-09-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | We stopped adding "Contributed by" or similar lines in sources in 2012 in favour of git logs and keeping the Contributors section of the glibc manual up to date. Removing these lines makes the license header a bit more consistent across files and also removes the possibility of error in attribution when license blocks or files are copied across since the contributed-by lines don't actually reflect reality in those cases. Move all "Contributed by" and similar lines (Written by, Test by, etc.) into a new file CONTRIBUTED-BY to retain record of these contributions. These contributors are also mentioned in manual/contrib.texi, so we just maintain this additional record as a courtesy to the earlier developers. The following scripts were used to filter a list of files to edit in place and to clean up the CONTRIBUTED-BY file respectively. These were not added to the glibc sources because they're not expected to be of any use in future given that this is a one time task: https://gist.github.com/siddhesh/b5ecac94eabfd72ed2916d6d8157e7dc https://gist.github.com/siddhesh/15ea1f5e435ace9774f485030695ee02 Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* hurd: Add support for AT_NO_AUTOMOUNTSamuel Thibault2021-08-101-0/+6
|
* hurd: Avoid spurious warningSamuel Thibault2021-08-031-1/+1
| | | | | Compilers missing some flow analysis may think ss may be used uninitialized.
* hurd: Export _hurd_libc_proc_initSamuel Thibault2021-04-122-0/+8
| | | | | hurd's libdiskfs needs to be able to call _hurd_init + _hurd_libc_proc_init for bootstrap initialization.
* hurd: handle EINTR during critical sectionsSamuel Thibault2021-03-237-2/+37
| | | | | | | | | 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.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2021-01-0288-88/+88
| | | | | | | | | | | | | | | | 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
* hurd: set sigaction for signal preemptors in arch-independent fileSamuel Thibault2020-12-262-7/+18
| | | | | | 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().
* Hurd: make sigstates hold a reference on thread portsRichard Braun2020-12-212-7/+29
| | | | | | | | | | | | | This change is required in order to correctly release per-thread resources. Directly reusing the threading library reference isn't possible since the sigstate is also used early in the main thread, before threading is initialized. * hurd/hurd/signal.h (_hurd_self_sigstate): Drop thread reference after calling _hurd_thread_sigstate. (_hurd_critical_section_lock): Likewise. * hurd/hurdsig.c (_hurd_thread_sigstate): Add a reference on the thread. (_hurd_sigstate_delete): Drop thread reference.
* hurd: implement SA_SIGINFO signal handlers.Jeremie Koenig2020-12-214-5/+10
| | | | | | | 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.
* hurd: Also turn KERN_INVALID_ADDRESS to EINVALSamuel Thibault2020-12-191-0/+1
| | | | | When e.g. mmap is passed an invalid address we would return KERN_INVALID_ADDRESS, while POSIX applications would expect EINVAL.
* hurd: Add __libc_open and __libc_closeSamuel Thibault2020-12-161-0/+1
| | | | Needed by libpthread for sem_open and sem_close
* hurd: Add __lll_abstimed_wait_intrSamuel Thibault2020-12-165-1/+33
| | | | For semaphores, we need an interruptible version of low-level locks.
* hurd: make lll_* take a variable instead of a ptrSamuel Thibault2020-12-163-24/+30
| | | | | To be coherent with other ports, let's make lll_* take a variable, and rename those that keep taking a ptr into __lll_*.
* hurd: Rename LLL_INITIALIZER to LLL_LOCK_INITIALIZERSamuel Thibault2020-12-161-1/+1
| | | | To get coherent with other ports.
* htl: Add missing symbolsSamuel Thibault2020-12-031-1/+1
| | | | | hurd/hurdsig.c needs to detect whether __pthread_detach and __pthread_create are available, so they need to be exposed.
* hurd report-wait: Fix stpcpy usageSamuel Thibault2020-11-231-29/+49
| | | | | | | | We shall not overflow the size of the description parameter. This makes describe_number and describe_port behave like strpcpy (except for not filling all the end of buffer with zeroes) and _S_msg_report_wait use series of stpncpy-like call. If we were to overflow, we can now detect it and return ENOMEM.
* hurd S_msg_report_wait: Fix detecting fd portsSamuel Thibault2020-11-231-1/+1
| | | | | _hurd_init_dtable stays set to non-NULL, so we have to run through both _hurd_init_dtable and _hurd_dtable.
* hurd S_msg_report_wait: Fix reporting portsSamuel Thibault2020-11-231-1/+1
| | | | | This fixes the parameter order of MSG_EXAMINE, thus fixing the detection of e.g. fd ports for nicer output in ps WAIT output.
* hurd: Fix strcpy callsSamuel Thibault2020-11-221-3/+4
| | | | | | | strcpy cannot be used with overlapping buffer, we have to use memmove instead. strcpy also cannot be safely used when the destination buffer is smaller that the source, we need to use strncpy to truncate the source if needed.
* hurd: Fix _S_msg_get/set_env_variable prototypeSamuel Thibault2020-11-221-3/+3
| | | | | | | _S_msg_get_env_variable and _S_msg_set_env_variable are taking string_t, not char *. Fixes a warning with gcc 11.
* hurd: Remove some remnants of cthreadsSamuel Thibault2020-11-1512-61/+44
| | | | | Libc has actually been using mach's lock-internal.h mutex for a long time already.
* hurd: initialize libpthread before starting the signal threadSamuel Thibault2020-11-131-0/+6
| | | | | We cannot rely on csu calling __pthread_initialize_minimal before posixland_init, in some cases _init gets called before that.
* hurd: Make _hurd_libc_proc_init idempotentSamuel Thibault2020-11-131-11/+19
| | | | | For the cases where _init is getting called several times during startup. Better clean pointers anyway.
* hurd: Notify the proc server later during initializationSamuel Thibault2020-11-111-11/+25
| | | | | | 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.
* htl: Initialize laterSamuel Thibault2020-11-111-3/+0
| | | | | | | | 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.
* hurd: Rework sbrkSamuel Thibault2020-08-051-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Making the brk start exactly at the end of the main application binary was requiring to get it through the _end symbol, which does not work any more with recent toolchains, and actually produces in libc.so a confusing external _end symbol that produces odd results, see https://sourceware.org/bugzilla/show_bug.cgi?id=23499 Trying to do so is quite outdated anyway with the tendency for address randomization. Using _end was also allowing to include the main binary data within the RLIMIT_DATA, but this also seems outdated with dynamic library loading, and nowadays' memory consumption via malloc and mmap rather than statically-allocated data. This adds a BRK_START macro in <vm_param.h> that just tells where we want to start the brk, and thus removes the _end symbol. * sysdeps/mach/hurd/i386/vm_param.h: New file. * sysdeps/mach/hurd/brk.c: Use BRK_START as brk start instead of _end. Also ignore __data_start. * hurd/Versions: Remove _end symbol. * sysdeps/mach/hurd/i386/libc.abilist: Remove _end symbol.
* hurd: Add remaining cancelation pointsSamuel Thibault2020-06-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * hurd/hurdselect.c: Include <sysdep-cancel.h>. (_hurd_select): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/hurd/accept4.c: Include <sysdep-cancel.h>. (__libc_accept4): Surround call to __socket_accept with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/connect.c: Include <sysdep-cancel.h>. (__connect): Surround call to __file_name_lookup and __socket_connect with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/fdatasync.c: Include <sysdep-cancel.h>. (fdatasync): Surround call to __file_sync with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/fsync.c: Include <sysdep-cancel.h>. (fsync): Surround call to __file_sync with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/ioctl.c: Include <sysdep-cancel.h>. (__ioctl): When request is TIOCDRAIN, surround call to send_rpc with enabling async cancel, and use HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/msync.c: Include <sysdep-cancel.h>. (msync): Surround call to __vm_object_sync with enabling async cancel. * sysdeps/mach/hurd/sigsuspend.c: Include <sysdep-cancel.h>. (__sigsuspend): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/hurd/sigwait.c: Include <sysdep-cancel.h>. (__sigwait): Surround wait code with enabling async cancel. * sysdeps/mach/msync.c: Include <sysdep-cancel.h>. (msync): Surround call to __vm_msync with enabling async cancel. * sysdeps/mach/sleep.c: Include <sysdep-cancel.h>. (__sleep): Surround call to __mach_msg with enabling async cancel. * sysdeps/mach/usleep.c: Include <sysdep-cancel.h>. (usleep): Surround call to __vm_msync with enabling async cancel.
* hurd: clean fd and port on thread cancelSamuel Thibault2020-06-288-4/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | HURD_*PORT_USE link fd and port with a stack-stored structure, so on thread cancel we need to cleanup this. * hurd/fd-cleanup.c: New file. * hurd/port-cleanup.c (_hurd_port_use_cleanup): New function. * hurd/Makefile (routines): Add fd-cleanup. * sysdeps/hurd/include/hurd.h (__USEPORT_CANCEL): New macro. * sysdeps/hurd/include/hurd/fd.h (_hurd_fd_port_use_data): New structure. (_hurd_fd_port_use_cleanup): New prototype. (HURD_DPORT_USE_CANCEL, HURD_FD_PORT_USE_CANCEL): New macros. * sysdeps/hurd/include/hurd/port.h (_hurd_port_use_data): New structure. (_hurd_port_use_cleanup): New prototype. (HURD_PORT_USE_CANCEL): New macro. * hurd/hurd/fd.h (HURD_FD_PORT_USE): Also refer to HURD_FD_PORT_USE_CANCEL. * hurd/hurd.h (__USEPORT): Also refer to __USEPORT_CANCEL. * hurd/hurd/port.h (HURD_PORT_USE): Also refer to HURD_PORT_USE_CANCEL. * hurd/fd-read.c (_hurd_fd_read): Call HURD_FD_PORT_USE_CANCEL instead of HURD_FD_PORT_USE. * hurd/fd-write.c (_hurd_fd_write): Likewise. * sysdeps/mach/hurd/send.c (__send): Call HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE. * sysdeps/mach/hurd/sendmsg.c (__libc_sendmsg): Likewise. * sysdeps/mach/hurd/sendto.c (__sendto): Likewise. * sysdeps/mach/hurd/recv.c (__recv): Likewise. * sysdeps/mach/hurd/recvfrom.c (__recvfrom): Likewise. * sysdeps/mach/hurd/recvmsg.c (__libc_recvmsg): Call __USEPORT_CANCEL instead of __USEPORT, and HURD_DPORT_USE_CANCEL instead of HURD_DPORT_USE.
* hurd: Fix hang in _hurd_raise_signal from pthread_killSamuel Thibault2020-06-071-1/+5
| | | | | | | When ss is not NULL, it is assumed to be locked. * hurd/hurd-raise.c (_hurd_raise_signal): Unlock before returning an error if ss is not NULL.
* hurd: Reject raising invalid signalsSamuel Thibault2020-06-071-0/+3
| | | | | * hurd/hurd-raise.c (_hurd_raise_signal): Return EINVAL if signo <= 0 or signo >= NSI.
* Hurd: Move <hurd/sigpreempt.h> internals into wrapper headerFlorian Weimer2020-05-281-10/+0
| | | | | | | | _hurdsig_preemptors and _hurdsig_preempted_set are not ABI symbols, so do not declare them. HURD_PREEMPT_SIGNAL_P is an implementation detail, so move it as well. Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>