]> sourceware.org Git - glibc.git/log
glibc.git
4 years agoLinux: getdents64 syscall number is always available on MIPS
Florian Weimer [Tue, 3 Mar 2020 11:20:31 +0000 (12:20 +0100)]
Linux: getdents64 syscall number is always available on MIPS

Due to the built-in tables, __NR_getdents64 is always defined,
although it may not be supported at run time.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: Clean up preadv2, pwritev2 system call names
Florian Weimer [Tue, 3 Mar 2020 11:18:22 +0000 (12:18 +0100)]
Linux: Clean up preadv2, pwritev2 system call names

With the built-in tables __NR_preadv2 and __NR_pwritev2 are always
defined.

The kernel has never defined __NR_preadv64v2 and __NR_pwritev64v2
and is unlikely to do so, given that the preadv2 and pwritev2 system
calls themselves are 64-bit.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: exit_group syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:17:24 +0000 (12:17 +0100)]
Linux: exit_group syscall number is always available

Due to the built-in tables, __NR_exit_group is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: set_tid_address syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:16:55 +0000 (12:16 +0100)]
Linux: set_tid_address syscall number is always available

Due to the built-in tables, __NR_set_tid_address is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: pkey_mprotect syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:16:35 +0000 (12:16 +0100)]
Linux: pkey_mprotect syscall number is always available

Due to the built-in tables, __NR_pkey_mprotect is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: rt_sigqueueinfo syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:16:15 +0000 (12:16 +0100)]
Linux: rt_sigqueueinfo syscall number is always available

Due to the built-in tables, __NR_rt_sigqueueinfo is always defined.

sysdeps/pthread/time_routines.c is not updated because it is shared with
Hurd.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: getrandom syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:15:38 +0000 (12:15 +0100)]
Linux: getrandom syscall number is always available

Due to the built-in tables, __NR_getrandom is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: Clean up preadv, pwritev system call names
Florian Weimer [Tue, 3 Mar 2020 11:15:06 +0000 (12:15 +0100)]
Linux: Clean up preadv, pwritev system call names

The names __NR_preadv64, __NR_pwritev64 appear to be a glibc invention.
With the built-in tables, __NR_preadv and __NR_pwritev are always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: Clean up pread64/pwrite64 system call names
Florian Weimer [Sun, 9 Feb 2020 15:07:00 +0000 (16:07 +0100)]
Linux: Clean up pread64/pwrite64 system call names

Linux removed the last definitions of __NR_pread and __NR_pwrite
in commit 4ba66a9760722ccbb691b8f7116cad2f791cca7b, the removal
of the blackfin port.  All architectures now define __NR_pread64 and
__NR_pwrite64 only.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: sigaltstack syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:13:29 +0000 (12:13 +0100)]
Linux: sigaltstack syscall number is always available

Due to the built-in tables, __NR_sigaltstack is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: sched_getaffinity syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:13:07 +0000 (12:13 +0100)]
Linux: sched_getaffinity syscall number is always available

Due to the built-in tables, __NR_sched_getaffinity is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: sched_setaffinity syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:12:42 +0000 (12:12 +0100)]
Linux: sched_setaffinity syscall number is always available

Due to the built-in tables, __NR_sched_setaffinity is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: statx syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:12:11 +0000 (12:12 +0100)]
Linux: statx syscall number is always available

Due to the built-in tables, __NR_statx is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: mq_* syscall numbers are always available
Florian Weimer [Tue, 3 Mar 2020 11:11:49 +0000 (12:11 +0100)]
Linux: mq_* syscall numbers are always available

Due to the built-in tables, __NR_mq_getsetattr, __NR_mq_notify,
__NR_mq_open, __NR_mq_timedreceive, __NR_mq_timedsend, __NR_mq_unlink
are always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: mlock2 syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:11:26 +0000 (12:11 +0100)]
Linux: mlock2 syscall number is always available

Due to the built-in tables, __NR_mlock2 is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: copy_file_range syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:11:01 +0000 (12:11 +0100)]
Linux: copy_file_range syscall number is always available

Due to the built-in tables, __NR_copy_file_range is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoLinux: renameat2 syscall number is always available
Florian Weimer [Tue, 3 Mar 2020 11:06:39 +0000 (12:06 +0100)]
Linux: renameat2 syscall number is always available

Due to the built-in tables, __NR_renameat2 is always defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agobuild-many-glibcs.py: Add list-compilers, list-glibcs commands
Florian Weimer [Sat, 29 Feb 2020 11:44:31 +0000 (12:44 +0100)]
build-many-glibcs.py: Add list-compilers, list-glibcs commands

These commands are helpful for scripting the distribution of
build-many-glibcs.py runs across multiple builders.

4 years agobuild-many-glibcs.py: Add --shallow option
Florian Weimer [Fri, 28 Feb 2020 11:32:28 +0000 (12:32 +0100)]
build-many-glibcs.py: Add --shallow option

The history is not used by build-many-glibcs.py itself.
--replace-sources deletes an existing source tree before switching
the version.  But some users prefer to have the full history
available, therefore make shallow clones optional with the --shallow
option.

4 years agoFixed typo in run_command_array() in support/shell-container.c
Girish Joshi [Mon, 2 Mar 2020 20:19:29 +0000 (15:19 -0500)]
Fixed typo in run_command_array() in support/shell-container.c

https://sourceware.org/bugzilla/show_bug.cgi?id=23991

4 years agoAdd missing libc_hidden_def for __utimensat64
Andreas Schwab [Mon, 2 Mar 2020 15:25:24 +0000 (16:25 +0100)]
Add missing libc_hidden_def for __utimensat64

