Commit Graph

36461 Commits

Author SHA1 Message Date
Stefan Liebler
aa7e05c304 Mark mtrace tests UNSUPPORTED if bug-ga2.mtrace or tst-leaks2.mtrace are missing
Starting with commit 29fddfc7df, the
tests posix/bug-ga2 and resolv/tst-leaks2 are test-container tests.

If test-container.c returns with EXIT_UNSUPPORTED, the tests with
mtrace() are not executed and the mtrace files do not exist.

Therefore the "mtrace-analysis-part" of those tests are marked
UNSUPPORTED if the mtrace files are missing.

Reported-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2020-11-25 08:30:17 +01:00
Shuo Wang
df5f473ed5 elf: Fix uninitialized variable for _dl_write
Variable ret in elf/dl-write.c is uninitialized, which should get
return value from __writev.
2020-11-24 16:54:58 -03:00
Matheus Castanho
1e0a7fd099 powerpc: Make PT_THREAD_POINTER available to assembly code
PT_THREAD_POINTER is currenty defined inside a #ifndef __ASSEMBLER__ block, but
its usage should not be limited to C code, as it can be useful when accessing
the TLS from assembly code as well.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2020-11-24 14:15:01 -03:00
Stefan Liebler
29fddfc7df Use libnss_files.so for tests posix/bug-ga2 and resolv/tst-leaks2 [BZ #26821]
The tests posix/bug-ga2-mem and resolv/mtrace-tst-leaks2 are failing on
fedora 33 as mtrace reports memory leaks.

The /etc/nsswitch.conf differs between
Fedora 32: hosts:      files dns myhostname
Fedora 33: hosts:      files resolve [!UNAVAIL=return] myhostname dns

Therefore /lib64/libnss_resolve.so.2 (from systemd) and the dependencies
libgcc_s.so.1 and libpthread.so.0 are loaded.

Usually all malloc'ed resources from getaddrinfo / gethostbyname are freed
and the libraries are dlclose'd in nss/nsswitch.c:libc_freeres_fn (free_mem).
Unfortunately, /lib64/libnss_resolve.so.2 is marked with DF_1_NODELETE.
As this library is not unmapped, you'll see "Memory not freed".

Therefore those tests are now only relying on libnss_files.so by making
them test-container tests and providing the required configuration files.

By moving the tests to tests-container, those are now running with
"make check".  Therefore the mtrace part of the tests are also moved
from "make xcheck" to "make check".

bug-ga2.c is now using test-driver.c in order to support WAIT_FOR_DEBUGGER
environment variable.
2020-11-23 10:51:24 +01:00
Samuel Thibault
76ea70c613 hurd report-wait: Fix stpcpy usage
We shall not overflow the size of the description parameter. This makes
describe_number and describe_port behave like strpcpy (except for not filling
all the end of buffer with zeroes) and _S_msg_report_wait use series of
stpncpy-like call. If we were to overflow, we can now detect it and
return ENOMEM.
2020-11-23 00:31:41 +00:00
Samuel Thibault
dba88fb3ed hurd S_msg_report_wait: Fix detecting fd ports
_hurd_init_dtable stays set to non-NULL, so we have to run through both
_hurd_init_dtable and _hurd_dtable.
2020-11-23 00:25:26 +00:00
Samuel Thibault
c57fe5462b hurd S_msg_report_wait: Fix reporting ports
This fixes the parameter order of MSG_EXAMINE, thus fixing the detection
of e.g. fd ports for nicer output in ps WAIT output.
2020-11-23 00:24:03 +00:00
Samuel Thibault
ee11682d4f hurd: Fix strcpy calls
strcpy cannot be used with overlapping buffer, we have to use memmove
instead. strcpy also cannot be safely used when the destination buffer
is smaller that the source, we need to use strncpy to truncate the
source if needed.
2020-11-22 23:15:36 +00:00
Samuel Thibault
ae959c26db hurd: Fix _S_msg_get/set_env_variable prototype
_S_msg_get_env_variable and _S_msg_set_env_variable are taking string_t,
not char *.

Fixes a warning with gcc 11.
2020-11-22 09:59:51 +00:00
Samuel Thibault
4e58941fc4 hurd: Enable using ifunc
Bugs have been fixed in binutils/gcc/glibc.
2020-11-16 21:15:20 +00:00
Samuel Thibault
3dbbd2ff92 Add {,sysdep-}ld-library-path make variable
On GNU/Hurd we not only need $(common-objpfx) in LD_LIBRARY_PATH when loading
dynamic objects, but also $(common-objpfx)/mach and $(common-objpfx)/hurd. This
adds an ld-library-path variable to be used as LD_LIBRARY_PATH basis in
Makefiles, and a sysdep-ld-library-path variable for sysdeps to add some
more paths, here mach/ and hurd/.
2020-11-16 21:15:20 +00:00
Florian Weimer
1daccf403b nptl: Move stack list variables into _rtld_global
Now __thread_gscope_wait (the function behind THREAD_GSCOPE_WAIT,
formerly __wait_lookup_done) can be implemented directly in ld.so,
eliminating the unprotected GL (dl_wait_lookup_done) function
pointer.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2020-11-16 19:33:30 +01:00
Samuel Thibault
aac0f62c47 hurd: let _dl_argv and __libc_stack_end be relro
libpthread does not switch stacks.
2020-11-15 14:48:15 +01:00
Samuel Thibault
9446e02b0d hurd: Remove some remnants of cthreads
Libc has actually been using mach's lock-internal.h mutex for a long
time already.
2020-11-15 13:16:03 +01:00
Lukasz Majewski
7ed2b6921f nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64
On ports with __TIMESIZE != 64 the remaining time argument always receives
pointer to struct __timespec64 instance. This is the different behavior
when compared to 64 bit versions of clock_nanosleep and nanosleep
functions, which receive NULL.

To avoid any potential issues, we also pass NULL when *rem pointer is
NULL.

Reported-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-11-14 22:12:40 +01:00
Lukasz Majewski
eb60eda2b9 y2038: Convert thrd_sleep to support 64 bit time
The thrd_sleep function has been converted to support 64 bit time.
It was also necessary to provide Linux specific copy of it to avoid
problems on i686-gnu (i.e. HURD) port, which is not providing
clock_nanosleep() supporting 64 bit time.

The thrd_sleep is a wrapper on POSIX threads to provide C11 standard
threads interface. It directly calls __clock_nanosleep64().

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-11-14 22:11:41 +01:00
Lukasz Majewski
b0c0ad4d54 y2038: Convert mtx_timedlock to support 64 bit time
The mtx_timedlock function has been converted to support 64 bit time.
It was also necessary to provide Linux specific copy of it to avoid
problems on i686-gnu (i.e. HURD) port, which is not providing
pthread_mutex_timedlock() supporting 64 bit time.

The mtx_timedlock is a wrapper on POSIX threads to provide C11 standard
threads interface. It directly calls __pthread_mutex_timedlock64().

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-11-14 22:10:31 +01:00
Lukasz Majewski
1f1a4847a4 y2038: Convert cnd_timedwait to support 64 bit time
The cnd_timedwait function has been converted to support 64 bit time.
It was also necessary to provide Linux specific copy of it to avoid
problems on i686-gnu (i.e. HURD) port, which is not providing
pthread_cond_timedwait() supporting 64 bit time.

Moreover, a linux specific copy of thrd_priv.h header file has been
added as well.

The cnd_timedwait is a wrapper on POSIX threads to provide C11 standard
threads interface. It directly calls __pthread_cond_timedwait64().

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
2020-11-14 22:09:43 +01:00
Samuel Thibault
839fa6bc8a hurd: Drop CLOCK_MONOTONIC change which slipped in 2020-11-14 00:59:04 +01:00
Samuel Thibault
b4fcf0475b hurd: make ptsname fail with ENOTTY on non-master-pty 2020-11-14 00:54:08 +01:00
Samuel Thibault
3b13266f14 mach: Add missing assert.h include 2020-11-14 00:53:49 +01:00
Samuel Thibault
56010b73e8 hurd: break relocation loop between libc.so and lib{mach,hurd}user.so
See
https://sourceware.org/pipermail/libc-alpha/2020-November/119575.html

lib{mach,hurd}user.so gets relocated before libc.so, but its references
to strpcpy and memcpy would need an ifunc decision, which e.g. on
x86 relies on cpu_features, but libc.so's _rtld_global_ro is not
relocated yet.

We can however just make lib{mach,hurd}user.so only call non-ifunc
functions, which can be relocated before libc.so is relocated.
2020-11-14 00:52:52 +01:00
John David Anglin
a24f414ba1 Remove obsolete defines for HPUX support from fcntl.h and update O_NONBLOCK. 2020-11-13 16:42:11 +00:00
Adhemerval Zanella
01bd62517c Remove tls.h inclusion from internal errno.h
The tls.h inclusion is not really required and limits possible
definition on more arch specific headers.

This is a cleanup to allow inline functions on sysdep.h, more
specifically on i386 and ia64 which requires to access some tls
definitions its own.

No semantic changes expected, checked with a build against all
affected ABIs.
2020-11-13 12:59:19 -03:00
Florian Weimer
26f7c72a99 nptl: Eliminate <smp.h> and __is_smp
Most systems are SMP, so optimizing for the UP case is no longer
approriate.  A dynamic check based on the kernel identification
has been only implemented for i386 anyway.

To disable adaptive mutexes on sh, define DEFAULT_ADAPTIVE_COUNT
as zero for this architecture.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2020-11-13 15:20:10 +01:00
Florian Weimer
d5c4cce9c3 powerpc: Eliminate UP macro conditionals
The macro is never defined.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2020-11-13 15:20:07 +01:00
Florian Weimer
0f34d426ac x86: Remove UP macro. Define LOCK_PREFIX unconditionally.
The UP macro is never defined.  Also define LOCK_PREFIX
unconditionally, to the same string.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2020-11-13 15:20:03 +01:00
Florian Weimer
4d5297253e alpha: Remove UP preprocessor conditionals
The macro is never defined.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2020-11-13 15:19:50 +01:00
Samuel Thibault
0f73c17037 hurd: Make sure signals get started
Now that _hurd_libc_proc_init is idempotent, we can always call it,
independently of the __libc_multiple_libcs test which may not match
whether signals should be started or not.
2020-11-13 11:24:22 +01:00
Samuel Thibault
2aa072d395 hurd: initialize libpthread before starting the signal thread
We cannot rely on csu calling __pthread_initialize_minimal before
posixland_init, in some cases _init gets called before that.
2020-11-13 02:24:18 +01:00
Samuel Thibault
946dcc6fde hurd: Make _hurd_libc_proc_init idempotent
For the cases where _init is getting called several times during startup. Better
clean pointers anyway.
2020-11-13 01:23:51 +01:00
Raphael M Zinsly
7beee7b39a powerpc: Add optimized stpncpy for POWER9
Add stpncpy support into the POWER9 strncpy.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2020-11-12 13:16:36 -03:00
Raphael M Zinsly
b9d83bf3eb powerpc: Add optimized strncpy for POWER9
Similar to the strcpy P9 optimization, this version uses VSX to improve
performance.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2020-11-12 13:12:24 -03:00
Siddhesh Poyarekar
b7aa84d5a5 Don't use nested function in test-ffs
There is no real need to use a nested function in that test, so break
it out so that it can build with clang too.
2020-11-12 14:54:24 +05:30
Siddhesh Poyarekar
7163ace331 Use __builtin___stpncpy_chk when available
The builtin has been available in gcc since 4.7.0 and in clang since
2.6.  This fixes stpncpy fortification with clang since it does a
better job of plugging in __stpncpy_chk in the right place than the
header hackery.

This has been tested by building and running all tests with gcc 10.2.1
and also with clang tip as of a few days ago (just the tests in debug/
since running all tests don't work with clang at the moment) to make
sure that both compilers pass the stpncpy tests.
2020-11-12 14:36:43 +05:30
Siddhesh Poyarekar
ee9946ce3c tests: Remove NULL check for an array
The NULL check for an array on stack is pointless since it will always
be false, so drop it.
2020-11-12 13:29:59 +05:30
Samuel Thibault
85741f7eba hurd: Move {,f,l}xstat{,at} and xmknod{at} to compat symbols
We do not actually need them, so we can move their implementations
into the standard {,f,l}stat{,at} variants and only keep compatibility
wrappers.
2020-11-11 23:56:56 +00:00
Samuel Thibault
1ccbb9258e hurd: Notify the proc server later during initialization
Notifying the proc server is an involved task, and unleashes various signal
handling etc. so we have to do this after e.g. ifunc relocations are
completed.
2020-11-11 20:41:25 +00:00
Samuel Thibault
9cec82de71 htl: Initialize later
Since htl does not actually need a stack switch, we can initialize it
like nptl is, avoiding all sorts of startup issues with ifunc.

More precisely, htl defines __pthread_initialize_minimal instead of the
elder _cthread_init_routine. We can then drop the stack switching dances.
2020-11-11 20:41:25 +00:00
Samuel Thibault
d482ebfa67 htl: Keep thread signals blocked during its initialization
One may send signals immediately after creating a thread. We need to block them
until the thread is ready to run signal handlers.
2020-11-11 20:41:24 +00:00
Samuel Thibault
6d1d603417 htl: Fix spurious symbols in namespaces
pthread_attr_{{get,set}stack{addr,size},setstack} were defining a strong alias
for no reason, turning them to weak.
2020-11-11 20:41:24 +00:00
Maximilian Krüger
d2d714b9fc Use O_CLOEXEC in sysconf [BZ #26791]
If sysconf is used in multithreaded processes, various filedescriptors
may leak due to missing O_CLOEXEC.  This commit adds the flag.
2020-11-11 12:15:21 +01:00
Florian Weimer
30af7c7fa1 struct _Unwind_Exception alignment should not depend on compiler flags
__attribute__((__aligned__)) selects an alignment that depends on
the micro-architecture selected by GCC flags.  Enabling vector
extensions may increase the allignment.  This is a problem when
building glibc as a collection of ELF multilibs with different
GCC flags because ld.so and libc.so/libpthread.so/&c may end up
with a different layout of struct pthread because of the
changing offset of its struct _Unwind_Exception field.

Tested-By: Matheus Castanho <msc@linux.ibm.com>
2020-11-11 11:59:29 +01:00
Samuel Thibault
3d3316b1de hurd: keep only required PLTs in ld.so
We need NO_RTLD_HIDDEN because of the need for PLT calls in ld.so.
See Roland's comment in
https://sourceware.org/bugzilla/show_bug.cgi?id=15605
"in the Hurd it's crucial that calls like __mmap be the libc ones
instead of the rtld-local ones after the bootstrap phase, when the
dynamic linker is being used for dlopen and the like."

We used to just avoid all hidden use in the rtld ; this commit switches to
keeping only those that should use PLT calls, i.e. essentially those defined in
sysdeps/mach/hurd/dl-sysdep.c:

__assert_fail
__assert_perror_fail
__*stat64
_exit

This fixes a few startup issues, notably the call to __tunable_get_val that is
made before PLTs are set up.
2020-11-11 02:36:22 +01:00
Samuel Thibault
a40b18b233 hurd: Add missing startup calls
DL_SYSDEP_INIT and DL_PLATFORM_INIT were not getting called, leading to
missing x86 platform tuning, now mandatory with 0f09154c64
("x86: Initialize CPU info via IFUNC relocation [BZ 26203]")
2020-11-11 02:35:59 +01:00
Zong Li
15b38ffc10 riscv: Get cache information through sysconf
Add support to query cache information on RISC-V through sysconf()
function. The cache information had been added in AUX vector of RISC-V
architecture in Linux kernel v.5.10-rc1.
Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
Acked-by: Palmer Dabbelt <palmerdabbelt@google.com>
2020-11-10 14:43:49 -05:00
Jim Wilson
1f67f23fdf RISC-V: Add _dl_start_user.
This is required for the debugglibc.sh script to work.  Tested by
successfully using this patched script, and a riscv64-linux testsuite
run.

We could perhaps call RTLD_EPILOGUE for ENTRY_POINT before calling
RTLD_PROLOGUE for _dl_start_user, but I don't think it matters.

OK?

Jim
2020-11-10 14:02:46 -05:00
Adhemerval Zanella
75a193b761 linux: Allow adjtime with NULL argument [BZ #26833]
The adjtime interface allows return the amount of time remaining
from any previous adjustment that has not yet been completed by
passing a NULL as first argument.  This was introduced with y2038
support 0308077e3a.

Checked on i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
2020-11-09 11:19:35 -03:00
Florian Weimer
5edf3d9fd6 aarch64: Add unwind information to _start (bug 26853)
This adds CFI directives which communicate that the stack ends
with this function.

Fixes bug 26853.
2020-11-09 11:31:04 +01:00
Samuel Thibault
dfe2e7a562 bsd unlockpt: unlockpt needs to fail with EINVAL, not ENOTTY
The EINVAL error code is mandated by POSIX, while ptsname_r returns
ENOTTY, so we need to translate.
2020-11-08 14:06:56 +00:00