about summary refs log tree commit diff
path: root/sysdeps/mach
Commit message (Collapse)AuthorAgeFilesLines
...
* hurd: Rework generating errno.hSamuel Thibault2023-08-063-41/+19
| | | | | We only need to give to gawk the headers that actually define error numbers, so let's rather filter out the other included headers early.
* configure: Use autoconf 2.71Siddhesh Poyarekar2023-07-172-152/+192
| | | | | | | | | | | | | | Bump autoconf requirement to 2.71 to allow regenerating configure on more recent distributions. autoconf 2.71 has been in Fedora since F36 and is the current version in Debian stable (bookworm). It appears to be current in Gentoo as well. All sysdeps configure and preconfigure scripts have also been regenerated; all changes are trivial transformations that do not affect functionality. Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* hurd: Implement MAP_EXCLSergey Bugaev2023-07-032-10/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MAP_FIXED is defined to silently replace any existing mappings at the address range being mapped over. This, however, is a dangerous, and only rarely desired behavior. Various Unix systems provide replacements or additions to MAP_FIXED: * SerenityOS and Linux provide MAP_FIXED_NOREPLACE. If the address space already contains a mapping in the requested range, Linux returns EEXIST. SerenityOS returns ENOMEM, however that is a bug, as the MAP_FIXED_NOREPLACE implementation is intended to be compatible with Linux. * FreeBSD provides the MAP_EXCL flag that has to be used in combination with MAP_FIXED. It returns EINVAL if the requested range already contains existing mappings. This is directly analogous to the O_EXCL flag in the open () call. * DragonFly BSD, NetBSD, and OpenBSD provide MAP_TRYFIXED, but with different semantics. DragonFly BSD returns ENOMEM if the requested range already contains existing mappings. NetBSD does not return an error, but instead creates the mapping at a different address if the requested range contains mappings. OpenBSD behaves the same, but also notes that this is the default behavior even without MAP_TRYFIXED (which is the case on the Hurd too). Since the Hurd leans closer to the BSD side, add MAP_EXCL as the primary API to request the behavior of not replacing existing mappings. Declare MAP_FIXED_NOREPLACE and MAP_TRYFIXED as aliases of (MAP_FIXED|MAP_EXCL), so any existing software that checks for either of those macros will pick them up automatically. For compatibility with Linux, return EEXIST if a mapping already exists. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230625231751.404120-5-bugaevc@gmail.com>
* hurd: Fix mapping at address 0 with MAP_FIXEDSergey Bugaev2023-07-031-2/+9
| | | | | | | | | | | Zero address passed to mmap () typically means the caller doesn't have any specific preferred address. Not so if MAP_FIXED is passed: in this case 0 means literal 0. Fix this case to pass anywhere = 0 into vm_map. Also add some documentation. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230625231751.404120-4-bugaevc@gmail.com>
* hurd: Fix calling vm_deallocate (NULL)Sergey Bugaev2023-07-031-3/+7
| | | | | | | | | | Only call vm_deallocate when we do have the old buffer, and check for unexpected errors. Spotted while debugging a msgids/readdir issue on x86_64-gnu. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230625231751.404120-3-bugaevc@gmail.com>
* hurd: Map brk non-executableSergey Bugaev2023-07-031-2/+2
| | | | | | | | | | | | The rest of the heap (backed by individual pages) is already mapped RW. Mapping these pages RWX presents a security hazard. Also, in another branch memory gets allocated using vm_allocate, which sets memory protection to VM_PROT_DEFAULT (which is RW). The mismatch between protections prevents Mach from coalescing the VM map entries. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230625231751.404120-2-bugaevc@gmail.com>
* htl: Let Mach place thread stacksSergey Bugaev2023-07-031-29/+6
| | | | | | | | | | | | | | Instead of trying to allocate a thread stack at a specific address, looping over the address space, just set the ANYWHERE flag in vm_allocate (). The previous behavior: - defeats ASLR (for Mach versions that support ASLR), - is particularly slow if the lower 4 GB of the address space are mapped inaccessible, as we're planning to do on 64-bit Hurd, - is just silly. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230625231751.404120-1-bugaevc@gmail.com>
* mach: strerror must not return NULL (bug 30555)Samuel Thibault2023-07-021-7/+19
| | | | | | | | | | | This follows 1d44530a5be2 ("string: strerror must not return NULL (bug 30555)"): « For strerror, this fixes commit 28aff047818eb1726394296d27b ("string: Implement strerror in terms of strerror_l"). This commit avoids returning NULL for strerror_l as well, although POSIX allows this behavior for strerror_l. »
* hurd: Make getrandom return ENOSYS when /dev/random is not set upSamuel Thibault2023-07-011-2/+7
| | | | So that callers (e.g. __arc4random_buf) don't try calling it again.
* hurd: Add strlcpy, strlcat, wcslcpy, wcslcat to libc.abilistFlorian Weimer2023-06-151-0/+8
|
* Add the wcslcpy, wcslcat functionsFlorian Weimer2023-06-141-0/+4
| | | | | | | These functions are about to be added to POSIX, under Austin Group issue 986. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* Implement strlcpy and strlcat [BZ #178]Florian Weimer2023-06-141-0/+4
| | | | | | | | | | | These functions are about to be added to POSIX, under Austin Group issue 986. The fortified strlcat implementation does not raise SIGABRT if the destination buffer does not contain a null terminator, it just inherits the non-failing regular strlcat behavior. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* hurd: Fix x86_64 sigreturn restoring bogus reply_portSergey Bugaev2023-06-041-38/+46
| | | | | | | | | | Since the area of the user's stack we use for the registers dump (and otherwise as __sigreturn2's stack) can and does overlap the sigcontext, we have to be very careful about the order of loads and stores that we do. In particular we have to load sc_reply_port before we start clobbering the sigcontext. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* Fix a few more typos I missed in previous round -- BZ 25337Paul Pluzhnikov2023-06-021-1/+1
|
* Fix misspellings in sysdeps/ -- BZ 25337Paul Pluzhnikov2023-05-3010-11/+11
|
* hurd: Fix setting up signal thread stack alignmentSamuel Thibault2023-05-281-7/+5
| | | | | x86_64 needs special alignment when calling functions, so we have to use MACHINE_THREAD_STATE_SETUP_CALL for the signal thread when forking.
* mach: Fix accessing mach_i386.hSamuel Thibault2023-05-234-4/+8
| | | | Fixes: 196358ae26aa ("mach: Fix installing mach_i386.h")
* mach: Fix installing mach_i386.hSamuel Thibault2023-05-232-2/+2
| | | | | | We do not want mach_i386.h to get installed into machine/, but into i386/ or x86_64/ depending where mach_i386.defs was found, i.e. according to 32/64 bitness.
* hurd: Fix making ld.so run static binaries with retrySamuel Thibault2023-05-231-1/+1
| | | | We need O_EXEC for __rtld_execve
* hurd: Use __hurd_fail () instead of assigning errnoSergey Bugaev2023-05-2044-242/+95
| | | | | | | | | | | | | | The __hurd_fail () inline function is the dedicated, idiomatic way of reporting errors in the Hurd part of glibc. Not only is it more concise than '{ errno = err; return -1; }', it is since commit 6639cc10029e24e06b34e169712b21c31b8cf213 "hurd: Mark error functions as __COLD" marked with the cold attribute, telling the compiler that this codepath is unlikely to be executed. In one case, use __hurd_dfail () over the plain __hurd_fail (). Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230520115531.3911877-1-bugaevc@gmail.com>
* hurd: Fix using interposable hurd_thread_selfSergey Bugaev2023-05-193-4/+7
| | | | | | | | | | | | Create a private hidden __hurd_thread_self alias, and use that one. Fixes 2f8ecb58a59eb82c43214d000842d99644a662d1 "hurd: Fix x86_64 _hurd_tls_fork" and c7fcce38c83a2bb665ef5dc4981bf20c7e586123 "hurd: Make sure to not use tcb->self" Reported-by: Joseph Myers <joseph@codesourcery.com> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
* hurd: Fix __TIMESIZE on x86_64Sergey Bugaev2023-05-192-1/+5
| | | | | | | We had sizeof (time_t) == 8, but __TIMESIZE == 32. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230519171516.3698754-1-bugaevc@gmail.com>
* hurd: Fix expected c++ typesSamuel Thibault2023-05-191-19/+19
| | | | | 90604f670c10 ("hurd 64bit: Add data for check-c++-types") actually added the 32bit version. This fixes it into a 64bit version.
* hurd: Also make it possible to call strlen very earlySergey Bugaev2023-05-171-0/+3
| | | | | | | | | | | | strlen, which is another ifunc-selected function, is invoked during early static executable startup if the argv arrives from the exec server. Make it not crash. Checked on x86_64-gnu: statically linked executables launched after the exec server is up now start up successfully. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230517191436.73636-10-bugaevc@gmail.com>
* hurd: Fix setting up pthreadsSergey Bugaev2023-05-172-1/+94
| | | | | | | | | | | | | | | | | | | | On x86_64, we have to pass function arguments in registers, not on the stack. We also have to align the stack pointer in a specific way. Since sharing the logic with i386 does not bring much benefit, split the file back into i386- and x86_64-specific versions, and fix the x86_64 version to set up the thread properly. Bonus: i386 keeps doing the extra RPC inside __thread_set_pcsptp to fetch the state of the thread before setting it; but x86_64 no lnoger does that. Checked on x86_64-gnu and i686-gnu. Fixes be6d002ca277ffc90058d382396150cb0e785b9c "hurd: Set up the basic tree for x86_64-gnu" Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230517191436.73636-9-bugaevc@gmail.com>
* hurd: Fix x86_64 _hurd_tls_forkSergey Bugaev2023-05-171-6/+19
| | | | | | | | | | | | | | | It is illegal to call thread_get_state () on mach_thread_self (), so this codepath cannot be used as-is to fork the calling thread's TLS. Fortunately we can use THREAD_SELF (aka %fs:0x0) to find out the value of our fs_base without calling into the kernel. Fixes: f6cf701efc61c9ad910372bda14b9a235db310a8 "hurd: Implement TLS for x86_64" Checked on x86_64-gnu: fork () now works! Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230517191436.73636-8-bugaevc@gmail.com>
* hurd: Make sure to not use tcb->selfSergey Bugaev2023-05-173-26/+14
| | | | | | | | | | | | | | | | | | | | Unlike sigstate->thread, tcb->self did not hold a Mach port reference on the thread port it names. This means that the port can be deallocated, and the name reused for something else, without anyone noticing. Using tcb->self will then lead to port use-after-free. Fortunately nothing was accessing tcb->self, other than it being intially set to then-valid thread port name upon TCB initialization. To assert that this keeps being the case without altering TCB layout, rename self -> self_do_not_use, and stop initializing it. Also, do not (re-)allocate a whole separate and unused stack for the main thread, and just exit __pthread_setup early in this case. Found upon attempting to use tcb->self and getting unexpected crashes. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230517191436.73636-7-bugaevc@gmail.com>
* hurd: Use __mach_setup_thread_call ()Sergey Bugaev2023-05-172-7/+9
| | | | | | | | | | | ...instead of mach_setup_thread (), which is unsuitable for setting up function calls. Checked on x86_64-gnu: the signal thread no longer crashes upon trying to process a message. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230517191436.73636-6-bugaevc@gmail.com>
* mach: Define MACHINE_THREAD_STATE_SETUP_CALLSergey Bugaev2023-05-172-0/+22
| | | | | | | | | | | | | | | | | | | | | The existing two macros, MACHINE_THREAD_STATE_SET_PC and MACHINE_THREAD_STATE_SET_SP, can be used to set program counter and the stack pointer registers in a machine-specific thread state structure. Useful as it is, this may not be enough to set up the thread to make a function call, because the machine-specific ABI may impose additional requirements. In particular, x86_64 ABI requires that upon function entry, the stack pointer is 8 less than 16-byte aligned (sp & 15 == 8). To deal with this, introduce a new macro, MACHINE_THREAD_STATE_SETUP_CALL (), which sets both stack and instruction pointers, and also applies any machine-specific requirements to make a valid function call. The default implementation simply forwards to MACHINE_THREAD_STATE_SET_PC and MACHINE_THREAD_STATE_SET_SP, but on x86_64 we additionally align the stack pointer. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230517191436.73636-3-bugaevc@gmail.com>
* Use TASK_THREAD_TIMES_INFO_COUNT when calling task_info with ↵Flavio Cruz2023-05-171-1/+1
| | | | | | | | | TASK_THREAD_TIMES_INFO This hasn't caused any problems yet but we are passing a pointer to struct task_thread_times_info which can cause problems if we populate over the existing size of the struct. Message-Id: <ZGRDDNcOM2hA3CuT@jupiter.tail36e24.ts.net>
* hurd: Fix computing user stack pointerSergey Bugaev2023-05-161-1/+1
| | | | | | | | | | Fixes b574ae0a2876ee94e4fe617f878407bf818c2df0 "hurd: Implement sigreturn for x86_64" Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230515083323.1358039-5-bugaevc@gmail.com>
* hurd: Fix sc_i386_thread_state layoutSergey Bugaev2023-05-162-0/+14
| | | | | | | | | | | | | | | | | | | The real i386_thread_state Mach structure has an alignment of 8 on x86_64. However, in struct sigcontext, the compiler was packing sc_gs (which is the first member of sc_i386_thread_state) into the same 8-byte slot as sc_error; this resulted in the rest of sc_i386_thread_state members having wrong offsets relative to each other, and the overall sc_i386_thread_state layout mismatching that of i386_thread_state. Fix this by explicitly adding the required padding members, and statically asserting that this results in the desired alignment. The same goes for sc_i386_float_state. Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230515083323.1358039-4-bugaevc@gmail.com>
* hurd: Align signal stack pointer after allocating stackframeSergey Bugaev2023-05-161-3/+2
| | | | | | | | | | | sizeof (*stackframe) appears to be divisible by 16, but we should not rely on that. So make sure to leave enough space for the stackframe first, and then align the final pointer at 16 bytes. Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230515083323.1358039-3-bugaevc@gmail.com>
* hurd: Fix aligning signal stack pointerSergey Bugaev2023-05-161-1/+1
| | | | | | | | | | | Fixes 60f9bf974694d50daf58d46347b06a5975ac5ddd "hurd: Port trampoline.c to x86_64" Checked on x86_64-gnu. Reported-by: Bruno Haible <bruno@clisp.org> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230515083323.1358039-2-bugaevc@gmail.com>
* hurd: rule out some mach headers when generating errno.hSamuel Thibault2023-05-112-3/+4
| | | | | | | | | | While mach/kern_return.h happens to pull mach/machine/kern_return.h, mach/machine/boolean.h, and mach/machine/vm_types.h (and realpath-ing them exposes the machine-specific machine symlink content), those headers do not actually define anything machine-specific for the content of errno.h. So we can just rule out these machine-specific from the dependency comment.
* Stop checking if MiG supports retcode.Flavio Cruz2023-05-112-62/+0
| | | | | | | | | | | | | | | | We already did the same change for Hurd (https://git.savannah.gnu.org/cgit/hurd/hurd.git/commit/?id=ef5924402864ef049f40a39e73967628583bc1a4) Due to MiG requiring the subsystem to be defined early in order to know the size of a port, this was causing a division by zero error during ./configure. We could have just move subsystem to the top of the snippet, however it is simpler to just remove the check given that we have no plans to use some other MiG anyway. HAVE_MIG_RETCODE is removed completely since this will be a no-op either way (compiling against old Hurd headers will work the same, new Hurd headers will result in the same stubs since retcode is a no-op). Message-Id: <ZFspor91aoMwbh9T@jupiter.tail36e24.ts.net>
* Update hurd/hurdselect.c to be more portable.Flavio Cruz2023-05-062-5/+31
| | | | | | | | | | | Summary of changes: - Use BAD_TYPECHECK to perform type checking in a cleaner way. BAD_TYPECHECK is moved into sysdeps/mach/rpc.h to avoid duplication. - Remove assertions for mach_msg_type_t since those won't work for x86_64. - Update message structs to use mach_msg_type_t directly. - Use designated initializers. Message-Id: <ZFa+roan3ioo0ONM@jupiter.tail36e24.ts.net>
* hurd: Fix ld.so nameSamuel Thibault2023-05-061-0/+1
| | | | This was set to ld-x86-64.so.1 in gcc.
* hurd: Add ioperm symbol on x86_64Samuel Thibault2023-05-062-0/+6
|
* Update sysdeps/mach/hurd/ioctl.c to make it more portableFlavio Cruz2023-05-051-20/+27
| | | | | | | | | | | | | | | Summary of the changes: - Update msg_align to use ALIGN_UP like we have done in previous patches. Use it below whenever necessary to avoid repeating the same alignment logic. - Define BAD_TYPECHECK to make it easier to do type checking in a few places below. - Update io2mach_type to use designated initializers. - Make RetCodeType use mach_msg_type_t. mach_msg_type_t is 8 byte for x86_64, so this make it portable. - Also call msg_align for _IOT_COUNT2/_IOT_TYPE2 since it is more correct. Message-Id: <ZFMvVsuFKwIy2dUS@jupiter.tail36e24.ts.net>
* hurd 64bit: Make dev_t word typeSamuel Thibault2023-05-021-1/+1
| | | | | | | dev_t are 64bit on Linux ports, so better increase their size on 64bit Hurd. It happens that this helps with BZ 23084 there: st_dev has type fsid_t (quad) and is specified by POSIX to have type dev_t. Making dev_t 64bit makes these match.
* hurd 64bit: Fix struct msqid_ds and shmid_ds fieldsSamuel Thibault2023-05-012-0/+83
| | | | | | | | The standards want msg_lspid/msg_lrpid/shm_cpid/shm_lpid to be pid_t, see BZ 23083 and 23085. We can leave them __rpc_pid_t on i386 for ABI compatibility, but avoid hitting the issue on 64bit.
* hurd 64bit: Fix ipc_perm fields typesSamuel Thibault2023-05-011-0/+33
| | | | | | | | | | | The standards want uid/cuid to be uid_t, gid/cgid to be gid_t and mode to be mode_t, see BZ 23082. We can leave them short ints on i386 for ABI compatibility, but avoid hitting the issue on 64bit. bits/ipc.h ends up being exactly the same in sysdeps/gnu/ and sysdeps/unix/sysv/linux/, so remove the latter.
* hurd 64bit: Fix flock fields typesSamuel Thibault2023-05-014-27/+95
| | | | | | | The standards want l_type and l_whence to be short ints, see BZ 23081. We can leave them ints on i386 for ABI compatibility, but avoid hitting the issue on 64bit.
* hurd 64bit: Add data for check-c++-typesSamuel Thibault2023-05-011-0/+67
|
* hurd 64bit: Fix pthread_t/thread_t type to longSamuel Thibault2023-05-012-0/+48
| | | | So that they can be trivially cast to pointer type, like with nptl.
* hurd 64bit: Add missing data file for check-localplt testSamuel Thibault2023-05-011-0/+44
|
* hurd 64bit: Add missing libanlSamuel Thibault2023-05-011-0/+4
| | | | The move of libanl to libc was in glibc 2.34 for nptl only.
* hurd: Also XFAIL missing SA_NOCLDWAIT on 64bitSamuel Thibault2023-05-011-0/+5
|
* hurd: Add expected abilist files for x86_64Sergey Bugaev2023-05-0112-0/+3687
| | | | | | | | | | These were created by creating stub files, running 'make update-abi', and reviewing the results. Also, set baseline ABI to GLIBC_2.38, the (upcoming) first glibc release to first have x86_64-gnu support. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>