Commit Graph

15703 Commits

Author SHA1 Message Date
Adhemerval Zanella
a1950a0758 riscv: Add the clone3 wrapper
It follows the internal signature:

  extern int clone3 (struct clone_args *__cl_args, size_t __size,
 int (*__func) (void *__arg), void *__arg);

Checked on riscv64-linux-gnu-rv64imafdc-lp64d.

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
2023-05-29 17:39:57 -03:00
Dridi Boukelmoune
33d7c0e1cb posix: Add error message for EAI_OVERFLOW
Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Reviewed-by: Arjun Shankar <arjun@redhat.com>
2023-05-29 15:30:14 +02:00
Joe Simmons-Talbott
d9055634a3 setsourcefilter: Replace alloca with a scratch_buffer.
Use a scratch_buffer rather than either alloca or malloc to reduce the
possibility of a stack overflow.

Suggested-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-05-29 09:16:00 -04:00
Noah Goldstein
ed2f9dc942 x86: Use 64MB as nt-store threshold if no cacheinfo [BZ #30429]
If `non_temporal_threshold` is below `minimum_non_temporal_threshold`,
it almost certainly means we failed to read the systems cache info.

In this case, rather than defaulting the minimum correct value, we
should default to a value that gets at least reasonable
performance. 64MB is chosen conservatively to be at the very high
end. This should never cause non-temporal stores when, if we had read
cache info, we wouldn't have otherwise.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2023-05-27 21:32:57 -05:00
Samuel Thibault
9ffdcf5b79 hurd: Fix setting up signal thread stack alignment
x86_64 needs special alignment when calling functions, so we have to use
MACHINE_THREAD_STATE_SETUP_CALL for the signal thread when forking.
2023-05-28 00:30:26 +02:00
Joseph Myers
9a51f4e2b6 Add MFD_NOEXEC_SEAL, MFD_EXEC from Linux 6.3 to bits/mman-shared.h
Linux 6.3 adds new constants MFD_NOEXEC_SEAL and MFD_EXEC.  Add these
to bits/mman-shared.h (conditional on MFD_NOEXEC_SEAL not already
being defined, similar to the existing conditional on the older MFD_*
macros).

Tested for x86_64.
2023-05-26 15:04:51 +00:00
Joseph Myers
a33c211b11 Add IP_LOCAL_PORT_RANGE from Linux 6.3 to bits/in.h
Linux 6.3 adds a new constant IP_LOCAL_PORT_RANGE.  Add it to the
corresponding bits/in.h in glibc.

Tested for x86_64.
2023-05-26 15:04:13 +00:00
Joe Simmons-Talbott
02f3d4c53a setipv4sourcefilter: Avoid using alloca.
Use a scratch_buffer rather than alloca/malloc to avoid potential stack
overflow.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-26 09:58:27 -04:00
Frédéric Bérat
7aec73c406 sysdeps/pthread/eintr.c: fix warn unused result
Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-05-24 21:52:31 -04:00
Paul Pluzhnikov
6b3ddc9ae5 Regenerate configure fragment -- BZ 25337.
In commit 0b25c28e02 I updated congure.ac
but neglected to regenerate updated configure.

Fix this here.
2023-05-23 16:21:29 +00:00
Paul Pluzhnikov
0b25c28e02 Fix misspellings in sysdeps/powerpc -- BZ 25337
All fixes are in comments, so the binaries should be identical
before/after this commit, but I can't verify this.

Reviewed-by: Rajalakshmi Srinivasaraghavan <rajis@linux.ibm.com>
2023-05-23 15:23:09 +00:00
Paul Pluzhnikov
d13733c166 Fix misspellings in sysdeps/unix -- BZ 25337
Applying this commit results in bit-identical rebuild of
libc.so.6 math/libm.so.6 elf/ld-linux-x86-64.so.2 mathvec/libmvec.so.1

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2023-05-23 11:59:23 +00:00
Paul Pluzhnikov
1e9d5987fd Fix misspellings in sysdeps/x86_64 -- BZ 25337.
Applying this commit results in bit-identical rebuild of libc.so.6
math/libm.so.6 elf/ld-linux-x86-64.so.2 mathvec/libmvec.so.1

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2023-05-23 10:25:11 +00:00
Samuel Thibault
ec9a66cd01 mach: Fix accessing mach_i386.h
Fixes: 196358ae26 ("mach: Fix installing mach_i386.h")
2023-05-23 09:46:47 +02:00
Paul Pluzhnikov
1d2971b525 Fix misspellings in sysdeps/x86_64/fpu/multiarch -- BZ 25337.
Applying this commit results in a bit-identical rebuild of
mathvec/libmvec.so.1 (which is the only binary that gets rebuilt).

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2023-05-23 03:28:58 +00:00
Samuel Thibault
196358ae26 mach: Fix installing mach_i386.h
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.
2023-05-23 01:47:05 +02:00
Samuel Thibault
6151d3b79a hurd: Fix making ld.so run static binaries with retry
We need O_EXEC for __rtld_execve
2023-05-23 01:47:05 +02:00
Ronan Pigott
8f59fc79b7 Add voice-admit DSCP code point from RFC-5865 2023-05-22 22:13:41 +02:00
Andreas Schwab
ea08d8dcea Remove last remnants of have-protected 2023-05-22 13:31:04 +02:00
Stefan Liebler
368b7c614b S390: Use compile-only instead of also link-tests in configure.
Some of the s390-specific configure checks are using compile and
link configure tests.  Now use only compile tests as the link
tests fails when e.g. bootstrapping a cross-toolchain due to
missing crt-files/libc.so.  This is achieved by using
AC_COMPILE_IFELSE in configure.ac file.

This is observable e.g. when using buildroot which builds glibc
only once or the build-many-glibcs.py script.  Note that the latter
one is building glibc twice in the compilers-step (configure-checks
fails) and in the glibcs-step (configure-checks succeed).

Note, that the s390 specific configure tests for static PIE have to
link an executable to test binutils support.  Thus we can't fix
those tests.
2023-05-22 09:58:58 +02:00
Sergey Bugaev
70d0dda0c1 htl: Use __hurd_fail () instead of assigning errno
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230520115531.3911877-2-bugaevc@gmail.com>
2023-05-20 18:16:06 +02:00
Sergey Bugaev
9ec31e5727 hurd: Use __hurd_fail () instead of assigning errno
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
6639cc1002
"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>
2023-05-20 18:14:01 +02:00
Mahesh Bodapati
36cc908ed5 powerpc:GCC(<10) doesn't allow -mlong-double-64 after -mabi=ieeelongdouble
Removed -mabi=ieeelongdouble on failing tests. It resolves the error.
error: ‘-mabi=ieeelongdouble’ requires ‘-mlong-double-128’
2023-05-19 17:35:01 -05:00
Sergey Bugaev
b44c1e1252 hurd: Fix using interposable hurd_thread_self
Create a private hidden __hurd_thread_self alias, and use that one.

Fixes 2f8ecb58a5
"hurd: Fix x86_64 _hurd_tls_fork" and
c7fcce38c8
"hurd: Make sure to not use tcb->self"

Reported-by: Joseph Myers <joseph@codesourcery.com>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-05-19 20:45:51 +02:00
Sergey Bugaev
4d3f846b88 hurd: Fix __TIMESIZE on x86_64
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>
2023-05-19 20:25:37 +02:00
Samuel Thibault
4bd0f1b6ce hurd: Fix expected c++ types
90604f670c ("hurd 64bit: Add data for check-c++-types") actually added
the 32bit version. This fixes it into a 64bit version.
2023-05-19 01:45:06 +02:00
Joseph Myers
5460fbbfea Add HWCAP2_SME* from Linux 6.3 to AArch64 bits/hwcap.h
Linux 6.3 adds six HWCAP2_SME* constants for AArch64; add them to the
corresponding bits/hwcap.h in glibc.

Tested with build-many-glibcs.py for aarch64-linux-gnu.
2023-05-18 14:55:27 +00:00
Sergey Bugaev
c93ee967cd hurd: Also make it possible to call strlen very early
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>
2023-05-17 23:03:23 +02:00
Sergey Bugaev
70fd6b3b23 hurd: Fix setting up pthreads
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 be6d002ca2
"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>
2023-05-17 23:02:08 +02:00
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
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
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
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
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
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
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