4 years agoelf: Add elf/check-wx-segment, a test for the presence of WX segments
Florian Weimer [Mon, 2 Mar 2020 13:24:27 +0000 (14:24 +0100)]
elf: Add elf/check-wx-segment, a test for the presence of WX segments

Writable, executable segments defeat security hardening.  The
existing check for DT_TEXTREL does not catch this.

hppa and SPARC currently keep the PLT in an RWX load segment.

4 years agoi386: Use comdat instead of .gnu.linkonce for i386 setup pic register (BZ #20543)
Adhemerval Zanella [Fri, 28 Feb 2020 13:46:14 +0000 (10:46 -0300)]
i386: Use comdat instead of .gnu.linkonce for i386 setup pic register (BZ #20543)

GCC has moved from using .gnu.linkonce for i386 setup pic register with
minimum current version (as for binutils minimum binutils that support
comdat).

Trying to pinpoint when binutils has added comdat support for i686, it
seems it was around 2004 [1].  I also checking with some ancient
binutils older than 2.16 I see:

test.o: In function `__x86.get_pc_thunk.bx':
test.o(.text.__x86.get_pc_thunk.bx+0x0): multiple definition of `__x86.get_pc_thunk.bx'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../i386-linux-gnu/crti.o(.gnu.linkonce.t.__x86.get_pc_thunk.bx+0x0): first defined here

Which seems that such version can not handle either comdat at all or
a mix of linkonce and comdat.  For binutils 2.16.1 I am getting a
different issue trying to link a binary with and more recent
ctri.o (unrecognized relocation (0x2b) in section `.init', which is
R_386_GOT32X and old binutils won't generate it anyway).

So I think that either unlikely someone will use an older binutils than
the one used to glibc and even this scenario may fail with some issue
as the R_386_GOT32X.  Also, 2.16.1 is quite old and not really supported
(glibc itself required 2.25).

Checked on i686-linux-gnu.

[1] https://gcc.gnu.org/ml/gcc/2004-05/msg00030.html

4 years agoldbl-128ibm-compat: link tst-ldbl-efgcvt against loader too
Paul E. Murphy [Thu, 27 Feb 2020 19:57:57 +0000 (13:57 -0600)]
ldbl-128ibm-compat: link tst-ldbl-efgcvt against loader too

This also requires the linker workaround to ensure everything links
correctly.  See comment in sysdeps/powerpc/powerpc64/le/Makefile
for details.

4 years agoldbl-128ibm-compat: enforce ibm128 on compat tests
Paul E. Murphy [Fri, 7 Feb 2020 20:06:53 +0000 (14:06 -0600)]
ldbl-128ibm-compat: enforce ibm128 on compat tests

For lack of a more comprehensive solution, tack on the ibm128 ABI
compiler options for the totalorder{,mag}l compat tests which exist
prior to enabling this feature.

4 years agoldbl-128ibm-compat: Provide nexttoward functions
Gabriel F. T. Gomes [Tue, 5 Jun 2018 19:54:40 +0000 (16:54 -0300)]
ldbl-128ibm-compat: Provide nexttoward functions

The functions in the nexttoward family are special, in the sense that
they always have a long double argument, regardless of their suffix
(i.e.: nexttowardf and nexttoward have a long double argument, besides
the float and double arguments).

On top of that, they are also special because nexttoward functions are
not part of the _FloatN API, hence __nexttowardf128 do not exist.

This patch adds 4 new function implementations for the new long double
format:

  __nexttoward_to_ieee128
  __nexttowardf_to_ieee128
  __nexttowardieee128 (as an alias to __nextafterieee128)

Likewise, rename "long double" "_Float128" in shared ldbl-128
files to ensure correct type is used irrespective of ABI
switches.

Thank you to those who helped out with this patch:

Co-Authored-By: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoldbl-128ibm-compat: Provide a significand implementation
Tulio Magno Quites Machado Filho [Mon, 18 Jun 2018 23:57:14 +0000 (20:57 -0300)]
ldbl-128ibm-compat: Provide a significand implementation

Reuse the template in order to provide the global symbol
__significandieee128.

4 years agoldbl-128ibm-compat: Redirect complex math functions
Rajalakshmi Srinivasaraghavan [Wed, 4 Apr 2018 01:45:24 +0000 (07:15 +0530)]
ldbl-128ibm-compat: Redirect complex math functions

The API doesn't change, i.e. compilers using a long double format compatible
with the IEEE 128-bit extended precision format are redirected from *l
functions to __*ieee128 symbols using the same mechanism already
used with -mlong-double-64 for complex math functions.

4 years agoldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions
Tulio Magno Quites Machado Filho [Wed, 20 Jun 2018 00:41:16 +0000 (21:41 -0300)]
ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functions

Modify the headers to redirect long double functions to global __*f128
symbols or to __*ieee128 otherwise.

Most of the functions in math.h benefit from the infrastructure already
available for __LDBL_COMPAT.  The only exceptions are nexttowardf and
nexttoward that need especial treatment.

Both math/bits/mathcalls-helper-functions.h and math/bits/mathcalls.h
were modified in order to provide alternative redirection destinations
that are essential to support functions that should not be redirected to
the same name pattern of the rest of the functions, i.e.: __fpclassify,
__signbit, __iseqsig, __issignaling, isinf, finite and isnan, which will
be redirected to __*f128 instead of __*ieee128 used for the rest.

4 years agoposix: Remove posix waitid
Adhemerval Zanella [Tue, 19 Nov 2019 21:34:19 +0000 (18:34 -0300)]
posix: Remove posix waitid

The POSIX waitid implementation is problematic in some ways:

  - It emulates using waitpid, which default implementation calls
    wait4 and wait4 returns ENOSYS as default.

  - Also by using waitpid it does not allod support the WNOWAIT,
    WEXITED, WSTOPPED, or WCONTINUED flag.  With current POSIX
    specification the flags are no longer marked as optional.

Also due BZ#23091 Hurd still uses the implementation, so it is moved
to as a Hurd arch-specific folder (with some minor cleanups).

Checked against a i686-gnu (run-built-tests=no)

4 years agoposix: Refactor tst-waitid (BZ #14666)
Adhemerval Zanella [Tue, 19 Nov 2019 20:21:26 +0000 (17:21 -0300)]
posix: Refactor tst-waitid (BZ #14666)

The main changes are:

  - Adapt to libsupport.
  - Synchronize the signal handler using atomics.
  - Replace waitpid by waitid calls.
  - Use support_process_state_wait to wait for child state.
  - Add tests for P_PGID and P_ALL.
  - Use sigwaitinfo instead of global state set by the signal handler.

Checked on x86_64-linux-gnu and i686-linux-gnu.

4 years agosupport: Add support_process_state_wait
Adhemerval Zanella [Tue, 19 Nov 2019 20:17:05 +0000 (17:17 -0300)]
support: Add support_process_state_wait

It allows parent process to wait for child state using a polling
strategy over procfs on Linux.  The polling is used over ptrace to
avoid the need to handle signals on the target pid and to handle some
system specific limitation (such as YAMA).

The polling has some limitations, such as resource consumption due
the procfs read in a loop and the lack of synchronization after the
state is obtained.

The interface idea is to simplify some sleep synchronization waitid
tests and is to reduce timeouts by replacing arbitrary waits.

4 years agomalloc/tst-mallocfork2: Kill lingering process for unexpected failures
Adhemerval Zanella [Thu, 20 Feb 2020 17:37:04 +0000 (14:37 -0300)]
malloc/tst-mallocfork2: Kill lingering process for unexpected failures

If the test fails due some unexpected failure after the children
creation, either in the signal handler by calling abort or in the main
loop; the created children might not be killed properly.

This patches fixes it by:

  * Avoid aborting in the signal handler by setting a flag that
    an error has occured and add a check in the main loop.

  * Add a atexit handler to handle kill child processes.

Checked on x86_64-linux-gnu.

4 years agoelf: Apply attribute_relro to pointers in elf/dl-minimal.c
Florian Weimer [Wed, 26 Feb 2020 14:58:23 +0000 (15:58 +0100)]
elf: Apply attribute_relro to pointers in elf/dl-minimal.c

The present code leaves the function pointers unprotected, but moves
some of the static functions into .data.rel.ro instead.  This causes
the linker to produce an allocatable, executable, writable section
and eventually an RWX load segment.  Not only do we really do not
want that, it also breaks valgrind because valgrind does not load
debuginfo from the mmap interceptor if all it sees are RX and RWX
mappings.

Fixes commit 3a0ecccb599a6b1ad4b149dc569c0080e92d057b ("ld.so: Do not
export free/calloc/malloc/realloc functions [BZ #25486]").

4 years agopowerpc: Refactor fenvinline.h
Rogerio Alves [Mon, 10 Feb 2020 15:09:02 +0000 (12:09 -0300)]
powerpc: Refactor fenvinline.h

This patch refactor fenviline.h replaces some statements for
builtins.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agonss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS
Florian Weimer [Tue, 25 Feb 2020 15:15:09 +0000 (16:15 +0100)]
nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONS

This commit removes the minor optimization based on strong aliases
because it loses type safety.

4 years agocsu: Use ELF constructor instead of _init in libc.so
Florian Weimer [Mon, 24 Feb 2020 10:50:24 +0000 (11:50 +0100)]
csu: Use ELF constructor instead of _init in libc.so

On !ELF_INITFINI architectures, _init is no longer called by the
dynamic linker.  We can use an ELF constructor instead because the
constructor order does not matter.  (The other constructors are used
to set up libio vtable bypasses and do not depend on this
initialization routine.)

4 years agoldbl-128ibm: make ieee754.h work with IEEE 128 long double
Paul E. Murphy [Fri, 7 Feb 2020 20:07:01 +0000 (14:07 -0600)]
ldbl-128ibm: make ieee754.h work with IEEE 128 long double

Instead of attempting something more creative, just copy
the small struct from ldbl-128 and enable it when IEEE
long double is present, and update the ibm long double
variant if supported.

Likewise, provide a shadow copy of math_ldbl.h to prevent
the ibm128 specific long double header from poisoning
unrelated files due to it's usage in math_private.h.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoldbl-128ibm-compat: fixup subdir location of several funcs
Paul E. Murphy [Fri, 7 Feb 2020 20:06:41 +0000 (14:06 -0600)]
ldbl-128ibm-compat: fixup subdir location of several funcs

We want to ensure that if a second file is built to support
ieee128 long double, we built its companion implementation
with ibm128 long double.  The shared object versions of these
files build correctly because the aliasing is sufficiently
complex to prevent the redirects from applying when defining
them.

However, this does not prevent the static object variants
from becoming quietly broken due to redirects.  This is
intentionally avoided by marking such objects to be built
with -mabi=ibmlongdouble.

Shuffle the misplaced routines to build against the subdir
which defines the needed symbols.

4 years agoldbl-128ibm-compat: enforce correct abi flags on internal file
Paul E. Murphy [Fri, 7 Feb 2020 20:06:35 +0000 (14:06 -0600)]
ldbl-128ibm-compat: enforce correct abi flags on internal file

A number of utility files and helper objects should also be
explicitly configured to build with the ibm128 ABI to prevent
gremlins when enabling IEEE long double.

4 years agoldbl-128ibm-compat: Provide ieee128 symbols to narrow functions
Tulio Magno Quites Machado Filho [Wed, 13 Jun 2018 20:12:46 +0000 (17:12 -0300)]
ldbl-128ibm-compat: Provide ieee128 symbols to narrow functions

Move the narrow math aliasing macros into a new sysdep header file
math-narrow-alias-float128.h.  Then, provide an override header
to supply the necessary changes to supply the *ieee128 aliases of
these symbols.

This adds ieee128 aliases for faddl, fdivl, fmull, fsubl, daddl, ddivl,
dmull, dsubl.

4 years agoUndefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]
Tulio Magno Quites Machado Filho [Tue, 19 Jun 2018 00:11:26 +0000 (21:11 -0300)]
Undefine redirections after long double definition on __LDBL_COMPAT [BZ #23294]

After defining the long double redirections to double, __MATHDECL_1 has
to be redefined to its previous state in order to avoid redirecting all
subsequent types.

4 years agonios2: Fix Linux kABI for syscall return
Adhemerval Zanella [Thu, 20 Feb 2020 13:08:06 +0000 (10:08 -0300)]
nios2: Fix Linux kABI for syscall return

From the type introduced at 861be5fd66.

4 years agoFix use-after-free in glob when expanding ~user (bug 25414)
Andreas Schwab [Wed, 19 Feb 2020 16:21:46 +0000 (17:21 +0100)]
Fix use-after-free in glob when expanding ~user (bug 25414)

The value of `end_name' points into the value of `dirname', thus don't
deallocate the latter before the last use of the former.

4 years agonptl: Move pthread_setschedparam implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:51:05 +0000 (11:51 +0100)]
nptl: Move pthread_setschedparam implementation into libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_getschedparam implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:49:13 +0000 (11:49 +0100)]
nptl: Move pthread_getschedparam implementation into libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdd hidden prototypes for __sched_getparam, __sched_getscheduler
Florian Weimer [Mon, 10 Feb 2020 09:38:37 +0000 (10:38 +0100)]
Add hidden prototypes for __sched_getparam, __sched_getscheduler

This will enable them to be used in libc.so without PLTs.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_cond_init implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:47:13 +0000 (11:47 +0100)]
nptl: Move pthread_cond_init implementation into libc

