about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* Fix Hurd getcwd build with GCC >= 13Joseph Myers2023-04-271-2/+3
| | | | | | | | | | | | | | | | | | | | | The build of glibc for i686-gnu has been failing for a while with GCC mainline / GCC 13: ../sysdeps/mach/hurd/getcwd.c: In function '__hurd_canonicalize_directory_name_internal': ../sysdeps/mach/hurd/getcwd.c:242:48: error: pointer 'file_name' may be used after 'realloc' [-Werror=use-after-free] 242 | file_namep = &buf[file_namep - file_name + size / 2]; | ~~~~~~~~~~~^~~~~~~~~~~ ../sysdeps/mach/hurd/getcwd.c:236:25: note: call to 'realloc' here 236 | buf = realloc (file_name, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~ Fix by doing the subtraction before the reallocation. Tested with build-many-glibcs.py for i686-gnu. [samuel.thibault@ens-lyon.rg: Removed mention of this being a bug] Message-Id: <18587337-7815-4056-ebd0-724df262d591@codesourcery.com>
* Regenerate sysdeps/mach/hurd/bits/errno.hJoseph Myers2023-04-261-0/+19
| | | | | This file was out of date, as shown by build-many-glibcs.py runs resulting in a modified source directory.
* locale/programs/locarchive.c: Remove unnecessary check in add_locale_archiveFrédéric Bérat2023-04-261-1/+1
| | | | | | | Since asprintf is called "if (mask & XPG_NORM_CODESET)" there is no point in checking the mask again within the asprintf call. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* manual: document posix_openpt (bug 17010)Gavin Smith2023-04-261-3/+33
| | | | | | | | State that getpt is similar to posix_openpt. Use posix_openpt instead of getpt in example. Signed-off-by: Gavin Smith <gavinsmith0123@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* if_index: Remove unneeded alloca.h includeJoe Simmons-Talbott2023-04-261-1/+0
| | | | | Nothing is being used from this header. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* gethostid: Do not include alloca.hJoe Simmons-Talbott2023-04-261-1/+0
| | | | | Nothing from alloca.h is being used here. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* socket: Add a test for MSG_CMSG_CLOEXECSergey Bugaev2023-04-252-0/+127
| | | | | | | | | | | | | | | This checks that: * We can send and receive fds over Unix domain sockets using SCM_RIGHTS; * msg_controllen, cmsg_level, cmsg_type, cmsg_len are all filled in correctly on receive; * Most importantly, the received fd has or has not the close-on-exec flag set depending on whether we pass MSG_CMSG_CLOEXEC to recvmsg (). Checked on i686-gnu and x86_64-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230423160548.126576-4-bugaevc@gmail.com>
* hurd: Do not take any flag from the CMSG_DATASamuel Thibault2023-04-251-1/+3
| | | | | | As fixed in 0822e3552a78 ("hurd: Don't pass FD_CLOEXEC in CMSG_DATA"), senders currently don't have any flag to pass. We shouldn't blindly take random flags that senders could be erroneously giving us.
* hurd: Implement MSG_CMSG_CLOEXECSergey Bugaev2023-04-242-2/+7
| | | | | | | | | | | | | | | This is a new flag that can be passed to recvmsg () to make it atomically set the CLOEXEC flag on all the file descriptors received using the SCM_RIGHTS mechanism. This is useful for all the same reasons that the other XXX_CLOEXEC flags are useful: namely, it provides atomicity with respect to another thread of the same process calling (fork and then) exec at the same time. This flag is already supported on Linux and FreeBSD. The flag's value, 0x40000, is choosen to match FreeBSD's. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230423160548.126576-2-bugaevc@gmail.com>
* hurd: Don't pass FD_CLOEXEC in CMSG_DATASamuel Thibault2023-04-241-2/+2
| | | | | | | | | | | | | | | | | | | The flags are used by _hurd_intern_fd, which takes O_* flags, not FD_*. Also, it is of no concern to the receiving process whether or not the sender process wants to close its copy of sent file descriptor upon exec, and it should not influence whether or not the received file descriptor gets the FD_CLOEXEC flag set in the receiving process. The latter should in fact be dependent on the MSG_CMSG_CLOEXEC flag being passed to the recvmsg () call, which is going to be implemented in the following commit. Fixes 344e755248ce02c0f8d095d11cc49e340703d926 "hurd: Support sending file descriptors over Unix sockets" Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* hurd: Implement prefer_map_32bit_exec tunableSergey Bugaev2023-04-248-23/+33
| | | | | | | This makes the prefer_map_32bit_exec tunable no longer Linux-specific. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230423215526.346009-4-bugaevc@gmail.com>
* hurd: Don't attempt to deallocate MACH_PORT_DEADSergey Bugaev2023-04-242-4/+4
| | | | | | | ...in some more places. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230423215526.346009-2-bugaevc@gmail.com>
* hurd: Only deallocate addrport when it's validSergey Bugaev2023-04-245-6/+10
| | | | | Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230423160548.126576-3-bugaevc@gmail.com>
* hurd: Implement MAP_32BITSergey Bugaev2023-04-243-7/+12
| | | | | | | | | | | | | | | | | | | | This is a flag that can be passed to mmap () to request that the mapping being established should be located in the lower 2 GB area of the address space, so only the lower 31 (not 32) bits can be set in its address, and the address can be represented as a 32-bit integer without truncating it. This flag is intended to be compatible with Linux, FreeBSD, and Darwin flags of the same name. Out of those systems, it appears Linux and FreeBSD take MAP_32BIT to mean "map 31 bit", whereas Darwin allows the 32nd bit to be set in the address as well. The Hurd follows Linux and FreeBSD behavior. Unlike on those systems, on the Hurd MAP_32BIT is defined on all supported architectures (which currently are only i386 and x86_64). Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230423215526.346009-1-bugaevc@gmail.com>
* Use O_CLOEXEC in more places (BZ #15722)Sergey Bugaev2023-04-226-11/+16
| | | | | | | | | | | | | When opening a temporary file without O_CLOEXEC we risk leaking the file descriptor if another thread calls (fork and then) exec while we have the fd open. Fix this by consistently passing O_CLOEXEC everywhere where we open a file for internal use (and not to return it to the user, in which case the API defines whether or not the close-on-exec flag shall be set on the returned fd). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230419160207.65988-4-bugaevc@gmail.com>
* misc: Convert daemon () to GNU coding styleSergey Bugaev2023-04-221-39/+49
| | | | | | | | | | | This is nicer, and is going to be required for the following changes to reasonably stay within the 79 column limit. No functional change. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Message-Id: <20230419160207.65988-2-bugaevc@gmail.com>
* wcsmbs: Add wcsdup() tests. (BZ #30266) azanella/bz30266Joe Simmons-Talbott2023-04-212-0/+3
| | | | | | Enable wide character testcases for wcsdup(). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* string: Add tests for strndup (BZ #30266)Joe Simmons-Talbott2023-04-212-0/+201
| | | | | | | | | Copy strncpy tests for strndup. Covers some basic testcases with random strings. Remove tests that set the destination's bytes and checked the resulting buffer's bytes. Remove wide character test support since wcsndup() doesn't exist. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* string: Add tests for strdup (BZ #30266)Joe Simmons-Talbott2023-04-212-0/+202
| | | | | | | Copy strcpy tests for strdup. Covers some basic testcases with random strings. Add a zero-length string testcase. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* string: Allow use of test-string.h for non-ifunc implementations.Joe Simmons-Talbott2023-04-211-2/+2
| | | | | | | Mark two variables as unused to silence warning when using test-string.h for non-ifunc implementations. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: Don't migrate reply port into __init1_tcbheadSergey Bugaev2023-04-213-17/+19
| | | | | | | | | | | | | | | Properly differentiate between setting up the real TLS with TLS_INIT_TP, and setting up the early TLS (__init1_tcbhead) in static builds. In the latter case, don't yet migrate the reply port into the TCB, and don't yet set __libc_tls_initialized to 1. This also lets us move the __init1_desc assignment inside _hurd_tls_init (). Fixes cd019ddd892e182277fadd6aedccc57fa3923c8d "hurd: Don't leak __hurd_reply_port0" Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* hurd: Make dl-sysdep's open () cope with O_IGNORE_CTTYSergey Bugaev2023-04-201-2/+2
| | | | | Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230419160207.65988-6-bugaevc@gmail.com>
* Created tunable to force small pages on stack allocation.Cupertino Miranda2023-04-207-0/+42
| | | | | | | | | | Created tunable glibc.pthread.stack_hugetlb to control when hugepages can be used for stack allocation. In case THP are enabled and glibc.pthread.stack_hugetlb is set to 0, glibc will madvise the kernel not to use allow hugepages for stack allocations. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* malloc: Add missing shared thread library flagsAdhemerval Zanella2023-04-201-0/+1
| | | | So tst-memalign-3 builds on Hurd.
* linux: Re-flow and sort multiline Makefile definitionsAdhemerval Zanella2023-04-201-48/+158
|
* posix: Re-flow and sort multiline Makefile definitionsAdhemerval Zanella2023-04-201-126/+425
|
* build-many-glibcs.py: --disable-gcov for gcc-firstJan-Benedict Glaw2023-04-191-0/+1
| | | | | | | | This is also being tracked n GCC [1]. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100289
* malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101)DJ Delorie2023-04-184-82/+268
| | | | | | | | | | | | | | | | | | | | | | | | | | | Based on these comments in malloc.c: size field is or'ed with NON_MAIN_ARENA if the chunk was obtained from a non-main arena. This is only set immediately before handing the chunk to the user, if necessary. The NON_MAIN_ARENA flag is never set for unsorted chunks, so it does not have to be taken into account in size comparisons. When we pull a chunk off the unsorted list (or any list) we need to make sure that flag is set properly before returning the chunk. Use the rounded-up size for chunk_ok_for_memalign() Do not scan the arena for reusable chunks if there's no arena. Account for chunk overhead when determining if a chunk is a reuse candidate. mcheck interferes with memalign, so skip mcheck variants of memalign tests. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* hurd: Microoptimize sigreturnSergey Bugaev2023-04-181-3/+9
| | | | Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* rcmd.c: Fix indentation in last commitSiddhesh Poyarekar2023-04-181-2/+2
| | | | Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* inet/rcmd.c: fix warn unused resultFrédéric Bérat2023-04-181-2/+5
| | | | | | | Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* hurd: Avoid leaking task & thread portsSergey Bugaev2023-04-181-0/+6
| | | | Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* hurd: Simplify _S_catch_exception_raiseSergey Bugaev2023-04-181-7/+1
| | | | | | | | _hurd_thread_sigstate () already handles finding an existing sigstate before allocating a new one, so just use that. Bonus: this will only lock the _hurd_siglock once. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* hurd: Run init_pids () before init_dtable ()Sergey Bugaev2023-04-171-9/+9
| | | | | | | | | | | | | | | | | | | | | | Much as the comment says, things on _hurd_subinit assume that _hurd_pid is already initialized by the time _hurd_subinit is run, so _hurd_proc_subinit has to run before it. Specifically, init_dtable () calls _hurd_port2fd (), which uses _hurd_pid and _hurd_pgrp to set up ctty handling. With _hurd_subinit running before _hurd_proc_subinit, ctty setup was broken: 13<--33(pid1255)->term_getctty () = 0 4<--39(pid1255) task16(pid1255)->mach_port_deallocate (pn{ 10}) = 0 13<--33(pid1255)->term_open_ctty (0 0) = 0x40000016 (Invalid argument) Fix this by running the _hurd_proc_subinit hook in the correct place -- just after _hurd_portarray is set up (so the proc server port is available in its usual place) and just before running _hurd_subinit. Fixes 1ccbb9258eed0f667edf459a28ba23a805549b36 ("hurd: Notify the proc server later during initialization"). Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* hurd: Fix restoring reply port in sigreturnSergey Bugaev2023-04-171-12/+23
| | | | | | | | | We must not use the user's reply port (scp->sc_reply_port) for any of our own RPCs, otherwise various things break. So, use MACH_PORT_DEAD as a reply port when destroying our reply port, and make sure to do this after _hurd_sigstate_unlock (), which may do a gsync_wake () RPC. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* wcsmbs: Re-flow and sort routines, tests variables in MakefileFlorian Weimer2023-04-171-40/+138
| | | | | | Eliminate strop-tests because it does not seem to be a simplification. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* debug: Re-flow and sort routines variable in MakefileFlorian Weimer2023-04-171-24/+87
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: Avoid extra ctty RPCs in init_dtable ()Sergey Bugaev2023-04-171-7/+39
| | | | | | | | | | | | | | | | | It is common to have (some of) stdin, stdout and stderr point to the very same port. We were making the ctty RPCs that _hurd_port2fd () does for each one of them separately: 1. term_getctty () 2. mach_port_deallocate () 3. term_open_ctty () Instead, let's detect this case and duplicate the ctty port we already have. This means we do 1 RPC instead of 3 (and create a single protid on the server side) if the file is our ctty, and no RPCs instead of 1 if it's not. A clear win! Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* math: Improve fmod(f) performanceWilco Dijkstra2023-04-172-77/+101
| | | | | | | | | | | | | Optimize the fast paths (x < y) and (x/y < 2^12). Delay handling of special cases to reduce the number of instructions executed before the fast paths. Performance improvements for fmod: Skylake Zen2 Neoverse V1 subnormals 11.8% 4.2% 11.5% normal 3.9% 0.01% -0.5% close-exponents 6.3% 5.6% 19.4% Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Benchtests: Adjust timingWilco Dijkstra2023-04-1711-11/+11
| | | | | | | | Adjust iteration counts so benchmarks don't run too slowly or quickly. Ensure benchmarks take less than 10 seconds on older, slower cores and more than 0.5 seconds on fast cores. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* hurd: Only check for TLS initialization inside rtld or in static buildsSergey Bugaev2023-04-146-33/+83
| | | | | | | | | | | | | | | | | | | | | When glibc is built as a shared library, TLS is always initialized by the call of TLS_INIT_TP () macro made inside the dynamic loader, prior to running the main program (see dl-call_tls_init_tp.h). We can take advantage of this: we know for sure that __LIBC_NO_TLS () will evaluate to 0 in all other cases, so let the compiler know that explicitly too. Also, only define _hurd_tls_init () and TLS_INIT_TP () under the same conditions (either !SHARED or inside rtld), to statically assert that this is the case. Other than a microoptimization, this also helps with avoiding awkward sharing of the __libc_tls_initialized variable between ld.so and libc.so that we would have to do otherwise -- we know for sure that no sharing is required, simply because __libc_tls_initialized would always be set to true inside libc.so. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-25-bugaevc@gmail.com>
* hurd: Remove __hurd_local_reply_portSergey Bugaev2023-04-144-21/+60
| | | | | | | | | | | | | | | | | | Now that the signal code no longer accesses it, the only real user of it was mig-reply.c, so move the logic for managing the port there. If we're in SHARED and outside of rtld, we know that __LIBC_NO_TLS () always evaluates to 0, and a TLS reply port will always be used, not __hurd_reply_port0. Still, the compiler does not see that __hurd_reply_port0 is never used due to its address being taken. To deal with this, explicitly compile out __hurd_reply_port0 when we know we won't use it. Also, instead of accessing the port via THREAD_SELF->reply_port, this uses THREAD_GETMEM and THREAD_SETMEM directly, avoiding possible miscompilations. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* malloc: Assure that THP mode read do write OOB end of stringtAdhemerval Zanella2023-04-141-0/+2
|
* malloc: Assure that THP mode is always null terminatedAdhemerval Zanella2023-04-131-0/+1
|
* hurd: Mark two tests as unsupportedSamuel Thibault2023-04-131-0/+10
| | | | They make the whole testsuite hang/crash.
* hurd: Restore destroying receive rights on sigreturnSamuel Thibault2023-04-131-2/+2
| | | | | Just subtracting a ref is making signal/tst-signal signal/tst-raise signal/tst-minsigstksz-5 htl/tst-raise1 fail.
* aio: Fix freeing memorySamuel Thibault2023-04-121-1/+1
| | | | | | | | The content of the pool array is initialized only until pool_size, pointers between pool_size and pool_max_size were not initialized by the realloc call in get_elem so they should not be freed. This fixes aio tests crashing at their termination on GNU/Hurd.
* Revert "hurd: Only check for TLS initialization inside rtld or in static builds"Samuel Thibault2023-04-116-83/+33
| | | | | | | | This reverts commit b37899d34d2190ef4b454283188f22519f096048. Apparently we load libc.so (and thus start using its functions) before calling TLS_INIT_TP, so libc.so functions should not actually assume that TLS is always set up.
* hurd: Don't leak __hurd_reply_port0Sergey Bugaev2023-04-112-1/+13
| | | | | | | | | | | | | Previously, once we set up TLS, we would implicitly switch from using __hurd_reply_port0 to reply_port inside the TCB, leaving the former unused. But we never deallocated it, so it got leaked. Instead, migrate the port into the new TCB's reply_port slot. This avoids both the port leak and an extra syscall to create a new reply port for the TCB. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-28-bugaevc@gmail.com>
* hurd: Improve reply port handling when exiting signal handlersSergey Bugaev2023-04-102-29/+16
| | | | | | | | | | | | | | | | | If we're doing signals, that means we've already got the signal thread running, and that implies TLS having been set up. So we know that __hurd_local_reply_port will resolve to THREAD_SELF->reply_port, and can access that directly using the THREAD_GETMEM and THREAD_SETMEM macros. This avoids potential miscompilations, and should also be a tiny bit faster. Also, use mach_port_mod_refs () and not mach_port_destroy () to destroy the receive right. mach_port_destroy () should *never* be used on mach_task_self (); this can easily lead to port use-after-free vulnerabilities if the task has any other references to the same port. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230319151017.531737-26-bugaevc@gmail.com>