Commit Graph

39995 Commits

Author SHA1 Message Date
Sergey Bugaev
2f8ecb58a5 hurd: Fix x86_64 _hurd_tls_fork
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: f6cf701efc
"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>
2023-05-17 23:00:59 +02:00
Sergey Bugaev
c7fcce38c8 hurd: Make sure to not use tcb->self
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>
2023-05-17 22:59:50 +02:00
Sergey Bugaev
aa19c68d2b hurd: Use __mach_setup_thread_call ()
...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>
2023-05-17 22:57:06 +02:00
Sergey Bugaev
01f317e98f mach: Add __mach_setup_thread_call ()
This is just like mach_setup_thread (), but it's suitable for making the
thread call a function correctly, as opposed to explicitly setting the
thread's stack and instruction pointers to the given values. Internally,
it uses MACHINE_THREAD_STATE_SETUP_CALL.

Unlike mach_setup_thread (), which is exported via mach.h for the
benefit of the Hurd exec server, __mach_setup_thread_call () is private
to glibc for the time being.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230517191436.73636-5-bugaevc@gmail.com>
2023-05-17 22:56:23 +02:00
Sergey Bugaev
be9c1b9cf4 hurd: Use MACHINE_THREAD_STATE_SETUP_CALL
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230517191436.73636-4-bugaevc@gmail.com>
2023-05-17 22:52:46 +02:00
Sergey Bugaev
4a373ea7d6 mach: Define MACHINE_THREAD_STATE_SETUP_CALL
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>
2023-05-17 22:52:39 +02:00
Flavio Cruz
3f7b800d54 Use TASK_THREAD_TIMES_INFO_COUNT when calling task_info with 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>
2023-05-17 19:23:10 +02:00
Carlos O'Donell
45af5422c1 argp: Reformat Makefile.
Reflow Makefile.
Sort using scripts/sort-makefile-lines.py.

Code generation is changed as routines are linked in sorted order
as expected.

No regressions on x86_64 and i686.
2023-05-17 08:12:08 -04:00
Florian Weimer
10a81dd4cf stdlib: Avoid undefined behavior in stdlib/tst-labs
The last loop could attempt to overflow beyond INT_MAX on 32-bit
architectures.

Also switch to GNU style.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-17 08:23:59 +02:00
Florian Weimer
8812b9900e stdlib: Use long long int in stdlib/tst-llabs
And adjust for GNU style.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-17 08:23:45 +02:00
Joseph Myers
4f009060fb Update kernel version to 6.3 in header constant tests
This patch updates the kernel version in the tests tst-mman-consts.py,
tst-mount-consts.py and tst-pidfd-consts.py to 6.3.  (There are no new
constants covered by these tests in 6.3 that need any other header
changes.)

Tested with build-many-glibcs.py.
2023-05-16 23:15:13 +00:00
DJ Delorie
088136aa02 i386: Use pthread_barrier for synchronization on tst-bz21269
So I was able to reproduce the hangs in the original source, and debug
it, and fix it.  In doing so, I realized that we can't use anything
complex to trigger the thread because that "anything" might also cause
the expected segfault and force everything out of sync again.

Here's what I ended up with, and it doesn't seem to hang where the
original one hung quite often (in a tight while..end loop).  The key
changes are:

1. Calls to futex are error checked, with retries, to ensure that the
   futexes are actually doing what they're supposed to be doing.  In the
   original code, nearly every futex call returned an error.

2. The main loop has checks for whether the thread ran or not, and
   "unlocks" the thread if it didn't (this is how the original source
   hangs).