It is necessary to export __pthread_cond_init from libc because
the C11 condition variable needs it and is still left in libpthread.

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_cond_destroy implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:35:05 +0000 (11:35 +0100)]
nptl: Move pthread_cond_destroy implementation into libc

It is necessary to export __pthread_cond_destroy from libc because
the C11 condition variable needs it and is still left in libpthread.

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_condattr_init implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:32:45 +0000 (11:32 +0100)]
nptl: Move pthread_condattr_init implementation into libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_condattr_destroy implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:30:59 +0000 (11:30 +0100)]
nptl: Move pthread_condattr_destroy implementation into libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_attr_setscope implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:29:16 +0000 (11:29 +0100)]
nptl: Move pthread_attr_setscope implementation into libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_attr_getscope implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:26:00 +0000 (11:26 +0100)]
nptl: Move pthread_attr_getscope implementation into libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_attr_setschedpolicy implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:23:32 +0000 (11:23 +0100)]
nptl: Move pthread_attr_setschedpolicy implementation into libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Move pthread_attr_getschedpolicy implementation into libc
Florian Weimer [Mon, 10 Feb 2020 10:20:30 +0000 (11:20 +0100)]
nptl: Move pthread_attr_getschedpolicy implementation into libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Sort routines list in Makefile alphabetically
Florian Weimer [Mon, 10 Feb 2020 10:17:11 +0000 (11:17 +0100)]
nptl: Sort routines list in Makefile alphabetically

