Commit Graph

36874 Commits

Author SHA1 Message Date
DJ Delorie
24eb3be5db NEWS: Add entry for CVE-2021-27645 2021-03-09 14:34:50 -05:00
Lukasz Majewski
6905404496 tst: Add test for settimeofday
This code brings test to check if time on target machine is properly set.
To avoid any issues with altering the time:

- The time, which was set before the test was executed is restored.

- The time is altered only when cross-test-ssh.sh is executed with
  --allow-time-setting flag

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-08 22:41:41 +01:00
Lukasz Majewski
6b6a151c77 tst: Add test for ntp_adjtime
This test is a wrapper on tst-clock_adjtime test.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-03-08 22:41:41 +01:00
Lukasz Majewski
39f39cade3 tst: Add test for adjtimex
This test is a wrapper on tst-clock_adjtime test.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-03-08 22:41:41 +01:00
Lukasz Majewski
4de01867dc tst: Modify tst-clock_adjtime to allow reuse of its code
The tst-clock_adjtime can be adjusted to be reused for also testing
adjtimex.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-03-08 22:41:41 +01:00
Lukasz Majewski
b4effffde8 tst: Add test for clock_adjtime
This code privides test to check if time on target machine is properly
adjusted.
The time is altered only when cross-test-ssh.sh is executed with
--allow-time-setting flag.
As the delta added to CLOCK_REALTIME is only 1 sec the original time is
not restored and further tests are executed with this bias.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-08 22:41:41 +01:00
Lukasz Majewski
3f337843ec tst: Add test for clock_settime
This code brings test to check if time on target machine is properly set.
To avoid any issues with altering the time:

- The time, which was set before the test was executed is restored.

- The time is altered only when cross-test-ssh.sh is executed with
  --allow-time-setting flag

Reviewed-by: DJ Delorie <dj@redhat.com>
2021-03-08 22:41:34 +01:00
Lukasz Majewski
a156555007 support: Provide xclock_settime test helper function
The xclock_settime is a wrapper function on the clock_settime syscall
to be used in the test code.

It checks if the GLIBC_TEST_ALLOW_TIME_SETTING env variable is defined
in the environment in which test is executed. If it is not - the test
ends as unsupported. Otherwise, the clock-settime is executed and return
value is assessed.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-08 22:41:28 +01:00
Lukasz Majewski
496e36f225 tst: Extend cross-test-ssh.sh to specify if target date can be altered
This code adds new flag - '--allow-time-setting' to cross-test-ssh.sh
script to indicate if it is allowed to alter the date on the system
on which tests are executed. This change is supposed to be used with
test systems, which use virtual machines for testing.

