Florian Weimer [Tue, 12 Nov 2019 11:25:49 +0000 (12:25 +0100)]
login: Use pread64 in utmp implementation
This reduces the possible error scenarios considerably because
no longer can file seek fail, leaving the file descriptor in an
inconsistent state and out of sync with the cache.
As a result, it is possible to avoid setting file_offset to -1
to make an error persistent. Instead, subsequent calls will retry
the operation and report any errors returned by the kernel.
This change also avoids reading the file from the start if pututline
is called multiple times, to work around lock acquisition failures
due to timeouts.
Change-Id: If21ea0c162c38830a89331ea93cddec14c0974de
Florian Weimer [Thu, 31 Oct 2019 12:28:26 +0000 (13:28 +0100)]
Clarify purpose of assert in _dl_lookup_symbol_x
Only one of the currently defined flags is incompatible with versioned
symbol lookups, so it makes sense to check for that flag and not its
complement.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Change-Id: I3384349cef90cfd91862ebc34a4053f0c0a99404
Krzysztof Koch [Tue, 5 Nov 2019 17:35:18 +0000 (17:35 +0000)]
aarch64: Increase small and medium cases for __memcpy_generic
Increase the upper bound on medium cases from 96 to 128 bytes.
Now, up to 128 bytes are copied unrolled.
Increase the upper bound on small cases from 16 to 32 bytes so that
copies of 17-32 bytes are not impacted by the larger medium case.
Benchmarking:
The attached figures show relative timing difference with respect
to 'memcpy_generic', which is the existing implementation.
'memcpy_med_128' denotes the the version of memcpy_generic with
only the medium case enlarged. The 'memcpy_med_128_small_32' numbers
are for the version of memcpy_generic submitted in this patch, which
has both medium and small cases enlarged. The figures were generated
using the script from:
https://www.sourceware.org/ml/libc-alpha/2019-10/msg00563.html
Depending on the platform, the performance improvement in the
bench-memcpy-random.c benchmark ranges from 6% to 20% between
the original and final version of memcpy.S
Tested against GLIBC testsuite and randomized tests.
Florian Weimer [Tue, 12 Nov 2019 11:02:57 +0000 (12:02 +0100)]
login: Introduce matches_last_entry to utmp processing
This simplifies internal_getut_nolock and fixes a regression,
introduced in commit
be6b16d975683e6cca57852cd4cfe715b2a9d8b1
("login: Acquire write lock early in pututline [BZ #24882]")
in pututxline because __utmp_equal can only compare process-related
utmp entries.
Fixes:
be6b16d975683e6cca57852cd4cfe715b2a9d8b1
Change-Id: Ib8a85002f7f87ee41590846d16d7e52bdb82f5a5
Florian Weimer [Tue, 12 Nov 2019 11:41:34 +0000 (12:41 +0100)]
slotinfo in struct dtv_slotinfo_list should be flexible array [BZ #25097]
GCC 10 will warn about subscribing inner length zero arrays. Use a GCC
extension in csu/libc-tls.c to allocate space for the static_slotinfo
variable. Adjust nptl_db so that the type description machinery does
not attempt to determine the size of the flexible array member slotinfo.
Change-Id: I51be146a7857186a4ede0bb40b332509487bdde8
Adhemerval Zanella [Mon, 11 Nov 2019 16:28:37 +0000 (13:28 -0300)]
Fix clock_nanosleep when interrupted by a signal
This patch fixes the time64 support (added by
2e44b10b42d) where it
misses the remaining argument updated if __NR_clock_nanosleep
returns EINTR.
Checked on i686-linux-gnu on 4.15 kernel (no time64 support) and
on 5.3 kernel (with time64 support).
Reviewed-by: Alistair Francis <alistair23@gmail.com>
Arjun Shankar [Mon, 11 Nov 2019 14:21:55 +0000 (15:21 +0100)]
libio/tst-fopenloc: Use xsetlocale, xfopen, and xfclose
Arjun Shankar [Mon, 11 Nov 2019 13:57:23 +0000 (14:57 +0100)]
support: Add xsetlocale function
Joseph Myers [Mon, 11 Nov 2019 15:04:48 +0000 (15:04 +0000)]
Declare asctime_r, ctime_r, gmtime_r, localtime_r for C2X.
C2X adds the asctime_r, ctime_r, gmtime_r and localtime_r functions.
This patch duly adds __GLIBC_USE (ISOC2X) to the conditions under
which <time.h> declares them.
Tested for x86_64.
Lukasz Majewski [Tue, 29 Oct 2019 14:08:00 +0000 (15:08 +0100)]
y2038: linux: Provide __ppoll64 implementation
This patch provides new __ppoll64 explicit 64 bit function for handling polling
events (with struct timespec specified timeout) for a set of file descriptors.
Moreover, a 32 bit version - __ppoll has been refactored to internally use
__ppoll64.
The __ppoll is now supposed to be used on systems still supporting 32 bit time
(__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct
__timespec64.
The new ppoll_time64 syscall available from Linux 5.1+ has been used, when
applicable.
The Linux kernel checks if passed tv_nsec value overflows, so there is no need
to repeat it in the glibc.
When ppoll syscall on systems supporting 32 bit time ABI is used, the check is
performed if passed data (which may have 64 bit tv_sec) fits into 32 bit range.
Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make PARALLELMFLAGS="-j8" && make check PARALLELMFLAGS="-j8" && \\
make xcheck PARALLELMFLAGS="-j8"
- The glibc has been build tested (make PARALLELMFLAGS="-j8") for
x86 (i386), x86_64-x32, and armv7
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
- Use of cross-test-ssh.sh for ARM (armv7):
make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck
Linux kernel, headers and minimal kernel version for glibc build test
matrix:
- Linux v5.1 (with ppoll_time64) and glibc build with v5.1 as
minimal kernel version (--enable-kernel="5.1.0")
The __ASSUME_TIME64_SYSCALLS flag defined.
- Linux v5.1 and default minimal kernel version
The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports ppoll_time64
syscall.
- Linux v4.19 (no ppoll_time64 support) with default minimal kernel version for
contemporary glibc
This kernel doesn't support ppoll_time64 syscall, so the fallback to ppoll is
tested.
Above tests were performed with Y2038 redirection applied as well as without
(so the __TIMESIZE != 64 execution path is checked as well).
No regressions were observed.
Florian Weimer [Mon, 11 Nov 2019 09:26:52 +0000 (10:26 +0100)]
linux: Reduce stack size for nptl/tst-thread-affinity-pthread
And related tests. These tests create a thread for each core, so
they may fail due to address space limitations with the default
stack size.
Change-Id: Ieef44a7731f58d3b7d6638cce4ccd31126647551
Florian Weimer [Mon, 11 Nov 2019 08:20:09 +0000 (09:20 +0100)]
support: Add support_set_small_thread_stack_size
And support_small_stack_thread_attribute
Change-Id: I1cf79a469984f8f30a4a947ee9ec2a5e74de8926
Andreas Schwab [Wed, 30 Oct 2019 09:38:36 +0000 (10:38 +0100)]
Fix array bounds violation in regex matcher (bug 25149)
If the regex has more subexpressions than the number of elements allocated
in the regmatch_t array passed to regexec then proceed_next_node may
access the regmatch_t array outside its bounds.
No testcase added because even without this bug it would then crash in
pop_fail_stack which is bug 11053.
Alistair Francis [Fri, 21 Jun 2019 20:00:23 +0000 (13:00 -0700)]
sysdeps/clock_nanosleep: Use clock_nanosleep_time64 if avaliable
The clock_nanosleep syscall is not supported on newer 32-bit platforms (such
as RV32). To fix this issue let's use clock_nanosleep_time64 if it is
avaliable.
Adhemerval Zanella [Fri, 8 Nov 2019 18:45:10 +0000 (15:45 -0300)]
Remove hppa pthreadP.h
It just contains duplicated defitions provided by other generic
nptl headers.
Checked with run-built-tests=no against hppa-linux-gnu.
Change-Id: I95f55d5b7b7ae528c81cd2394d57ce92398189bf
Florian Weimer [Thu, 7 Nov 2019 17:15:18 +0000 (18:15 +0100)]
login: Acquire write lock early in pututline [BZ #24882]
It has been reported that due to lack of fairness in POSIX file
locking, the current reader-to-writer lock upgrade can result in
lack of forward progress. Acquiring the write lock directly
hopefully avoids this issue if there are only writers.
This also fixes bug 24882 due to the cache revalidation in
__libc_pututline.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Change-Id: I57e31ae30719e609a53505a0924dda101d46372e
Adhemerval Zanella [Thu, 7 Nov 2019 15:10:35 +0000 (15:10 +0000)]
nptl: Add missing placeholder abi symbol from nanosleep move
Adds the __libpthread_version_placeholder symbol with the same version
of nanosleep/__nanosleep that was removed by
79a547b162657b3f and that
is not provided by other symbols.
Florian Weimer [Thu, 7 Nov 2019 08:53:41 +0000 (09:53 +0100)]
login: Remove double-assignment of fl.l_whence in try_file_lock
Since l_whence is the second member of struct flock, it is written
twice. The double-assignment is technically undefined behavior due to
the lack of a sequence point.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Change-Id: I2baf9e70690e723c61051b25ccbd510aec15976c
Florian Weimer [Thu, 7 Nov 2019 08:52:11 +0000 (09:52 +0100)]
hurd: Use __clock_gettime in _hurd_select
The __gettimeofday references caused check-localplt failures after
commit
5e46749c64d5.
Fixes:
5e46749c64d51f50f8511ed99c1266d7c13e182b
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Change-Id: Ia6da4045157a5bbccc67d79e881d7592e6f8a890
Florian Weimer [Thu, 7 Nov 2019 08:52:34 +0000 (09:52 +0100)]
hurd: Remove lingering references to the time function
They cause a check-localplt failure after commit
f9a7554009cf38f39.
Fixes:
f9a7554009cf38f390e74fcabc5b49f974f72382
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Change-Id: I37bc20f3449b9e358f32879ed231720c969965b4
liqingqing [Thu, 7 Nov 2019 00:26:54 +0000 (00:26 +0000)]
math: enhance the endloop condition of function handle_input_flag
In the function handle_input_flag, the end-loop condition is not
correct, because when the loop variable i equals 16
(num_input_flag_types), then input_flags[16] will be out of bounds.
(This issue is only relevant with invalid input files to
gen-auto-libm-tests.)
Adhemerval Zanella [Tue, 5 Nov 2019 21:52:48 +0000 (21:52 +0000)]
nptl: Refactor thrd_sleep in terms of clock_nanosleep
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Tue, 5 Nov 2019 21:37:44 +0000 (21:37 +0000)]
Refactor nanosleep in terms of clock_nanosleep
The generic version is straightforward. For Hurd, its nanosleep
implementation is moved to clock_nanosleep with adjustments from
generic unix implementation.
The generic clock_nanosleep unix version is also removed since
it calls nanosleep.
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Tue, 5 Nov 2019 19:59:36 +0000 (19:59 +0000)]
nptl: Move nanosleep implementation to libc
Checked on x86_64-linux-gnu and powerpc64le-linux-gnu. I also checked
the libpthread.so .gnu.version_d entries for every ABI affected and
all of them contains the required versions (including for architectures
which exports __nanosleep with a different version).
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Mon, 4 Nov 2019 19:47:11 +0000 (16:47 -0300)]
posix: Sync regex with gnulib
It sync with gnulib commit
6cfb4302b3e1da14d706198b693558290e9b00f4
and contains the fixes:
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=
32915b2a8a43825720755113bdffe9f67a591748
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=
48f07576b8cd935b48e1050551f45ab1a79b9f01
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=
5e407aba1f775d51b25481cb55f324c9868f62d7
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=
4e02b30c761c76d04057fa5f6bba71401f9310cd
https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=
79f8ee4e389f8cb1339f8abed9a7d29816e2a2d4
Checked on x86_64-linux-gnu and i686-linux-gnu.
Mike FABIAN [Tue, 5 Nov 2019 11:26:58 +0000 (12:26 +0100)]
Add mnw language code [BZ #25139]
Talachan Mon [Tue, 5 Nov 2019 09:35:55 +0000 (10:35 +0100)]
Add new locale: mnw_MM (Mon language spoken in Myanmar) [BZ #25139]
Stefan Liebler [Wed, 6 Nov 2019 07:07:40 +0000 (08:07 +0100)]
S390: Fp comparison are now raising FE_INVALID with gcc 10.
The s390 gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77918
"S390: Floating point comparisons don't raise invalid for unordered operands."
is fixed with gcc 10. Thus we conditionally set FIX_COMPARE_INVALID
to 0 or 1.
Lukasz Majewski [Tue, 5 Nov 2019 10:22:28 +0000 (11:22 +0100)]
linux: pselect: Remove CALL_PSELECT6 macro
Nothing defines CALL_PSELECT6 in the current tree, so remove it.
Tested with:
- make PARALLELMFLAGS="-j8" && make xcheck PARALLELMFLAGS="-j8" (x86_64)
- scripts/build-many-glibcs.py
Arjun Shankar [Tue, 5 Nov 2019 15:41:25 +0000 (16:41 +0100)]
Fix run-one-test so that it runs elf tests
The `test' make target passes a trailing slash in the subdir argument. This
does not play well with elf/rtld-Rules which looks for `elf' without any
trailing slash, and therefore doesn't find a match when running an elf test
individually. This commit removes the trailing slash from the invocation.
Reviewed-by: DJ Delorie <dj@redhat.com>
Mike Crowe [Mon, 4 Nov 2019 19:36:21 +0000 (16:36 -0300)]
nptl: Fix niggles with pthread_clockjoin_np
Joseph Myers spotted[1] that
69ca4b54c151cec42ccca5e05790efc1a8206b47 added
pthread_clockjoin_np to sysdeps/nptl/pthread.h but not to its hppa-specific
equivalent sysdeps/unix/sysv/linux/hppa/pthread.h.
Rafal Luzynski spotted[2] typos in the NEWS entry and manual updates too.
Florian Weimer spotted[3] that the clockid parameter was not using a
reserved identifier in pthread.h.
[1] https://sourceware.org/ml/libc-alpha/2019-11/msg00016.html
[2] https://sourceware.org/ml/libc-alpha/2019-11/msg00019.html
[3] https://sourceware.org/ml/libc-alpha/2019-11/msg00022.html
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
Reviewed-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: Florian Weimer <fw@deneb.enyo.de>
John David Anglin [Sun, 3 Nov 2019 21:28:01 +0000 (16:28 -0500)]
hppa: Align __clone stack argument to 8 bytes (Bug 25066)
The hppa architecture requires strict alignment for loads and stores.
As a result, the minimum stack alignment that will work is 8 bytes.
This patch adjusts __clone() to align the stack argument passed to it.
It also adjusts slightly some formatting.
This fixes the nptl/tst-tls1 test.
Lukasz Majewski [Thu, 24 Oct 2019 12:34:46 +0000 (14:34 +0200)]
y2038: linux: Provide __futimens64 implementation
This patch provides new __futimens64 explicit 64 bit function for
setting access and modification time of file (by using its file descriptor).
Moreover, a 32 bit version - __futimens has been refactored to internally use
__futimens64.
The __futimens is now supposed to be used on systems still supporting
32 bit time (__TIMESIZE != 64) - hence the necessary conversions to 64 bit
struct __timespec64.
When pointer to struct __timespec64 is NULL - the file access and modification
time is set to the current one (by the kernel) and no conversions from struct
timespec to __timespec64 are performed.
The __futimens64 reuses __utimensat64_helper defined for __utimensat64.
The test procedure for __futimens64 is the same as for __utimensat64 conversion
patch.
Lukasz Majewski [Thu, 24 Oct 2019 10:12:16 +0000 (12:12 +0200)]
y2038: linux: Provide __utimensat64 implementation
This patch provides new __utimensat64 explicit 64 bit function for
setting access and modification time of a file. Moreover, a 32 bit version
- __utimensat has been refactored to internally use __utimensat64.
The __utimensat is now supposed to be used on systems still supporting
32 bit time (__TIMESIZE != 64) - hence the necessary conversions to 64 bit
struct __timespec64.
When pointer to struct __timespec64 is NULL - the file access and modification
time is set to the current one and no conversions from struct timespec to
__timespec64 are performed.
The new utimensat_time64 syscall available from Linux 5.1+ has been used,
when applicable.
The new helper function - __utimensat64_helper - has been introduced to
facilitate code re-usage on function providing futimens syscall handling.
The Linux kernel checks if passed tv_nsec value overflows, so there is no
need to repeat it in glibc.
When utimensat syscall on systems supporting 32 bit time ABI is used,
the check is performed if passed data (which may have 64 bit tv_sec) fits
into 32 bit range.
Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make PARALLELMFLAGS="-j8" && make xcheck PARALLELMFLAGS="-j8"
- The glibc has been build tested (make PARALLELMFLAGS="-j8") for
x86 (i386), x86_64-x32, and armv7
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
- Use of cross-test-ssh.sh for ARM (armv7):
make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck
Linux kernel, headers and minimal kernel version for glibc build test
matrix:
- Linux v5.1 (with utimensat_time64) and glibc build with v5.1 as
minimal kernel version (--enable-kernel="5.1.0")
The __ASSUME_TIME64_SYSCALLS flag defined.
- Linux v5.1 and default minimal kernel version
The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports utimensat_time64
syscall.
- Linux v4.19 (no utimensat_time64 support) with default minimal kernel
version for contemporary glibc
This kernel doesn't support utimensat_time64 syscall, so the fallback
to utimensat is tested.
The above tests were performed with Y2038 redirection applied as well as
without (so the __TIMESIZE != 64 execution path is checked as well).
No regressions were observed.
Mike Crowe [Thu, 31 Oct 2019 13:05:17 +0000 (10:05 -0300)]
nptl: Add pthread_timedjoin_np, pthread_clockjoin_np NULL timeout test
Passing NULL as the timeout parameter to pthread_timedjoin_np has resulted
in it behaving like pthread_join for a long time. Since that is now the
documented behaviour, we ought to test that both it and the new
pthread_clockjoin_np support it.
Checked on x86_64-linux-gnu.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Mike Crowe [Thu, 31 Oct 2019 13:03:21 +0000 (10:03 -0300)]
nptl: Add pthread_clockjoin_np
Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np that
accepts a clockid_t parameter to indicate which clock the timeout should be
measured against. This mirrors the recently-added POSIX-proposed "clock"
wait functions.
Checked on x86_64-linux-gnu.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Mike Crowe [Thu, 31 Oct 2019 12:08:57 +0000 (09:08 -0300)]
manual: Add documentation for pthread_tryjoin_np and pthread_timedjoin_np
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Mike Crowe [Thu, 31 Oct 2019 12:08:10 +0000 (09:08 -0300)]
nptl: Convert tst-join3 to use libsupport
Checked on x86_64-linux-gnu.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Paul Eggert [Thu, 31 Oct 2019 20:15:57 +0000 (13:15 -0700)]
Sync time/mktime.c with gnulib
This syncs with gnulib commit
9e78024bad107fe786cc3e5e328a475921ea0873.
* time/mktime.c: Update URL in comment.
Adhemerval Zanella [Thu, 31 Oct 2019 17:46:44 +0000 (14:46 -0300)]
Sync timespec-{add,sub} with gnulib
It sync with gnulib commit
06011ed74e978613422aca43c0bd92dc44213933.
Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
Adhemerval Zanella [Thu, 31 Oct 2019 17:30:55 +0000 (14:30 -0300)]
Sync intprops.h with gnulib
It sync with gnulib commit
f5756b919addb9e8ce03f4e61a10e4fcff14874a.
Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
Adhemerval Zanella [Mon, 28 Oct 2019 17:55:22 +0000 (14:55 -0300)]
Refactor adjtimex based on clock_adjtime
Checked on x86_64-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Wed, 30 Oct 2019 16:29:40 +0000 (13:29 -0300)]
Refactor PI mutexes internal definitions
This patch adds the generic futex_lock_pi and futex_unlock_pi to wrap
around the syscall machinery required to issue the syscall calls. It
simplifies a bit the futex code required to implement PI mutexes.
No function changes, checked on x86_64-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Wed, 30 Oct 2019 17:04:08 +0000 (14:04 -0300)]
Remove pause and nanosleep not cancel wrappers
Since they are not used any longer.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Wed, 30 Oct 2019 18:56:39 +0000 (15:56 -0300)]
nptl: Replace non cancellable pause/nanosleep with futex
To help y2038 work avoid duplicate all the logic of nanosleep on
non cancellable version, the patch replace it with a new futex
operation, lll_timedwait. The changes are:
- Add a expected value for __lll_clocklock_wait, so it can be used
to wait for generic values.
- Remove its internal atomic operation and move the logic to
__lll_clocklock. It makes __lll_clocklock_wait even more generic
and __lll_clocklock slight faster on fast-path (since it won't
require a function call anymore).
- Add lll_timedwait, which uses __lll_clocklock_wait, to replace both
__pause_nocancel and __nanosleep_nocancel.
It also allows remove the sparc32 __lll_clocklock_wait implementation
(since it is similar to the generic one).
Checked on x86_64-linux-gnu, sparcv9-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Tue, 29 Oct 2019 22:15:15 +0000 (19:15 -0300)]
Consolidate lowlevellock-futex.h
NPTL is already Linux specific, there is no need to parametrize low
level lock futex operations and add a sysdep Linux specific
implementation. This patch moves the relevant Linux code to nptl one.
Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Tue, 29 Oct 2019 21:52:19 +0000 (18:52 -0300)]
Consolidate futex-internal.h
NPTL is already Linux specific, there is no need to parametrize futex
operations and add a sysdep Linux specific implementation. This patch
moves the relevant Linux code to nptl one.
Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
DJ Delorie [Wed, 30 Oct 2019 22:03:14 +0000 (18:03 -0400)]
Base max_fast on alignment, not width, of bins (Bug 24903)
set_max_fast sets the "impossibly small" value based on,
eventually, MALLOC_ALIGNMENT. The comparisons for the smallest
chunk used is, eventually, MIN_CHUNK_SIZE. Note that i386
is the only platform where these are the same, so a smallest
chunk *would* be put in a no-fastbins fastbin.
This change calculates the "impossibly small" value
based on MIN_CHUNK_SIZE instead, so that we can know it will
always be impossibly small.
Zack Weinberg [Mon, 19 Aug 2019 14:31:07 +0000 (10:31 -0400)]
Revise the documentation of simple calendar time.
This is a thorough revision of all the material relating to the
functions time, stime, gettimeofday, settimeofday, clock_gettime,
clock_getres, clock_settime, and difftime, spilling over into the
discussion of time-related data types (which now get their own
section) and touching the adjtime family as well (which deserves its
own thorough revision, but I'd have to do a bunch of research first).
Substantive changes are:
* Document clock_gettime, clock_getres, and clock_settime. (Only
CLOCK_REALTIME and CLOCK_MONOTONIC are documented; the others are
either a bit too Linux-specific, or have more to do with measuring
CPU/processor time. That section _also_ deserves its own thorough
revision but again I'd have to do a bunch of research first.)
* Present gettimeofday, settimeofday, and struct timeval as obsolete
relative to clock_*.
* Remove the documentation of struct timezone. Matching POSIX,
say that the type of the second argument to gettimeofday and
settimeofday is [const] void *.
* Clarify ISO C and POSIX's requirements on time_t. Clarify the
circumstances under which difftime is equivalent to simple
subtraction.
* Consolidate documentation of most of the time-related data types
into a new section "Time Types," right after "Time Basics." (The
exceptions are struct tm, which stays in "Broken-down Time," and
struct times, which stays in "Processor And CPU Time."
* The "Elapsed Time" section is now called "Calculating Elapsed Time"
and includes only difftime and the discussion of how to compute
timeval differences by hand.
* Fold the "Simple Calendar Time," "High Resolution Calendar," and
"High Accuracy Clock" sections together into two new sections titled
"Getting the Time" and "Setting and Adjusting the Time."
Zack Weinberg [Mon, 19 Aug 2019 17:51:25 +0000 (13:51 -0400)]
Make second argument of gettimeofday as 'void *'
Also make the public prototype of gettimeofday declare its second
argument with type "void *" unconditionally, consistent with POSIX.
It is also consistent with POSIX.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Adhemerval Zanella [Thu, 24 Oct 2019 19:19:33 +0000 (19:19 +0000)]
Use clock_gettime to implement gettimeofday.
Consolidate generic gettimeofday implementation to use clock_gettime.
Linux ports that still provide gettimeofday through vDSO are not
changed.
Remove sysdeps/unix/clock_gettime.c, which implemented clock_gettime
using gettimeofday; new OS ports must provide a real implementation of
clock_gettime.
Rename sysdeps/mach/gettimeofday.c to sysdeps/mach/clock_gettime.c and
convert into an implementation of clock_gettime. It only supports
CLOCK_REALTIME; Mach does not appear to have any support for monotonic
clocks. It uses __host_get_time, which provides at best microsecond
resolution. Hurd is currently using sysdeps/posix/clock_getres.c for
clock_getres; its output for CLOCK_REALTIME is based on
sysconf (_SC_CLK_TCK), and I do not know whether that gives the
correct result.
Unlike settimeofday, there are no known uses of gettimeofday's
vestigial "get time zone" feature that are not bugs. (The per-process
timezone support in localtime and friends is unrelated, and the
programs that set the kernel's offset between the hardware clock and
UTC do not need to read it back.) Therefore, this feature is dummied
out. Henceforth, if gettimeofday's "struct timezone" argument is not
NULL, it will write zeroes to both fields. Any program that is
actually looking at this data will thus think it is running in UTC,
which is probably more correct than whatever it was doing before.
[__]gettimeofday no longer has any internal callers, so we can now
remove its internal prototype and PLT bypass aliases. The
__gettimeofday@GLIBC_2.0 export remains, in case it is used by any
third-party code.
It also allows to simplify the arch-specific implementation on x86 and
powerpc to remove the hack to disable the internal route to non iFUNC
variant for internal symbol.
This patch also fixes a missing optimization on aarch64, powerpc, and
x86 where the code used on static build do not use the vDSO.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.
Co-authored-by: Zack Weinberg <zackw@panix.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Zack Weinberg [Thu, 22 Aug 2019 21:10:35 +0000 (17:10 -0400)]
Use clock_gettime to implement timespec_get.
timespec_get is the same function as clock_gettime, with an obnoxious
coating of NIH painted on it by the ISO C committee. In addition to
the rename, it takes its arguments in a different order, it returns 0
on *failure* or a positive number on *success*, and it requires that
all of its TIME_* constants be positive. This last means we cannot
directly reuse the existing CLOCK_* constants for it, because
those have been allocated starting with CLOCK_REALTIME = 0 on all
existing platforms.
This patch simply promotes the sysdeps/posix implementation to
universal, and removes the Linux-specific implementation, whose
apparent reason for existing was to cut out one function call's worth
of overhead.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Zack Weinberg [Wed, 4 Sep 2019 16:51:23 +0000 (16:51 +0000)]
Consolidate and deprecate ftime
ftime is an obsolete variation on gettimeofday, offering only
millisecond time resolution; it was probably a system call in ooold
versions of BSD Unix. For historic reasons, we had three
implementations of it. These are all consolidated into time/ftime.c,
and then the function is deprecated.
For some reason, the implementation of ftime in terms of gettimeofday
was rounding rather than truncating microseconds to milliseconds. In
all the other places where we use a higher-resolution time function to
implement a lower-resolution one, we truncate. ftime is changed to
match, just for tidiness' sake.
Like gettimeofday, ftime tries to report the time zone, and using that
information is always a bug. This patch dummies out the reported
timezone information; the timezone and dstflag fields of the
returned "struct timeb" will always be zero.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, and powerpc-linux-gnu.
Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Adhemerval Zanella [Thu, 24 Oct 2019 21:01:40 +0000 (21:01 +0000)]
Change most internal uses of time to __clock_gettime.
As for gettimeofday, time will be implemented based on clock_gettime
on all platforms and internal code should use clock_gettime
directly. In addition to removing a layer of indirection, this will
allow us to remove the PLT-bypass gunk for gettimeofday.
The changed code always assumes __clock_gettime (CLOCK_REALTIME)
or __clock_gettime (CLOCK_REALTIME_COARSE) (for Linux case) cannot
fail, using the same rationale for gettimeofday change. And internal
helper was added (time_now).
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, and powerpc-linux-gnu.
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Adhemerval Zanella [Thu, 24 Oct 2019 17:52:30 +0000 (17:52 +0000)]
Use clock_gettime to implement time.
Change the default implementation of time to call clock_gettime,
to align with new Linux ports that are expected to only implement
__NR_clock_gettime. Arch-specific implementation that either call
the time vDSO or route to gettimeofday vDSO are not removed.
Also for Linux, CLOCK_REALTIME_COARSE is used instead of generic
CLOCK_REALTIME clockid. This takes less CPU time and its behavior
better matches what the current glibc does.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.
Co-authored-by: Zack Weinberg <zackw@panix.com>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Zack Weinberg [Wed, 28 Aug 2019 12:25:49 +0000 (08:25 -0400)]
Use clock_settime to implement settimeofday.
Unconditionally, on all ports, use clock_settime to implement
settimeofday. Remove sysdeps/unix/clock_settime.c, which implemented
clock_settime by calling settimeofday; new OS ports must henceforth
provide a real implementation of clock_settime.
Hurd had a real implementation of settimeofday but not of
clock_settime; this patch converts it into an implementation of
clock_settime. It only supports CLOCK_REALTIME and microsecond
resolution; Hurd/Mach does not appear to have any support for
finer-resolution clocks.
The vestigial "set time zone" feature of settimeofday complicates the
generic settimeofday implementation a little. The only remaining uses
of this feature that aren't just bugs, are using it to inform the
Linux kernel of the offset between the hardware clock and UTC, on
systems where the hardware clock doesn't run in UTC (usually because
of dual-booting with Windows). There currently isn't any other way to
do this. However, the callers that do this call settimeofday with
_only_ the timezone argument non-NULL. Therefore, glibc's new
behavior is: callers of settimeofday must supply one and only one of
the two arguments. If both arguments are non-NULL, or both arguments
are NULL, the call fails and sets errno to EINVAL.
When only the timeval argument is supplied, settimeofday calls
__clock_settime(CLOCK_REALTIME), same as stime.
When only the timezone argument is supplied, settimeofday calls a new
internal function called __settimezone. On Linux, only, this function
will pass the timezone structure to the settimeofday system call. On
all other operating systems, and on Linux architectures that don't
define __NR_settimeofday, __settimezone is a stub that always sets
errno to ENOSYS and returns -1.
The settimeoday syscall is enabled on Linux by the flag
COMPAT_32BIT_TIME, which is an option to either 32-bits ABIs or COMPAT
builds (defined usually by 64-bit kernels that want to support 32-bit
ABIs, such as x86). The idea to future 64-bit time_t only ABIs
is to not provide settimeofday syscall.
The same semantics are implemented for Linux/Alpha's GLIBC_2.0 compat
symbol for settimeofday.
There are no longer any internal callers of __settimeofday, so the
internal prototype is removed.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Zack Weinberg [Fri, 16 Aug 2019 19:03:16 +0000 (15:03 -0400)]
Use clock_settime to implement stime; withdraw stime.
Unconditionally, on all ports, use clock_settime to implement stime,
not settimeofday or a direct syscall. Then convert stime into a
compatibility symbol and remove its prototype from time.h.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Zack Weinberg [Sat, 17 Aug 2019 00:38:22 +0000 (20:38 -0400)]
Change most internal uses of __gettimeofday to __clock_gettime.
Since gettimeofday will shortly be implemented in terms of
clock_gettime on all platforms, internal code should use clock_gettime
directly; in addition to removing a layer of indirection, this will
allow us to remove the PLT-bypass gunk for gettimeofday. (We can't
quite do that yet, but it'll be coming later in this patch series.)
In many cases, the changed code does fewer conversions.
The changed code always assumes __clock_gettime (CLOCK_REALTIME)
cannot fail. Most of the call sites were assuming gettimeofday could
not fail, but a few places were checking for errors. POSIX says
clock_gettime can only fail if the clock constant is invalid or
unsupported, and CLOCK_REALTIME is the one and only clock constant
that's required to be supported. For consistency I grepped the entire
source tree for any other places that checked for errors from
__clock_gettime (CLOCK_REALTIME), found one, and changed it too.
(For the record, POSIX also says gettimeofday can never fail.)
(It would be nice if we could declare that GNU systems will always
support CLOCK_MONOTONIC as well as CLOCK_REALTIME; there are several
places where we are using CLOCK_REALTIME where _MONOTONIC would be
more appropriate, and/or trying to use _MONOTONIC and then falling
back to _REALTIME. But the Hurd doesn't support CLOCK_MONOTONIC yet,
and it looks like adding it would involve substantial changes to
gnumach's internals and API. Oh well.)
A few Hurd-specific files were changed to use __host_get_time instead
of __clock_gettime, as this seemed tidier. We also assume this cannot
fail. Skimming the code in gnumach leads me to believe the only way
it could fail is if __mach_host_self also failed, and our
Hurd-specific code consistently assumes that can't happen, so I'm
going with that.
With the exception of support/support_test_main.c, test cases are not
modified, mainly because I didn't want to have to figure out which
test cases were testing gettimeofday specifically.
The definition of GETTIME in sysdeps/generic/memusage.h had a typo and
was not reading tv_sec at all. I fixed this. It appears nobody has been
generating malloc traces on a machine that doesn't have a superseding
definition.
There are a whole bunch of places where the code could be simplified
by factoring out timespec subtraction and/or comparison logic, but I
want to keep this patch as mechanical as possible.
Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
Zack Weinberg [Mon, 19 Aug 2019 18:18:08 +0000 (14:18 -0400)]
Linux/Alpha: don't use timeval32 system calls.
Linux/Alpha has two versions of several system call wrappers that take
or return data of type "struct timeval" (possibly nested inside a
larger structure). The GLIBC_2.0 version is a compat symbol that
calls __NR_osf_foo or __NR_old_foo and uses a struct timeval with a
32-bit tv_sec field. The GLIBC_2.1 version is used for current code,
calls __NR_foo, and uses a struct timeval with a 64-bit tv_sec field.
This patch changes all of the compat symbols of this type to be
wrappers around their GLIBC_2.1 counterparts; the compatibility system
calls will no longer be used. It serves as a proposal for part of how
we do the transition to 64-bit time_t on systems that currently use
32-bit time_t:
* The patched glibc will NOT use system calls that involve 32-bit
time_t to implement its compatibility symbols. This will make both
our lives and the kernel maintainers' lives easier. The primary
argument I've seen against it is that the kernel could warn about
uses of the old system calls, helping people find old binaries that
need to be recompiled. I think there are several other ways we
could accomplish this, e.g. scripts to scan the filesystem for
binaries with references to the old symbol versions, or issuing
diagnostics ourselves.
* The compat symbols do NOT report failure after the Y2038 deadline.
An earlier revision of this patch had them return -1 and set errno
to EOVERFLOW, but Adhemerval pointed out that many of them have
already performed side effects at the point where we discover the
overflow, so that would break more than it fixes. Also, we don't
want people to be _checking_ for EOVERFLOW from these functions; we
want them to recompile with 64-bit time_t. So it's not actually
useful for them to report failure to the calling code.
* What they do do, when they encounter overflow, is saturate the
overflowed "struct timeval"(s): tv_sec is set to INT32_MAX and
tv_nsec is set to 999999. That means time stops advancing for
programs with 32-bit time_t when they reach the deadline. That's
obviously going to break stuff, but I think wrapping around is
probably going to break _more_ stuff. I'd be interested to hear
arguments against, if anyone has one.
The new header file tv32-compat.h is currently Alpha-specific but I
mean for it to be reused to aid in writing wrappers for all affected
architectures. I only put it in sysdeps/unix/sysv/linux/alpha for now
because I haven't checked whether the various "foo32" structures it
defines agree with the ABI for ports other than Linux/Alpha.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Florian Weimer [Wed, 30 Oct 2019 16:44:09 +0000 (17:44 +0100)]
resolv/tst-idna_name_classify: Isolate from system libraries
Loading NSS modules from static binaries uses installed system
libraries if LD_LIBRARY_PATH is not set.
Svante Signell [Wed, 30 Oct 2019 00:23:41 +0000 (01:23 +0100)]
hurd: Support for file record locking
* sysdeps/mach/hurd/fcntl.c: Add support for file-record-lock RPC
fixing posix file locking using the flock64 version of struct
flock.
Carlos O'Donell [Tue, 29 Oct 2019 15:58:03 +0000 (11:58 -0400)]
Comment out initgroups from example nsswitch.conf (Bug 25146)
In commit
4b7c74179c8928d971d370e1137d202f891a4cf5 the nsswitch.conf
file was harmonized with downstream distributions, but this change
included adding "initgroups: files". We should not add initgroups by
default, we can have it, but it should be commented out to allow it
to inherit the settings for group. The problem is principally that
downstream authconfig won't update initgroups and it will get out of
sync with the setting for group.
Lukasz Majewski [Tue, 15 Oct 2019 15:57:05 +0000 (17:57 +0200)]
y2038: linux: Provide __clock_getres64 implementation
This patch provides new __clock_getres64 explicit 64 bit function for
getting the resolution (precision) of specified clock ID. Moreover, a
32 bit version - __clock_getres has been refactored to internally use
__clock_getres64.
The __clock_getres is now supposed to be used on systems still supporting
32 bit time (__TIMESIZE != 64) - hence the necessary conversion from 64 bit
struct __timespec64 to struct timespec.
The new clock_getres_time64 syscall available from Linux 5.1+ has been used,
when applicable.
On systems which are not supporting clock_getres_time64 (as their
clock_getres supports 64 bit time ABI) the vDSO syscall is attempted.
On the contrary the non-vDSO syscall is used for clock_getres_time64 as
up till now the kernel is not providing such interface.
No additional checks (i.e. if tv_nsec value overflow) are performed on
values returned via clock_getres{_time64} syscall, as it is assumed that
the Linux kernel will either return 0 and provide correct value or error.
The check for tv_sec being out of range on systems still supporting 32 bit
time (__TIMESIZE != 64) without Y2038 time support is also omitted as it is
_very_ unlikely that we would have a timer with resolution which exceeds 32
bit time_t range.
Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make PARALLELMFLAGS="-j8" && make xcheck PARALLELMFLAGS="-j8"
- The glibc has been build tested (make PARALLELMFLAGS="-j8") for
x86 (i386), x86_64-x32, and armv7
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
- Use of cross-test-ssh.sh for ARM (armv7):
make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck
Linux kernel, headers and minimal kernel version for glibc build test
matrix:
- Linux v5.1 (with clock_getres_time64) and glibc build with v5.1 as
minimal kernel version (--enable-kernel="5.1.0")
The __ASSUME_TIME64_SYSCALLS flag defined.
- Linux v5.1 and default minimal kernel version
The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports
clock_getres_time64 syscall.
- Linux v4.19 (no clock_getres_time64 support) with default minimal kernel
version for contemporary glibc
This kernel doesn't support clock_getres_time64 syscall, so the fallback
to clock_getres is tested.
The above tests were performed with Y2038 redirection applied as well as
without (so the __TIMESIZE != 64 execution path is checked as well).
No regressions were observed.
Lukasz Majewski [Thu, 24 Oct 2019 14:20:56 +0000 (16:20 +0200)]
time: Introduce function to check correctness of nanoseconds value
The valid_nanoseconds () static inline function has been introduced to
check if nanoseconds value is in the correct range - greater or equal to
zero and less than
1000000000.
The explicit #include <time.h> has been added to files where it was
missing.
The __syscall_slong_t type for ns has been used to avoid issues on x32.
Tested with:
- scripts/build-many-glibcs.py
- make PARALLELMFLAGS="-j12" && make PARALLELMFLAGS="-j12" xcheck on x86_64
Arjun Shankar [Wed, 23 Oct 2019 16:51:29 +0000 (18:51 +0200)]
Add Transliterations for Unicode Misc. Mathematical Symbols-A/B [BZ #23132]
This commit adds previously missing transliterations for several code points
in the Unicode blocks "Miscellaneous Mathematical Symbols-A/B" -
transliterated to their approximate ASCII representations. It also adds a
corresponding iconv transliteration test.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
DJ Delorie [Wed, 23 Oct 2019 21:52:26 +0000 (17:52 -0400)]
Install charmaps uncompressed in testroot
The testroot does not have a gunzip command, so the charmap files
should not be installed gzipped else they cannot be used (and thus
tested). With this patch, installing with INSTALL_UNCOMPRESSED=yes
installs uncompressed charmaps instead.
Note that we must purge the $(symbolic_link_list) as it contains
references to $(DESTDIR), which we change during the testroot
installation.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
DJ Delorie [Wed, 2 Oct 2019 18:46:46 +0000 (14:46 -0400)]
Add wait-for-debugger test harness hooks
If WAIT_FOR_DEBUGGER is set to a non-zero value in the environment,
any test that runs will print some useful gdb information and wait
for gdb to attach to it and clear the "wait_for_debugger" variable.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Alistair Francis [Tue, 13 Aug 2019 20:35:28 +0000 (13:35 -0700)]
Define __STATFS_MATCHES_STATFS64
Add a new macro __STATFS_MATCHES_STATFS64 that specifies if fsblkcnt_t
matches fsblkcnt64_t and if fsfilcnt_t matches fsfilcnt64_t.
As we don't have the padding we also need to update the overflow checker
to not access the undefined members.
Florian Weimer [Thu, 24 Oct 2019 13:51:29 +0000 (15:51 +0200)]
hurd: Fix build after __pread64 usage in the dynamic loader
Commit
95c1056962a3f2297c94ce47f0eaf0c5b6563231 ("elf: Use nocancel
pread64() instead of lseek()+read()") added calls to __pread64 to
the dynamic loader. On Hurd, this needs an implementation in the
dynamic loader because the rtld-pread64 rebuild pulls in too many
symbols.
Fixes:
95c1056962a3f2297c94ce47f0eaf0c5b6563231
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Alistair Francis [Tue, 13 Aug 2019 20:18:06 +0000 (13:18 -0700)]
sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts
On a 32-bit platform with a 64-bit ino_t type (__INO_T_MATCHES_INO64_T
defined) we want to update the stat struct to remove the padding as it
isn't required. As we don't have the padding we also need to update the
overflow checker to not access the undefined members.
Stefan Liebler [Wed, 23 Oct 2019 12:51:53 +0000 (14:51 +0200)]
S390: Remove not needed stack frame in syscall function.
As an svc invocation does not clobber any user space registers
despite of the return value r2 and it does not need a special
stack frame. This patch gets rid of the extra frame.
We just have to save and restore r6 and r7 as those are
preserved across function calls.
Joseph Myers [Tue, 22 Oct 2019 20:24:10 +0000 (20:24 +0000)]
Fix testroot.pristine creation copying dynamic linker.
This patch addresses an issue reported in
<https://sourceware.org/ml/libc-alpha/2019-07/msg00661.html> where the
creation of testroot.pristine, on encountering
LD_TRACE_LOADED_OBJECTS=1 of the form
libc.so.6 => /scratch/jmyers/glibc/mbs/obj/glibc-8-0-mips64-linux-gnu-x86_64-linux-gnu/default/libc.so.6 (0x772dd000)
/lib32/ld.so.1 => /scratch/jmyers/glibc/mbs/obj/glibc-8-0-mips64-linux-gnu-x86_64-linux-gnu/default/elf/ld.so.1 (0x7747b000)
tries to copy /lib32/ld.so.1 (which does not exist) into the testroot
instead of copying the path on the RHS of "=>", which does exist,
because the Makefile logic assumes that the path on such a line with
'/' should be copied, when if there are such paths on both the LHS and
the RHS of "=>", only the one on the RHS necessarily exists and so
only that should be copied. The patch follows the approach suggested
by DJ in <https://sourceware.org/ml/libc-alpha/2019-07/msg00662.html>,
with the suggestion from Andreas in
<https://sourceware.org/ml/libc-alpha/2019-10/msg00514.html> of a
single sed command in place of pipeline of grep and three sed
commands.
Tested for x86_64, with and without --enable-hardcoded-path-in-tests;
a previous version with multiple sed commands, implementing the same
logic, also tested for MIPS, with and without
--enable-hardcoded-path-in-tests, to confirm it fixes the original
problem.
Co-authored-by: DJ Delorie <dj@redhat.com>
Wilco Dijkstra [Tue, 16 Jul 2019 14:29:06 +0000 (11:29 -0300)]
Remove x64 _finite tests and references
Remove _finite tests and references from x86_64. Rather than calling
__exp_finite, use exp directly (since it's the same entry point).
x86_64 builds and passes testsuite.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Wilco Dijkstra [Tue, 16 Jul 2019 13:39:56 +0000 (10:39 -0300)]
Remove finite-math tests
Remove the finite-math tests from the testsuite - these are no longer
useful after removing math-finite.h header.
Passes buildmanyglibc, build&test on x86_64 and AArch64.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Wilco Dijkstra [Tue, 16 Jul 2019 13:08:57 +0000 (10:08 -0300)]
Remove math-finite.h
Remove math-finite.h redirections for math functions.
Passes buildmanyglibc.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Lukasz Majewski [Fri, 18 Oct 2019 09:33:59 +0000 (11:33 +0200)]
Include <kernel-features.h> explicitly in Linux clock_settime.c
The rewritten clock_settime code (which now supports 64 bit time on systems
with __WORDSIZE == 32) for Linux now relies on the
__ASSUME_TIME64_SYSCALLS flag set.
Lets explicitly include the header file where it is defined to avoid
any indirect inclusion (which may pose some unwanted API definitions).
Tested with scripts/build-many-glibcs.py script.
DJ Delorie [Fri, 18 Oct 2019 21:15:52 +0000 (17:15 -0400)]
loadarchive: guard against locale-archive corruption (Bug #25115)
_nl_load_locale_from_archive() checks for a zero size, but
divides by both (size) and (size-2). Extend the check to
guard against a size of two or less.
Tested by manually corrupting locale-archive and running a program
that calls setlocale() with LOCPATH unset (size is typically very
large).
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Carlos O'Donell [Fri, 18 Oct 2019 20:06:31 +0000 (16:06 -0400)]
Undo accidental commit to ChangeLog.19.
I had a local commit
fed33b0fb03 which crossed the boundary
between when we had and didn't have ChangeLog's and this
caused me to have an odd behaviour with the file rename,
despite cleaning up the original ChangeLog changes.
Sorry. Corrected now.
Carlos O'Donell [Fri, 4 Oct 2019 19:58:08 +0000 (15:58 -0400)]
nptl: Document AS-safe functions in cancellation.c.
Document in comments that __pthread_enable_asynccancel and
__pthread_disable_asynccancel must be AS-safe in general with
the exception of the act of cancellation.
Leandro Pereira [Wed, 2 Oct 2019 16:48:17 +0000 (12:48 -0400)]
elf: Use nocancel pread64() instead of lseek()+read()
Transforms this, when linking in a shared object:
openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3"..., 832) = 832
lseek(3, 792, SEEK_SET) = 792
read(3, "\4\0\0\0\24\0\0\0"..., 68) = 68
fstat(3, {st_mode=S_IFREG|0755, st_size=6699224, ...}) = 0
lseek(3, 792, SEEK_SET) = 792
read(3, "\4\0\0\0\24\0\0\0"..., 68) = 68
lseek(3, 864, SEEK_SET) = 864
read(3, "\4\0\0\0\20\0\0\0"..., 32) = 32
Into this:
openat(AT_FDCWD, "/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3"..., 832) = 832
pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) = 68
fstat(3, {st_mode=S_IFREG|0755, st_size=6699224, ...}) = 0
pread(3, "\4\0\0\0\24\0\0\0"..., 68, 792) = 68
pread(3, "\4\0\0\0\20\0\0\0"..., 32, 864) = 32
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Leandro Pereira [Wed, 2 Oct 2019 16:42:28 +0000 (12:42 -0400)]
Add nocancel version of pread64()
This is in preparation for changes in the dynamic linker so that
pread() is used instead of lseek()+read().
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
DJ Delorie [Mon, 30 Sep 2019 20:04:52 +0000 (16:04 -0400)]
Add run-one-test convenience target and makefile help text
Adds "make test" for re-running just one test. Also adds
"make help" for help with our Makefile targets, and adds a
mini-help when you just run "make".
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Mon, 20 May 2019 15:17:46 +0000 (12:17 -0300)]
Update sysvipc kernel-features.h files for Linux 5.1
Linux 5.1 adds missing SySV IPC syscalls to the syscall table for
remanining one that still uses the ipc syscall on glibc (m68k, mips-o32,
powerpc, s390, sh, and sparc32). However the newly added direct ipc
syscall are different than the old ones:
1. They do not expect IPC_64, meaning __IPC_64 should be set to zero
when new syscalls are used. And new syscalls can not be used
for compat functions like __old_semctl (to emulated old sysvipc it
requires to use the old __NR_ipc syscall without __IPC_64).
Thus IPC_64 is redefined for newer kernels on affected ABIs.
2. semtimedop and semop does not exist on 32-bit ABIs (only
semtimedop_time64 is supplied). The provided syscall wrappers only
uses the wire-up syscall if __NR_semtimedop and __NR_semop are
also defined.
Checked on x86_64-linux-gnu and i686-linux-gnu on both a 4.15 kernel
configure with default options and sysvipc tests on a 5.3.0 kernel with
--enable-kernel=5.1.
Tested-by: Paul A. Clarke <pc@us.ibm.com>
Stefan Liebler [Fri, 18 Oct 2019 12:57:14 +0000 (14:57 +0200)]
S390: Add new s390 platform z15.
The new IBM z15 is added to platform string array.
The macro _DL_PLATFORMS_COUNT is incremented.
Florian Weimer [Fri, 18 Oct 2019 12:29:04 +0000 (14:29 +0200)]
nptl: SIGCANCEL, SIGTIMER, SIGSETXID are always defined
All nptl targets have these signal definitions nowadays. This
changes also replaces the nptl-generic version of pthread_sigmask
with the Linux version.
Tested on x86_64-linux-gnu and i686-linux-gnu. Built with
build-many-glibcs.py.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Florian Weimer [Fri, 18 Oct 2019 12:28:49 +0000 (14:28 +0200)]
nptl/tst-cancel25 needs to be an internal test
Otherwise the definition of SIGCANCEL is not visible.
Tested on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Florian Weimer [Thu, 17 Oct 2019 19:36:34 +0000 (21:36 +0200)]
Remove libc_hidden_def from __semtimedop stub
This breaks the Hurd build after commit
765cdd0bffd77960ae852104f
("sysvipc: Implement semop based on semtimedop") added it to the stub.
Adhemerval Zanella [Fri, 11 Oct 2019 14:39:04 +0000 (11:39 -0300)]
sysvipc: Implement semop based on semtimedop
Besides semop being a subset of semtimedop, new 32-bit architectures
on Linux are not expected to provide the syscall (only the 64-bit time
semtimedop).
Also, Linux 5.1 only wired-up semtimedop for the 64-bit architectures
that missed it (powerpc, s390, and sparc). This simplifies the code
to support it.
Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Adhemerval Zanella [Wed, 15 May 2019 18:20:58 +0000 (15:20 -0300)]
ipc: Refactor sysvipc internal definitions
This patch refactor the internal sysvipc in two main points:
1. Add a new __ASSUME_SYSVIPC_DEFAULT_IPC_64 to infer the __IPC_64
value to be used along either the multiplexed __NR_ipc or wired-up
syscall. The defaut value assumed for __IPC_64 is also changed
from 0x100 to 0x0, aligning with Linux generic UAPI. The idea
is to simplify the Linux 5.1 wire-up for sysvipc syscalls for
some 32-bit ABIs (which expectes __IPC_64 being 0x0) and simplify
new ports (which will no longer need to add ipc_priv.h).
2. It also removes some duplicated internal definition used on compat
sysvipc symbols defined at ipc_priv.h (more specifically the
__old_ipc_perm, SEMCTL_ARG_ADDRESS, MSGRCV_ARGS, and
SEMTIMEDOP_IPC_ARGS). The idea is also to make it simpler to enable
the new wire-up sysvipc syscall provided by Linux v5.1.
There is no semantic change expected on any port. Checked with a build
against all affected ABIs.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Florian Weimer [Thu, 17 Oct 2019 06:51:21 +0000 (08:51 +0200)]
Rename and split elf/tst-dlopen-aout collection of tests
From the beginning, elf/tst-dlopen-aout has exercised two different
bugs: (a) failure to report errors for a dlopen of the executable
itself in some cases (bug 24900) and (b) incorrect rollback of the
TLS modid allocation in case of a dlopen failure (bug 16634).
This commit replaces the test with elf/tst-dlopen-self for (a) and
elf/tst-dlopen-tlsmodid for (b). The latter tests use the
elf/tst-dlopen-self binaries (or iconv) with dlopen, so they are
no longer self-dlopen tests.
Tested on x86_64-linux-gnu and i686-linux-gnu, with a toolchain that
does not default to PIE.
Florian Weimer [Wed, 16 Oct 2019 16:19:51 +0000 (18:19 +0200)]
dlfcn: Remove remnants of caller sensitivity from dlinfo
dlinfo operates on a specific handle, which means that there is no
caller sensivity involved.
Andreas Schwab [Wed, 9 Oct 2019 15:46:47 +0000 (17:46 +0200)]
ldconfig: handle .dynstr located in separate segment (bug 25087)
To determine the load offset of the DT_STRTAB section search for the
segment containing it, instead of using the load offset of the first
segment.
Florian Weimer [Tue, 15 Oct 2019 14:41:51 +0000 (16:41 +0200)]
ldd: Print "not a dynamic executable" on standard error [BZ #24150]
Tested with the testsuite on x86_64-linux-gnu, and manually.
Reviewed-By: Richard W.M. Jones <rjones@redhat.com>
Joseph Myers [Mon, 14 Oct 2019 23:43:52 +0000 (23:43 +0000)]
Add PTRACE_GET_SYSCALL_INFO from Linux 5.3 to sys/ptrace.h.
Linux 5.3 adds a PTRACE_GET_SYSCALL_INFO constant, with an associated
structure and PTRACE_SYSCALL_INFO_* constants.
This patch adds these to sys/ptrace.h in glibc
(PTRACE_GET_SYSCALL_INFO in each architecture version, the rest in
bits/ptrace-shared.h). As with previous such constants and associated
structures, the glibc version of the structure is named struct
__ptrace_syscall_info.
Tested for x86_64, and with build-many-glibcs.py.
Florian Weimer [Fri, 11 Oct 2019 20:42:32 +0000 (22:42 +0200)]
Move ChangeLog to ChangeLog.old/ChangeLog.19
We no longer maintain a manually-written ChangeLog file:
<https://sourceware.org/ml/libc-alpha/2019-09/msg00333.html>
<https://sourceware.org/ml/libc-alpha/2019-10/msg00131.html>
Instead the release manager is expected to generate a ChangeLog-like
file using scripts/gitlog_to_changelog.py. For further details,
see commit
f2144b7874b23be7c7eb184ec601633ec6fa8fac ("Script to
generate ChangeLog-like output from git log").
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Florian Weimer [Fri, 11 Oct 2019 18:15:24 +0000 (20:15 +0200)]
manual: Remove warning in the documentation of the abort function
The warning is confusing to those who do not understand the context,
and the warning is easy to misunderstand:
A reader needs to know that it was written by someone who is generally
skeptical of government influence and control, otherwise it reads as
an affirmation of the U.S. government's role as the ultimate editor of
the manual. This is precisely the opposite of what the warning
intends to convey. (Reportedly, it criticizes that several
U.S. administrations have tried to restrict the medical advice that
U.S.-funded health care workers can provide abroad, considering that
censorship.)
The warning is also misleading on a technical level. A reader who
makes the connection to pregnancy termination will get the wrong
impression that calling the abort function will terminate subprocesses
of the current process, but this is not what generally happens.
Finally, for both GNU and the FSF, it is inappropriate to use female
reproductive health as mere joke material, since these organizations
do not concern themselves with such issues otherwise, and the warning
is purportedly about something else entirely.
This reinstates commit
340d9652b9d0e1d4136588f18b726662d195777c
("manual/startup.texi (Aborting a Program): Remove inappropriate
joke."), effectively reverting the revert in commit
ffa81c22a3ac0fb75ad9bf2b1c3cdbf9eafa0bc9 ("Revert:").
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Adhemerval Zanella [Thu, 10 Oct 2019 18:13:11 +0000 (18:13 +0000)]
sysvipc: Set ipc_perm mode as mode_t (BZ#18231)
This patch sets the mode field in ipc_perm as mode_t for all architectures,
as POSIX specification [1]. The changes required are as follow:
1. It moves the ipc_perm definition out of ipc.h to its own header
ipc_perm.h. It also allows consolidate the IPC_* definition on
only one header.
2. The generic implementation follow the kernel ipc64_perm size so the
syscall can be made directly without temporary buffer copy. However,
since glibc defines the MODE field as mode_t, it omits the __PAD1 field
(since glibc does not export mode_t as 16-bit for any architecture).
It is a two-fold improvement:
2.1. New implementation which follow Linux UAPI will not need to
provide an arch-specific ipc-perm.h header neither wrongly
use the wrong 16-bit definition from previous default ipc.h
(as csky did).
2.1. It allows consolidate ipc_perm definition for architectures that
already provide mode_t as 32-bit.
3. All kernel ABIs for the supported architectures already provides the
expected padding for mode type extension to 32-bit. However, some
architectures the padding has the wrong placement, so it requires
the ipc control routines (msgctl, semctl, and shmctl) to adjust the
mode field accordingly. Currently they are armeb, microblaze, m68k,
s390, and sheb.
A new assume is added, __ASSUME_SYSVIPC_BROKEN_MODE_T, which the
required ABIs define.
4. For the ABIs that define __ASSUME_SYSVIPC_BROKEN_MODE_T, it also
require compat symbols that do not adjust the mode field.
Checked on arm-linux-gnueabihf, aarch64-linux-gnu, powerpc64le-linux-gnu,
and x86_64-linux-gnu. I also checked the sysvipc tests on hppa-linux-gnu,
sh4-linux-gnu, s390x-linux-gnu, and s390-linux-gnu.
I also did a sanity test against armeb qemu usermode for the sysvipc
tests.
[BZ #18231]
* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
bits/ipc-perm.h.
* sysdeps/unix/sysv/linux/aarch64/bits/ipc.h: Remove file.
* sysdeps/unix/sysv/linux/alpha/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/ipc.h: Likewise.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
[__BYTE_ORDER == __BIG_ENDIAN] (__ASSUME_SYSVIPC_BROKEN_MODE_T):
Define.
* sysdeps/sysv/linux/microblaze/kernel-features.h: Likewise.
* sysdeps/unix/sysv/linux/s390/kernel-features.h
[!__s390x__] (__ASSUME_SYSVIPC_BROKEN_MODE_T): Define.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
(__ASSUME_SYSVIPC_BROKEN_MODE_T): Define.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h: Likewise.
* sysdeps/unix/sysv/linux/bits/ipc-perm.h: New file.
* sysdeps/unix/sysv/linux/powerpc/bits/ipc-perm.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/ipc-perm.h: Likewise.
* sysdeps/unix/sysv/linux/bits/ipc.h (ipc_perm): Move to
bits/ipc-perm.h.
* sysdeps/unix/sysv/linux/hppa/bits/ipc-perm.h: New file.
* sysdeps/unix/sysv/linux/kernel-features.h: Add comment about
__ASSUME_SYSVIPC_BROKEN_MODE_T semantic.
* sysdeps/unix/sysv/linux/msgctl.c (DEFAULT_VERSION): Define as
2.31 if __ASSUME_SYSVIPC_BROKEN_MODE_T is defined.
(msgctl_syscall, __msgctl_mode16): New symbol.
(__new_msgctl): Add bits for __ASSUME_SYSVIPC_BROKEN_MODE_T.
* sysdeps/unix/sysv/linux/semctl.c: Likewise.
* sysdeps/unix/sysv/linux/shmctl.c: Likewise.
* sysdeps/unix/sysv/linux/arm/be/libc.abilist (GLIBC_2.31): Add
msgctl, semctl, and shmctl.
* sysdeps/sysv/linux/microblaze/be/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/be/libc.abilist: Likewise.
* conform/data/sys/ipc.h-data: Only xfail {struct ipc_perm} mode_t
mode for Hurd.
* sysdeps/unix/sysv/linux/m68k/Versions (libc) [GLIBC_2.31]: Add
msgctl, semctl, and shmctl.
* sysdeps/unix/sysv/linux/arm/be/Versions: New file.
* sysdeps/unix/sysv/linux/microblaze/be/Versions: Likewise.
* sysdeps/unix/sysv/linux/sh/be/Versions: Likewise.
[1] http://pubs.opengroup.org/onlinepubs/
9699919799/basedefs/sys_ipc.h.html
Andreas Schwab [Thu, 10 Oct 2019 08:45:31 +0000 (10:45 +0200)]
Simplify note processing
This removes dead code during note processing.
Dmitry V. Levin [Thu, 10 Oct 2019 00:38:28 +0000 (00:38 +0000)]
syscall-names.list: fix typos in comment
* sysdeps/unix/sysv/linux/syscall-names.list: Fix typos in comment,
reformat the affected paragraph.
Lukasz Majewski [Tue, 24 Sep 2019 12:22:42 +0000 (14:22 +0200)]
y2038: linux: Provide __clock_settime64 implementation
This patch provides new __clock_settime64 explicit 64 bit function for
setting the time. Moreover, a 32 bit version - __clock_settime - has been
refactored to internally use __clock_settime64.
The __clock_settime is now supposed to be used on systems still supporting
32 bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit
struct timespec.
The new clock_settime64 syscall available from Linux 5.1+ has been used,
when applicable.
In this patch the internal padding (tv_pad) of struct __timespec64 is
left untouched (on systems with __WORDSIZE == 32) as Linux kernel ignores
upper 32 bits of tv_nsec.
Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make PARALLELMFLAGS="-j8" && make xcheck PARALLELMFLAGS="-j8"
- The glibc has been build tested (make PARALLELMFLAGS="-j8") for
x86 (i386), x86_64-x32, and armv7
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
- Use of cross-test-ssh.sh for ARM (armv7):
make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck
Linux kernel, headers and minimal kernel version for glibc build test
matrix:
- Linux v5.1 (with clock_settime64) and glibc build with v5.1 as minimal
kernel version (--enable-kernel="5.1.0")
The __ASSUME_TIME64_SYSCALLS flag defined.
- Linux v5.1 and default minimal kernel version
The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports
__clock_settime64 syscalls.
- Linux v4.19 (no clock_settime64 support) with default minimal kernel
version for contemporary glibc
This kernel doesn't support __clock_settime64 syscalls, so the fallback
to clock_settime is tested.
The above tests were performed with Y2038 redirection applied as well as
without (so the __TIMESIZE != 64 execution path is checked as well).
No regressions were observed.
* include/time.h (__clock_settime64):
Add __clock_settime alias according to __TIMESIZE define
* sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime):
Refactor this function to be used only on 32 bit machines as a wrapper
on __clock_settime64.
* sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime64): Add
* sysdeps/unix/sysv/linux/clock_settime.c (__clock_settime64):
Use clock_settime64 kernel syscall (available from 5.1+ Linux)