This will make it easier to review changes which move implementations
from libpthread to libc.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agonptl: Use .NOTPARALLEL in Makefile only if actually running tests
Florian Weimer [Mon, 10 Feb 2020 10:28:31 +0000 (11:28 +0100)]
nptl: Use .NOTPARALLEL in Makefile only if actually running tests

It is safe to build the tests in parallel.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoBlock all signals on timer_create thread (BZ#10815)
Adhemerval Zanella [Mon, 9 Dec 2019 17:33:33 +0000 (14:33 -0300)]
Block all signals on timer_create thread (BZ#10815)

The behavior of the signal mask on threads created by timer_create
for SIGEV_THREAD timers are implementation-defined and glibc explicit
unblocks all signals before calling the user-defined function.

This behavior, although not incorrect standard-wise, opens a race if a
program using a blocked rt-signal plus sigwaitinfo (and without an
installed signal handler for the rt-signal) receives a signal while
executing the used-defined function for SIGEV_THREAD.

A better alternative discussed in bug report is to rather block all
signals (besides the internal ones not available to application
usage).

This patch fixes this issue by only unblocking SIGSETXID (used on
set*uid function) and SIGCANCEL (used for thread cancellation).

Checked on x86_64-linux-gnu and i686-linux-gnu.

4 years agoFix tst-pkey expectations on pkey_get [BZ #23202]
Lucas A. M. Magalhaes [Mon, 17 Feb 2020 12:09:52 +0000 (09:09 -0300)]
Fix tst-pkey expectations on pkey_get [BZ #23202]

From the GNU C Library manual, the pkey_set can receive a combination of
PKEY_DISABLE_WRITE and PKEY_DISABLE_ACCESS.  However PKEY_DISABLE_ACCESS
is more restrictive than PKEY_DISABLE_WRITE and includes its behavior.

The test expects that after setting
(PKEY_DISABLE_WRITE|PKEY_DISABLE_ACCESS) pkey_get should return the
same.  This may not be true as PKEY_DISABLE_ACCESS will succeed in
describing the state of the key in this case.

The pkey behavior during signal handling is different between x86 and
POWER.  This change make the test compatible with both architectures.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoy2038: linux: Provide __gettimeofday64 implementation
Lukasz Majewski [Mon, 27 Jan 2020 14:37:07 +0000 (15:37 +0100)]
y2038: linux: Provide __gettimeofday64 implementation

In the glibc the gettimeofday can use vDSO (on power and x86 the
USE_IFUNC_GETTIMEOFDAY is defined), gettimeofday syscall or 'default'
___gettimeofday() from ./time/gettime.c (as a fallback).

In this patch the last function (___gettimeofday) has been refactored and
moved to ./sysdeps/unix/sysv/linux/gettimeofday.c to be Linux specific.

The new __gettimeofday64 explicit 64 bit function for getting 64 bit time from
the kernel (by internally calling __clock_gettime64) has been introduced.

Moreover, a 32 bit version - __gettimeofday has been refactored to internally
use __gettimeofday64.

The __gettimeofday is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary check for time_t potential
overflow and conversion of struct __timeval64 to 32 bit struct timespec.

The iFUNC vDSO direct call optimization has been removed from both i686 and
powerpc32 (USE_IFUNC_GETTIMEOFDAY is not defined for those architectures
anymore). The Linux kernel does not provide a y2038 safe implementation of
gettimeofday neither it plans to provide it in the future, clock_gettime64
should be used instead. Keeping support for this optimization would require
to handle another build permutation (!__ASSUME_TIME64_SYSCALLS &&
USE_IFUNC_GETTIMEOFDAY) which adds more complexity and has limited use
(since the idea is to eventually have a y2038 safe glibc build).

Build tests:
./src/scripts/build-many-glibcs.py glibcs

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

Above tests were performed with Y2038 redirection applied as well as without
to test proper usage of both __gettimeofday64 and __gettimeofday.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
[Including some commit message improvement]

4 years agoLinux: Work around kernel bugs in chmod on /proc/self/fd paths [BZ #14578]
Florian Weimer [Tue, 18 Feb 2020 16:52:27 +0000 (17:52 +0100)]
Linux: Work around kernel bugs in chmod on /proc/self/fd paths [BZ #14578]

It appears that the ability to change symbolic link modes through such
paths is unintended.  On several file systems, the operation fails with
EOPNOTSUPP, even though the symbolic link permissions are updated.
The expected behavior is a failure to update the permissions, without
file system changes.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
4 years agoIntroduce <elf-initfini.h> and ELF_INITFINI for all architectures
Florian Weimer [Tue, 18 Feb 2020 13:42:41 +0000 (14:42 +0100)]
Introduce <elf-initfini.h> and ELF_INITFINI for all architectures

This supersedes the init_array sysdeps directory.  It allows us to
check for ELF_INITFINI in both C and assembler code, and skip DT_INIT
and DT_FINI processing completely on newer architectures.

A new header file is needed because <dl-machine.h> is incompatible
with assembler code.  <sysdep.h> is compatible with assembler code,
but it cannot be included in all assembler files because on some
architectures, it redefines register names, and some assembler files
conflict with that.

<elf-initfini.h> is replicated for legacy architectures which need
DT_INIT/DT_FINI support.  New architectures follow the generic default
and disable it.

4 years agomips: Fix bracktrace result for signal frames
Adhemerval Zanella [Mon, 17 Feb 2020 13:57:56 +0000 (10:57 -0300)]
mips: Fix bracktrace result for signal frames

MIPS fallback code handle a frame where its FDE can not be obtained
(for instance a signal frame) by reading the kernel allocated signal frame
and adding '2' to the value of 'sc_pc' [1].  The added value is used to
recognize an end of an EH region on mips16 [2].

The fix adjust the obtained signal frame value and remove the libgcc added
value by checking if the previous frame is a signal frame one.

Checked with backtrace and tst-sigcontext-get_pc tests on mips-linux-gnu
and mips64-linux-gnu.

[1] libgcc/config/mips/linux-unwind.h from gcc code.
[2] gcc/config/mips/mips.h from gcc code.  */

4 years agoMove implementation of <file_change_detection.h> into a C file
Florian Weimer [Tue, 18 Feb 2020 12:44:48 +0000 (13:44 +0100)]
Move implementation of <file_change_detection.h> into a C file

file_change_detection_for_stat partially initialize
struct file_change_detection in some cases, when the size member
alone determines the outcome of all comparisons.  This results
in maybe-uninitialized compiler warnings in case of sufficiently
aggressive inlining.

Once the implementation is moved into a separate C file, this kind
of inlining is no longer possible, so the compiler warnings are gone.

4 years ago<fd_to_filename.h>: Add type safety and port to Hurd
Florian Weimer [Tue, 18 Feb 2020 12:02:37 +0000 (13:02 +0100)]
<fd_to_filename.h>: Add type safety and port to Hurd

The new type struct fd_to_filename makes the allocation of the
backing storage explicit.

Hurd uses /dev/fd, not /proc/self/fd.

Co-Authored-By: Paul Eggert <eggert@cs.ucla.edu>
4 years agoPrepare redirections for IEEE long double on powerpc64le
Gabriel F. T. Gomes [Thu, 19 Dec 2019 15:06:09 +0000 (12:06 -0300)]
Prepare redirections for IEEE long double on powerpc64le

All functions that have a format string, which can consume a long double
argument, must have one version for each long double format supported on
a platform.  On powerpc64le, these functions currently have two versions
(i.e.: long double with the same format as double, and long double with
IBM Extended Precision format).  Support for a third long double format
option (i.e. long double with IEEE long double format) is being prepared
and all the aforementioned functions now have a third version (not yet
exported on the master branch, but the code is in).

For these functions to get selected (during build time), references to
them in user programs (or dependent libraries) must get redirected to
the aforementioned new versions of the functions.  This patch installs
the header magic required to perform such redirections.

Notice, however, that since the redirections only happen when
__LONG_DOUBLE_USES_FLOAT128 is set to 1, and no platform (including
powerpc64le) currently does it, no redirections actually happen.
Redirections and the exporting of the new functions will happen at the
same time (when powerpc64le adds ldbl-128ibm-compat to their Implies.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Reviewed-by: Paul E. Murphy <murphyp@linux.vnet.ibm.com>
4 years agoconform/conformtest.py: Extend tokenizer to cover character constants
Florian Weimer [Mon, 17 Feb 2020 16:18:49 +0000 (17:18 +0100)]
conform/conformtest.py: Extend tokenizer to cover character constants

Such constants are used in __USE_EXTERN_INLINES blocks.

4 years agostdlib: Reduce namespace pollution in <inttypes.h>
Florian Weimer [Mon, 17 Feb 2020 10:30:17 +0000 (11:30 +0100)]
stdlib: Reduce namespace pollution in <inttypes.h>

The namespace pollution results in conform test failures if the tests
are run __USE_EXTERN_INLINES defined (e.g., when configuring with
CC="gcc -O3" CXX="g++ -O3").

4 years agox86: Avoid single-argument _Static_assert in <tls.h>
Florian Weimer [Mon, 17 Feb 2020 10:08:15 +0000 (11:08 +0100)]
x86: Avoid single-argument _Static_assert in <tls.h>

Older GCC versions do not support this extension.  Fixes commit f1bdee61797
("x86 tls: Use _Static_assert for TLS access size assertion").

4 years agox86 tls: Use _Static_assert for TLS access size assertion
Samuel Thibault [Sun, 16 Feb 2020 23:40:39 +0000 (00:40 +0100)]
x86 tls: Use _Static_assert for TLS access size assertion

4 years agohtl: Link internal htl tests against libpthread
Samuel Thibault [Sun, 16 Feb 2020 23:36:53 +0000 (00:36 +0100)]
htl: Link internal htl tests against libpthread

4 years agopthread: Fix building tst-robust8 with nptl
Samuel Thibault [Sun, 16 Feb 2020 22:53:38 +0000 (23:53 +0100)]
pthread: Fix building tst-robust8 with nptl

NPTL's pthreadP.h needs internal definitions

4 years agopthread: Move robust mutex tests from nptl to sysdeps/pthread
Samuel Thibault [Sun, 16 Feb 2020 14:30:17 +0000 (14:30 +0000)]
pthread: Move robust mutex tests from nptl to sysdeps/pthread

tst-robust8.c prints some mutex internals for nptl debugging, this
needed to be made conditioned by getting built with nptl.

4 years agohtl: Remove stub warning for pthread_mutexattr_setpshared
Samuel Thibault [Sun, 16 Feb 2020 14:35:42 +0000 (06:35 -0800)]
htl: Remove stub warning for pthread_mutexattr_setpshared

It actually is implemented.

4 years agohtl: Add missing functions and defines for robust mutexes
Samuel Thibault [Sun, 16 Feb 2020 14:08:56 +0000 (14:08 +0000)]
htl: Add missing functions and defines for robust mutexes

4 years agohtl: Only check pthread_self coherency when DEBUG is set
Samuel Thibault [Sat, 15 Feb 2020 14:31:50 +0000 (14:31 +0000)]
htl: Only check pthread_self coherency when DEBUG is set

htl has been widely tested for a long time now with this coherency
checked successfully.

4 years agohurd: Add THREAD_GET/SETMEM/_NC
Samuel Thibault [Sat, 15 Feb 2020 13:04:02 +0000 (05:04 -0800)]
hurd: Add THREAD_GET/SETMEM/_NC

Store them in the TCB, and use them for accessing _hurd_sigstate.

4 years agohurd tls: update comment about fields at the end of tcbhead
Samuel Thibault [Sat, 15 Feb 2020 12:56:44 +0000 (04:56 -0800)]
hurd tls: update comment about fields at the end of tcbhead

4 years agold.so: Do not export free/calloc/malloc/realloc functions [BZ #25486]
Florian Weimer [Sat, 8 Feb 2020 18:58:43 +0000 (19:58 +0100)]
ld.so: Do not export free/calloc/malloc/realloc functions [BZ #25486]

Exporting functions and relying on symbol interposition from libc.so
makes the choice of implementation dependent on DT_NEEDED order, which
is not what some compiler drivers expect.

This commit replaces one magic mechanism (symbol interposition) with
another one (preprocessor-/compiler-based redirection).  This makes
the hand-over from the minimal malloc to the full malloc more
explicit.

Removing the ABI symbols is backwards-compatible because libc.so is
always in scope, and the dynamic loader will find the malloc-related
symbols there since commit f0b2132b35248c1f4a80f62a2c38cddcc802aa8c
("ld.so: Support moving versioned symbols between sonames
[BZ #24741]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoRemove weak declaration of free from <inline-hashtab.h>
Florian Weimer [Sat, 8 Feb 2020 15:15:09 +0000 (16:15 +0100)]
Remove weak declaration of free from <inline-hashtab.h>

elf/dl-minimal.c provides a definition of free, so the function
pointer is always non-null, even before the final relocation
of the loader.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoelf: Extract _dl_sym_post, _dl_sym_find_caller_map from elf/dl-sym.c
Florian Weimer [Sat, 8 Feb 2020 14:00:28 +0000 (15:00 +0100)]
elf: Extract _dl_sym_post, _dl_sym_find_caller_map from elf/dl-sym.c

The definitions are moved into a new file, elf/dl-sym-post.h, so that
this code can be used by the dynamic loader as well.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoelf: Introduce the rtld-stubbed-symbols makefile variable
Florian Weimer [Fri, 7 Feb 2020 19:06:32 +0000 (20:06 +0100)]
elf: Introduce the rtld-stubbed-symbols makefile variable

This generalizes a mechanism used for stack-protector support, so
that it can be applied to other symbols if required.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoarm: fix use of INTERNAL_SYSCALL_CALL
Andreas Schwab [Sat, 15 Feb 2020 09:21:20 +0000 (10:21 +0100)]
arm: fix use of INTERNAL_SYSCALL_CALL

Remove extra argument from INTERNAL_SYSCALL_CALL macro call.  Fixes
commit bc2eb9321e ("linux: Remove INTERNAL_SYSCALL_DECL").

4 years agolinux: Remove INTERNAL_SYSCALL_DECL
Adhemerval Zanella [Wed, 29 Jan 2020 20:38:36 +0000 (20:38 +0000)]
linux: Remove INTERNAL_SYSCALL_DECL

With all Linux ABIs using the expected Linux kABI to indicate
syscalls errors, the INTERNAL_SYSCALL_DECL is an empty declaration
on all ports.

This patch removes the 'err' argument on INTERNAL_SYSCALL* macro
and remove the INTERNAL_SYSCALL_DECL usage.

Checked with a build against all affected ABIs.

4 years agonptl: Remove ununsed pthread-errnos.h rule
Adhemerval Zanella [Mon, 10 Feb 2020 18:16:28 +0000 (18:16 +0000)]
nptl: Remove ununsed pthread-errnos.h rule

4 years agolinux: Consolidate INLINE_SYSCALL
Adhemerval Zanella [Wed, 29 Jan 2020 17:36:58 +0000 (17:36 +0000)]
linux: Consolidate INLINE_SYSCALL

With all Linux ABIs using the expected Linux kABI to indicate
syscalls errors, there is no need to replicate the INLINE_SYSCALL.

The generic Linux sysdep.h includes errno.h even for !__ASSEMBLER__,
which is ok now and it allows cleanup some archaic code that assume
otherwise.

Checked with a build against all affected ABIs.

4 years agos390: Consolidate Linux syscall definition
Adhemerval Zanella [Mon, 10 Feb 2020 14:32:40 +0000 (11:32 -0300)]
s390: Consolidate Linux syscall definition

The {INTERNAL,INLINE}_SYSCALL are defined only on s390 sysdep.h.

Checked on s390x-linux-gnu and s390-linux-gnu.

4 years agoriscv: Avoid clobbering register parameters in syscall
Adhemerval Zanella [Mon, 10 Feb 2020 13:32:14 +0000 (10:32 -0300)]
riscv: Avoid clobbering register parameters in syscall

The riscv INTERNAL_SYSCALL macro might clobber the register
parameter if the argument itself might clobber any register (a function
call for instance).

This patch fixes it by using temporary variables for the expressions
between the register assignments (as indicated by GCC documentation,
6.47.5.2 Specifying Registers for Local Variables).

It is similar to the fix done for MIPS (bug 25523).

Checked with riscv64-linux-gnu-rv64imafdc-lp64d build.

4 years agomicroblaze: Avoid clobbering register parameters in syscall
Adhemerval Zanella [Mon, 10 Feb 2020 13:19:29 +0000 (10:19 -0300)]
microblaze: Avoid clobbering register parameters in syscall

The microblaze INTERNAL_SYSCALL macro might clobber the register
parameter if the argument itself might clobber any register (a function
call for instance).

This patch fixes it by using temporary variables for the expressions
between the register assignments (as indicated by GCC documentation,
6.47.5.2 Specifying Registers for Local Variables).

It is similar to the fix done for MIPS (bug 25523).

Checked with microblaze-linux-gnu and microblazeel-linux-gnu build.

4 years agonios2: Use Linux kABI for syscall return
Adhemerval Zanella [Mon, 3 Feb 2020 15:00:19 +0000 (12:00 -0300)]
nios2: Use Linux kABI for syscall return

It changes the nios INTERNAL_SYSCALL_RAW macro to return a negative
value instead of the 'r2' register value on the 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P macro follows the other Linux kABIs.

Checked with a build against nios2-linux-gnu.

4 years agomips: Use Linux kABI for syscall return
Adhemerval Zanella [Mon, 3 Feb 2020 14:52:43 +0000 (11:52 -0300)]
mips: Use Linux kABI for syscall return

It changes the mips INTERNAL_SYSCALL* and internal_syscall*  macros
to return a negative value instead of the 'a3' register value on then
'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P macro follows the other Linux kABIs.
The redefinition of INTERNAL_VSYSCALL_CALL is also no longer
required.

Checked on mips64-linux-gnu, mips64n32-linux-gnu, and mips-linux-gnu.

4 years agomips64: Consolidate Linux sysdep.h
Adhemerval Zanella [Mon, 3 Feb 2020 14:13:18 +0000 (11:13 -0300)]
mips64: Consolidate Linux sysdep.h

The mips64 Linux syscall macros only differs argument type and
the requirement of sign-extending values on n32.  The headers
are consolidate by parameterizing the arguments with a new type,
__syscall_arg_t, and by defining the ARGIFY for n64.

Also, the generic unix mips64 sysdep is essentially the same,
only the load instruction need to be adjusted depending of the
ABI.

Checked on mips64-linux-gnu and mips64n32-linux-gnu.

4 years agoia64: Use Linux kABI for syscall return
Adhemerval Zanella [Mon, 3 Feb 2020 00:03:28 +0000 (21:03 -0300)]
ia64: Use Linux kABI for syscall return

It changes the ia64 INTERNAL_SYSCALL_NCS macro to return a negative
value instead of the 'r10' register value on the 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P macro follows the other Linux kABIs.

Checked on ia64-linux-gnu.

4 years agoalpha: Refactor syscall and Use Linux kABI for syscall return
Adhemerval Zanella [Fri, 31 Jan 2020 19:41:25 +0000 (19:41 +0000)]
alpha: Refactor syscall and Use Linux kABI for syscall return

It highly unlikely that alpha will be ported to anything else than
Linux, so this patch moves the generic unix syscall definition to
Linux and adapt it to Linux kernel ABI.

It changes the internal_syscall* macros to return a negative value
instead of the '$19' register value on the 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P macro follows the other Linux kABIs.

Checked on alpha-linux-gnu.

4 years agosparc: Avoid clobbering register parameters in syscall
Adhemerval Zanella [Mon, 10 Feb 2020 15:57:28 +0000 (12:57 -0300)]
sparc: Avoid clobbering register parameters in syscall

The sparc INTERNAL_SYSCALL macro might clobber the register
parameter if the argument itself might clobber any register (a function
call for instance).

This patch fixes it by using temporary variables for the expressions
between the register assignments (as indicated by GCC documentation,
6.47.5.2 Specifying Registers for Local Variables).

It is similar to the fix done for MIPS (bug 25523).

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.

4 years agosparc: Use Linux kABI for syscall return
Adhemerval Zanella [Tue, 28 Jan 2020 22:33:01 +0000 (19:33 -0300)]
sparc: Use Linux kABI for syscall return

It changes the sparc internal_syscall* macros to return a negative
value instead of the 'g1' register value in the 'err' macro argument.
The __SYSCALL_STRING macro is also changed to no set the 'g1'
value, since 'o1' already holds all the required information
to check if syscall has failed.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P macro follows the other Linux kABIs.
The redefinition of INTERNAL_VSYSCALL_CALL is also no longer
required.

Checked on sparc64-linux-gnu and sparcv9-linux-gnu. It fixes
the sporadic issues on sparc32 where clock_nanosleep does not
act as cancellation entrypoint.

4 years agopowerpc: Use Linux kABI for syscall return
Adhemerval Zanella [Sun, 2 Feb 2020 23:45:58 +0000 (20:45 -0300)]
powerpc: Use Linux kABI for syscall return

It changes the powerpc INTERNAL_VSYSCALL_CALL and INTERNAL_SYSCALL_NCS
to return a negative value instead of the returning the CR value in
the 'err' macro argument.

The macro INTERNAL_SYSCALL_DECL is no longer required, and the
INTERNAL_SYSCALL_ERROR_P macro follows the other Linux kABIs.

Checked on powerpc64-linux-gnu, powerpc64le-linux-gnu, and
powerpc-linux-gnu-power4.

4 years agopowerpc: Consolidate Linux syscall definition
Adhemerval Zanella [Thu, 30 Jan 2020 19:13:31 +0000 (19:13 +0000)]
powerpc: Consolidate Linux syscall definition

The diferences between powerpc64{le} and powerpc32 Linux sysdep.h
are:

  1. On both vDSO and syscall macros the volatile registers r9, r10,
     r11, and r12 are used as input operands on powerpc32 and as
     clobber registers on powerpc64.  However the outcome is essentially
     the same, it advertise the register might be clobbered by the
     kernel (although Linux won't leak register information to userland
     in such case).

  2. The LOADARGS* macros uses a different size to check for invalid
     types.

  3. The pointer mangling support guard pointer loading uses ABI
     specific instruction and register.

This patch consolidates on only one sysdep by using the the powerpc64
version as default and add the adjustments required for powerpc32.

Checked on powerpc64-linux-gnu, powerpc64le-linux-gnu, and
powerpc-linux-gnu-power4.

4 years agoi386: Enable CET support in ucontext functions
H.J. Lu [Fri, 14 Feb 2020 22:45:34 +0000 (14:45 -0800)]
i386: Enable CET support in ucontext functions

1. getcontext and swapcontext are updated to save the caller's shadow
stack pointer and return address.
2. setcontext and swapcontext are updated to restore shadow stack and
jump to new context directly.
3. makecontext is updated to allocate a new shadow stack and set the
caller's return address to the helper code, L(exitcode).
4. Since we no longer save and restore EAX, ECX and EDX in getcontext,
setcontext and swapcontext, we can use them as scratch register slots
to enable CET in ucontext functions.

Since makecontext allocates a new shadow stack when making a new
context and kernel allocates a new shadow stack for clone/fork/vfork
syscalls, we track the current shadow stack base.  In setcontext and
swapcontext, if the target shadow stack base is the same as the current
shadow stack base, we unwind the shadow stack.  Otherwise it is a stack
switch and we look for a restore token.

We enable shadow stack at run-time only if program and all used shared
objects, including dlopened ones, are shadow stack enabled, which means
that they must be compiled with GCC 8 or above and glibc 2.28 or above.
We need to save and restore shadow stack only if shadow stack is enabled.
When caller of getcontext, setcontext, swapcontext and makecontext is
compiled with smaller ucontext_t, shadow stack won't be enabled at
run-time.  We check if shadow stack is enabled before accessing the
extended field in ucontext_t.

Tested on i386 CET/non-CET machines.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agotst-clone3: Use __NR_futex_time64 if we don't have __NR_futex
Alistair Francis [Mon, 11 Nov 2019 23:07:19 +0000 (15:07 -0800)]
tst-clone3: Use __NR_futex_time64 if we don't have __NR_futex

We can't include sysdep.h in the test case (it introduces lots of
strange failures) so __NR_futex isn't redifined to __NR_futex_time64 by
64-bit time_t 32-bit archs (y2038 safe).

To allow the test to pass let's just do the __NR_futex_time64 syscall if
we don't have __NR_futex defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This page took 0.093991 seconds and 5 git commands to generate.