The GLIBC_TEST_ALLOW_TIME_SETTING env variable is exported to the
remote environment on which the eligible test is run and brings no
functional change when it is not.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-08 22:37:16 +01:00
John David Anglin
60167dc24b Update hppa libm-test-ulps 2021-03-07 17:23:34 +00:00
H.J. Lu
339bf918ea x86: Set minimum x86-64 level marker [BZ #27318]
Since the full ISA set used in an ELF binary is unknown to compiler,
an x86-64 ISA level marker indicates the minimum, not maximum, ISA set
required to run such an ELF binary.  We never guarantee a library with
an x86-64 ISA level v3 marker doesn't contain other ISAs beyond x86-64
ISA level v3, like AVX VNNI.  We check the x86-64 ISA level marker for
the minimum ISA set.  Since -march=sandybridge enables only some ISAs
in x86-64 ISA level v3, we should set the needed ISA marker to v2.
Otherwise, libc is compiled with -march=sandybridge will fail to run on
Sandy Bridge:

$ ./elf/ld.so ./libc.so
./libc.so: (p) CPU ISA level is lower than required: needed: 7; got: 3

Set the minimum, instead of maximum, x86-64 ISA level marker should have
no impact on the glibc-hwcaps directory assignment logic in ldconfig nor
ld.so.
2021-03-06 07:49:30 -08:00
Florian Weimer
3c66792667 posix: glob, glob64 should not be declared __THROW [BZ #27522]
These functions invoke callbacks with GLOB_ALTDIRFUNC, so they
are not leaf functions (as implied by _THROW).  Use __THROWNL
and __REDIRECT_NTHNL to express this.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-05 14:07:26 +01:00
Adhemerval Zanella
6bb0d2fe0a nptl: Fix __pthread_clockjoin_np64 __pthread_timedjoin_np64 hidden proto
They are both implemented in libpthread instead of libc.
2021-03-05 08:36:01 -03:00
Adhemerval Zanella
4b9bedbc90 linux: Fix __thrd_sleep64 hidden definition
The symbol is exported by libc.
2021-03-05 08:35:50 -03:00
Adhemerval Zanella
6990a72679 Update arm libm-test-ulps 2021-03-05 08:35:24 -03:00
Adhemerval Zanella
1a1c854338 Update sparc libm-test-ulps 2021-03-05 08:34:40 -03:00
Jakub Jelinek
f0419e6a10 [PATCH] pthread_once hangs when init routine throws an exception [BZ #18435]
This is another attempt at making pthread_once handle throwing exceptions
from the init routine callback.  As the new testcases show, just switching
to the cleanup attribute based cleanup does fix the tst-once5 test, but
breaks the new tst-oncey3 test.  That is because when throwing exceptions,
only the unwind info registered cleanups (i.e. C++ destructors or cleanup
attribute), when cancelling threads and there has been unwind info from the
cancellation point up to whatever needs cleanup both unwind info registered
cleanups and THREAD_SETMEM (self, cleanup, ...) registered cleanups are
invoked, but once we hit some frame with no unwind info, only the
THREAD_SETMEM (self, cleanup, ...) registered cleanups are invoked.
So, to stay fully backwards compatible (allow init routines without
unwind info which encounter cancellation points) and handle exception throwing
we actually need to register the pthread_once cleanups in both unwind info
and in the THREAD_SETMEM (self, cleanup, ...) way.
If an exception is thrown, only the former will happen and we in that case
need to also unregister the THREAD_SETMEM (self, cleanup, ...) registered
handler, because otherwise after catching the exception the user code could
call deeper into the stack some cancellation point, get cancelled and then
a stale cleanup handler would clobber stack and probably crash.
If a thread calling init routine is cancelled and unwind info ends before
the pthread_once frame, it will be cleaned up through self->cleanup as
before.  And if unwind info is present, unwind_stop first calls the
self->cleanup registered handler for the frame, then it will call the
unwind info registered handler but that will already see __do_it == 0
and do nothing.
2021-03-04 15:15:33 +01:00
Florian Weimer
82215c1e25 powerpc: Regenerate ulps
This time on a POWER8 machine.
2021-03-03 18:39:17 +01:00
Arjun Shankar
86b9d5a475 s390x: Regenerate ulps
For new test cases in commit 5a051454a9.
2021-03-03 12:44:21 +01:00
DJ Delorie
58673149f3 nss: Re-enable NSS module loading after chroot [BZ #27389]
The glibc 2.33 release enabled /etc/nsswitch.conf reloading,
and to prevent potential security issues like CVE-2019-14271
the re-loading of nsswitch.conf and all mdoules was disabled
when the root filesystem changes (see bug 27077).

Unfortunately php-lpfm and openldap both require the ability
to continue to load NSS modules after chroot. The packages
do not exec after the chroot, and so do not cause the
protections to be reset. The only solution is to re-enable
only NSS module loading (not nsswitch.conf reloading) and so
get back the previous glibc behaviour.

In the future we may introduce a way to harden applications
so they do not reload NSS modules once the root filesystem
changes, or that only files/dns are available pre-loaded
(or builtin).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-02 16:14:18 -05:00
DJ Delorie
dca565886b nscd: Fix double free in netgroupcache [BZ #27462]
In commit 745664bd79 a use-after-free
was fixed, but this led to an occasional double-free.  This patch
tracks the "live" allocation better.

Tested manually by a third party.

Related: RHBZ 1927877

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-02 12:32:18 -05:00
Lukasz Majewski
dd1776e327 tst: Fix tst-timerfd test
There were following problems discovered for tst-timerfd test:

1. Do not set the struct itimerspec's it_interval tv_sec to 2 seconds.
After this change the timerfd will trigger only once (the it_value is
only set in this case).

2. The 'val1' variable (including the call to timerfd_gettime) is not
needed anymore, as it is just enough to read the struct itimerspec
after sleep. As a consequence the 'val2' has been renamed to 'val'.

3. After calling timerfd_gettime, the value of struct itimerspec time,
when timer is running, is the remaining time. In the case of this test
it would be less than 1 second.
As a result the TEST_COMPARE macro logic had to be adjusted.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-02 16:55:05 +01:00
Florian Weimer
f01a61e138 i386: Regenerate ulps 2021-03-02 15:41:29 +01:00
Florian Weimer
01a5746b6c x86: Add CPU-specific diagnostics to ld.so --list-diagnostics 2021-03-02 15:01:10 +01:00
Florian Weimer
e4933c8a92 x86: Automate generation of PREFERRED_FEATURE_INDEX_1 bitfield
Use a .def file to define the bitfield layout, so that it is possible
to iterate over field members using the preprocessor.
2021-03-02 15:01:06 +01:00
Florian Weimer
851f32cf7b ld.so: Implement the --list-diagnostics option 2021-03-02 14:39:24 +01:00
Matheus Castanho
40d055a2dd powerpc: Update libm-test-ulps
Generated with 'make regen-ulps'

Tested on powerpc, powerpc64, and powerpc64le
2021-03-02 10:08:07 -03:00
Lukasz Majewski
9871ae0ab4 tst: Add test for utimes
This patch provides test for utimes. It uses wrapper to read
access and modification times to compare them with ones written by
utimes.

Moreover, access and modification times beyond the Y2038 threshold
date (i.e. 32 bit time_t overflow) are also checked.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-02 13:31:13 +01:00
Lukasz Majewski
dec445d40d tst: Add test for utime
This patch provides test for utime. It uses wrapper to read access
and modification times to compare them with ones written by utime.

Moreover, access and modification times beyond the Y2038 threshold
date (i.e. 32 bit time_t overflow) are also checked.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-02 13:31:13 +01:00
Lukasz Majewski
e0685bacd5 tst: Add test for futimens
This patch provides test for futimens. It uses wrapper, which
reads access and modification time to compare them with ones
written by futimens.

Moreover, access and modification times beyond the Y2038 threshold
date (i.e. 32 bit time_t overflow) are also checked.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-03-02 13:31:13 +01:00
Florian Weimer
e81402f246 nptl: __libc_cleanup_push/__libc_cleanup_pop require -fexceptions
Do not define these macros if they do nothing in a particular
compilation, otherwise they can easily be used accidentally, while
not actually achieving anything.
2021-03-02 11:56:33 +01:00
Florian Weimer
e7b2a56192 elf: Build __dl_iterate_phdr with unwinding support [BZ #27498] 2021-03-02 11:56:33 +01:00
Florian Weimer
97e42bd482 nptl: Use <unwind-link.h> for accessing the libgcc_s unwinder
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 16:00:22 +01:00
Florian Weimer
6b7efa3d87 Implement _Unwind_Resume in libc on top of <unwind-link.h>
Temporarily move the arm _Unwind_Resume implementation to the file
used by libpthread.  It will be ported to <unwind-link.h> along with
the rest of nptl.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 16:00:03 +01:00
Florian Weimer
d14624825a Move sysdeps/gnu/unwind-resume.c to sysdeps/generic/unwind-resume.c
This change allows architecture-specific sysdeps directories to override
it.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:59:49 +01:00
Florian Weimer
7cf18db482 __frame_state_for: Use <unwind-link.h> for unwinder access
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:59:36 +01:00
Florian Weimer
600fe89cb1 sparc: Implement backtrace on top <unwind-link.h>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:59:25 +01:00
Florian Weimer
6563d544db m68k: Implement backtrace on top of <unwind-link.h>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:59:12 +01:00
Florian Weimer
fd19b84640 i386: Implement backtrace on top of <unwind-link.h>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:58:58 +01:00
Florian Weimer
fac75a690e arm: Implement backtrace on top of <unwind-link.h>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:58:45 +01:00
Florian Weimer
e164d95abf backtrace: Implement on top of <unwind-link.h>
This reimplements the generic version of backtrace.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:58:28 +01:00
Florian Weimer
9fc813e1a3 Implement <unwind-link.h> for dynamically loading the libgcc_s unwinder
This will be used to consolidate the libgcc_s access for backtrace
and pthread_cancel.

Unlike the existing backtrace implementations, it provides some
hardening based on pointer mangling.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2021-03-01 15:58:01 +01:00
Martin Sebor
764e9a0334 Correct buffer end pointer in IO_wdefault_doallocate (BZ #26874)
An experimental build of GCC 11 with an enhanced -Warray-bounds
reports a bug in IO_wdefault_doallocate where the function forms
an invalid past-the-end pointer to an allocated wchar_t buffer
by failingf to consider the scaling by sizeof (wchar_t).

The fix path below corrects this problem.  It keeps the buffer
size the same as opposed to increasing it according to what other
code like it does.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2021-03-01 19:34:49 +05:30
Szabolcs Nagy
9fb07fd4e1 aarch64: update ulps.
For new test cases in
commit 5a051454a9
2021-03-01 12:29:42 +00:00
Paul Zimmermann
5a051454a9 Add inputs that generate larger error bounds
(Using values from https://members.loria.fr/PZimmermann/papers/accuracy.pdf)
2021-02-27 06:32:11 +01:00
Florian Weimer
035c012e32 Reduce the statically linked startup code [BZ #23323]
It turns out the startup code in csu/elf-init.c has a perfect pair of
ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, "return-to-csu: A
New Method to Bypass 64-bit Linux ASLR").  These functions are not
needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
are already processed by the dynamic linker.  However, the dynamic
linker skipped the main program for some reason.  For maximum
backwards compatibility, this is not changed, and instead, the main
map is consulted from __libc_start_main if the init function argument
is a NULL pointer.

For statically linked binaries, the old approach based on linker
symbols is still used because there is nothing else available.

A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because
new binaries running on an old libc would not run their ELF
constructors, leading to difficult-to-debug issues.
2021-02-25 12:13:02 +01:00
Adhemerval Zanella
a79328c745 posix: Falling back to non wide mode in case of encoding error [BZ #14185]
Gnulib has added the proposed fix with aed23714d60 (done in 2005), but
recently with a glibc merge with 67306f6 (done in 2020 with sync back)
it has fallback to old semantic to return -1 on in case of failure.

From gnulib developer feedback it was an oversight.  Although the full
fix for BZ #14185 would require to rewrite fnmatch implementation to use
mbrtowc instead of mbsrtowcs on the full input, this mitigate the issue
and it has been used by gnulib for a long time.

This patch also removes the alloca usage on the string convertion to
wide characters before calling the internal function.

Checked on x86_64-linux-gnu.
2021-02-23 15:58:04 -03:00
Florian Weimer
5a664d7ae8 nptl: Move elision implementations into libc
The elision interfaces are closely aligned between the targets that
implement them, so declare them in the generic <lowlevellock.h>
file.

Empty .c stubs are provided, so that fewer makefile updates
under sysdeps are needed.  Also simplify initialization via
__libc_early_init.

The symbols __lll_clocklock_elision, __lll_lock_elision,
__lll_trylock_elision, __lll_unlock_elision, __pthread_force_elision
move into libc.  For the time being, non-hidden references are used
from libpthread to access them, but once that part of libpthread
is moved into libc, hidden symbols will be used again.  (Hidden
references seem desirable to reduce the likelihood of transactions
aborts.)
2021-02-23 14:59:34 +01:00
Samuel Thibault
597d0267b5 NEWS: Add missing bug closures 2021-02-23 13:36:06 +01:00
Paul Zimmermann
90197376d5 added rt to malloc/Depend [BZ #27132]
This avoids a failure when a new glibc version is compiled with an older
system librt. Patch proposed by Florian Weimer.
2021-02-23 10:04:45 +01:00