Note: the usleep() is not for timing purposes, but just to give the
kernel an excuse to run the other thread at that time.  The test will
not hang without it, but is more likely to test the right bugfix
if the usleep() is present.
2023-05-16 15:09:18 -04:00
Joe Simmons-Talbott
d877b52d58 stdlib: Add testcases for llabs(). (BZ #30263)
Test minimum and maximum long long values, zero, 32bit crossover points, and
part of the range of long long values.  Use '-fno-builtin' to ensure we are
testing the implementation.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2023-05-16 14:38:20 -04:00
Joe Simmons-Talbott
b11db301e1 stdlib: Add testcases for labs(). (BZ #30263)
Test minimum and maximum long values, zero, and part of the range
of long values.  Use '-fno-builtin' to ensure we are testing the
implementation.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2023-05-16 14:38:17 -04:00
Joe Simmons-Talbott
0d21b3783f stdlib: Add testcases for abs(). (BZ #30263)
Test minimum and maximum int values, zero, and part of the range
of int values.  Use '-fno-builtin' to ensure we are testing the
implementation.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2023-05-16 14:38:07 -04:00
Sergey Bugaev
114f1b7881 hurd: Fix computing user stack pointer
Fixes b574ae0a28
"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>
2023-05-16 16:09:02 +02:00
Sergey Bugaev
e333759f77 hurd: Fix sc_i386_thread_state layout
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>
2023-05-16 16:09:00 +02:00
Sergey Bugaev
ce96593c88 hurd: Align signal stack pointer after allocating stackframe
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>
2023-05-16 16:08:58 +02:00
Sergey Bugaev
ff0f87632a hurd: Fix aligning signal stack pointer
Fixes 60f9bf9746
"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>
2023-05-16 16:08:45 +02:00
Carlos O'Donell
40b68e8cc0 wcsmbs: Reformat Makefile.
Reflow Makefile.
Sort using scripts/sort-makefile-lines.py.

No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.
2023-05-16 07:19:31 -04:00
Carlos O'Donell
dccee96e6d linux: Reformat Makefile.
Reflow Makefile.
Sort using scripts/sort-makefile-lines.py.

No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.
2023-05-16 07:19:31 -04:00
Carlos O'Donell
91f33a300c stdlib: Reformat Makefile.
Reflow Makefile.
Sort using scripts/sort-makefile-lines.py.

No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.
2023-05-16 07:19:31 -04:00
Carlos O'Donell
c3004417af stdio-common: Reformat Makefile.
Reflow Makefile.
Sort using scripts/sort-makefile-lines.py.

Code generation is changed as routines are linked in sorted order
as expected.

No regressions on x86_64 and i686.
2023-05-16 07:19:31 -04:00
Carlos O'Donell
bc57361e51 socket: Reformat Makefile.
Reflow Makefile.
Sort using scripts/sort-makefile-lines.py.

Code generation is changed as routines are linked in sorted order
as expected.

No regressions on x86_64 and i686.
2023-05-16 07:19:31 -04:00
Carlos O'Donell
20b6ae7e3b misc: Reformat Makefile.
Reflow Makefile.
Sort using scripts/sort-makefile-lines.py.

Code generation is changed as routines are linked in sorted order
as expected.

No regressions on x86_64 and i686.
2023-05-16 07:19:28 -04:00
Carlos O'Donell
e475bc2507 debug: Reformat Makefile.
Fix list terminator whitspace.
Sort using scripts/sort-makefile-lines.py.

No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.
2023-05-16 07:17:19 -04:00
Carlos O'Donell
aa492359f1 elf: Reformat Makefile.
Fix list terminator whitspace.
Sort using scripts/sort-makefile-lines.py.

No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.
2023-05-16 07:17:19 -04:00
Xi Ruoyao
71d9e0fe76 libio: Add __nonnull for FILE * arguments of fclose and freopen
Calling fclose or freopen with a null FILE * is undefined behavior, and
doing so in practice will cause a SIGSEGV.  So it seems suitable for
__nonnull.

This will help the compiler to warn for some buggy code, like
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109570.
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-05-16 06:56:32 -03:00
Arjun Shankar
bea1a4a773 nss: Reconcile conditional declaration and use of `is_nscd'
This change harmonizes the declaration and use of `is_nscd' and fixes a
build failure with the "--enable-static-nss --enable-nscd"
configuration options due to `is_nscd' being used undeclared.

The purpose of `is_nscd' is to avoid (nss <-> nscd) recursion in
dynamically linked libc (SHARED) that is nscd-aware (USE_NSCD), and so
its declaration and use should be guarded by the definition of those
macros.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-05-16 11:40:10 +02:00
Joseph Myers
eeef96f56c Update syscall lists for Linux 6.3
Linux 6.3 has no new syscalls.  Update the version number in
syscall-names.list to reflect that it is still current for 6.3.

Tested with build-many-glibcs.py.
2023-05-15 22:26:56 +00:00
Samuel Thibault
d6c72f976c hurd: rule out some mach headers when generating errno.h
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.
2023-05-11 01:53:49 +02:00
Flavio Cruz
3ca9f43d10 Stop checking if MiG supports retcode.
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>
2023-05-11 01:28:34 +02:00
Sachin Monga
1a57ab0c92 Added Redirects to longdouble error functions [BZ #29033]
This patch redirects the error functions to the appropriate
longdouble variants which enables the compiler to optimize
for the abi ieeelongdouble.

Signed-off-by: Sachin Monga <smonga@linux.ibm.com>
2023-05-10 13:59:48 -05:00
Carlos O'Donell
f0dbe112f5 nptl: Reformat Makefile.
Reflow all long lines adding comment terminators.
Sort all reflowed text using scripts/sort-makefile-lines.py.

No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-10 13:15:13 -04:00
Carlos O'Donell
1270549a26 scripts: Add sort-makefile-lines.py to sort Makefile variables.
The scripts/sort-makefile-lines.py script sorts Makefile variables
according to project expected order.

The script can be used like this:

$ scripts/sort-makefile-lines.py < elf/Makefile > elf/Makefile.tmp
$ mv elf/Makefile.tmp elf/Makefile

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-10 13:14:52 -04:00
Andreas Schwab
ab5aa2ee3d dlopen: skip debugger notification for DSO loaded from sprof (bug 30258)
Avoid inconsistent state in the debugger interface.
2023-05-09 14:36:34 +02:00
DJ Delorie
d1417176a3 aligned_alloc: conform to C17
This patch adds the strict checking for power-of-two alignments
in aligned_alloc(), and updates the manual accordingly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-05-08 16:40:10 -04:00
наб
cea74a4a24 testsuite: stdlib/isomac.c: fix REQUIREMENTS
All of the mentioned variables are gone. gcc is just the default and
argv[1] can be used instead. /usr/include isn't hard-coded and you can
pass argv[2] with -I... to adjust.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2023-05-08 09:59:45 -04:00
Florian Weimer
2f679937b3 manual: Remove unsupported line breaks in waiting-with-clock section
The argument to @deftypefun must be on a single line.
Also add the missing @safety for sem_clockwait.

Reported-by: Nilgün Belma Bugüner <nillguine@gmail.com>
2023-05-08 13:14:22 +02:00
Flavio Cruz
a26238d3ca Enable new device_open_new RPC in libmachuser.
Message-Id: <ZFfcM3DP+x7VHpWA@jupiter.tail36e24.ts.net>
2023-05-07 19:14:29 +02:00
Florian Weimer
bf88b47ecb Revert "riscv: Resolve symbols directly for symbols with STO_RISCV_VARIANT_CC."
This reverts commit 117e8b341c.

Reason for revert: Causes elf/tst-glibcelf and elf/tst-relro-*
to fail on all architectures.
2023-05-07 14:16:03 +02:00
Flavio Cruz
84b4a81aeb Update hurd/hurdselect.c to be more portable.
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>
2023-05-06 23:10:55 +02:00
Samuel Thibault
e64b7c26d4 hurd: Fix ld.so name
This was set to ld-x86-64.so.1 in gcc.
2023-05-06 21:00:56 +02:00
Samuel Thibault
d2593d452a hurd: Add ioperm symbol on x86_64 2023-05-06 19:06:39 +02:00
Joe Simmons-Talbott
21f0b087ee time: Remove alloca() from getdate
Reduce the usage of alloca() to the bare minimum to avoid the potential
for stack overflow.  Use __strndup to simplify the code.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-05 10:55:48 -04:00
Szabolcs Nagy
642f1b9b3d aarch64: More configure checks for libmvec
Check assembler and linker support too, not just SVE ACLE in the
compiler, since variant PCS requires at least binutils 2.32.1.
2023-05-05 11:34:44 +01:00
Szabolcs Nagy
ee68e9cba4 aarch64: SVE ACLE configure test cleanups
Use more idiomatic configure test for better autoconf cache and logs.
2023-05-05 10:28:29 +01:00
Sam James
c8bd171caf hppa: Fix 'concurrency' typo in comment
Signed-off-by: Sam James <sam@gentoo.org>
2023-05-05 10:12:39 +01:00
Flavio Cruz
4571fb8fe6 Update hurd/intr-msg.c to be more portable
Summary of the changes:
- Introduce BAD_TYPECHECK from MiG to make it simpler to do type
  checking.
- Replace int type with mach_msg_type_t. This assumes that
  mach_msg_type_t is always the same size as int which is not true for
  x86_64.
- Calculate the size and align using PTR_ALIGN_UP, which is a bit
  cleaner and similar to what we do elsewhere.
- Define mach_msg_type_t to check using designated initializers.
Message-Id: <ZFMvrIkvoCSxqB/C@jupiter.tail36e24.ts.net>
2023-05-05 02:24:38 +02:00
Flavio Cruz
3f433cb895 Update sysdeps/mach/hurd/ioctl.c to make it more portable
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>
2023-05-05 02:22:31 +02:00