]> sourceware.org Git - glibc.git/log
glibc.git
2 years agomisc: Fix rare fortify crash on wchar funcs. [BZ 29030]
Joan Bruguera [Mon, 11 Apr 2022 17:49:56 +0000 (19:49 +0200)]
misc: Fix rare fortify crash on wchar funcs. [BZ 29030]

If `__glibc_objsize (__o) == (size_t) -1` (i.e. `__o` is unknown size), fortify
checks should pass, and `__whatever_alias` should be called.

Previously, `__glibc_objsize (__o) == (size_t) -1` was explicitly checked, but
on commit a643f60c53876b, this was moved into `__glibc_safe_or_unknown_len`.

A comment says the -1 case should work as: "The -1 check is redundant because
since it implies that __glibc_safe_len_cond is true.". But this fails when:
* `__s > 1`
* `__osz == -1` (i.e. unknown size at compile time)
* `__l` is big enough
* `__l * __s <= __osz` can be folded to a constant
(I only found this to be true for `mbsrtowcs` and other functions in wchar2.h)

In this case `__l * __s <= __osz` is false, and `__whatever_chk_warn` will be
called by `__glibc_fortify` or `__glibc_fortify_n` and crash the program.

This commit adds the explicit `__osz == -1` check again.
moc crashes on startup due to this, see: https://bugs.archlinux.org/task/74041

Minimal test case (test.c):
    #include <wchar.h>

    int main (void)
    {
        const char *hw = "HelloWorld";
        mbsrtowcs (NULL, &hw, (size_t)-1, NULL);
        return 0;
    }

Build with:
    gcc -O2 -Wp,-D_FORTIFY_SOURCE=2 test.c -o test && ./test

Output:
    *** buffer overflow detected ***: terminated

Fixes: BZ #29030
Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 33e03f9cd2be4f2cd62f93fda539cc07d9c8130e)

2 years agoDefault to --with-default-link=no (bug 25812)
Florian Weimer [Mon, 11 Apr 2022 09:30:31 +0000 (11:30 +0200)]
Default to --with-default-link=no (bug 25812)

This is necessary to place the libio vtables into the RELRO segment.
New tests elf/tst-relro-ldso and elf/tst-relro-libc are added to
verify that this is what actually happens.

The new tests fail on ia64 due to lack of (default) RELRO support
inbutils, so they are XFAILed there.

(cherry picked from commit 198abcbb94618730dae1b3f4393efaa49e0ec8c7)

2 years agoscripts: Add glibcelf.py module
Florian Weimer [Mon, 11 Apr 2022 09:28:08 +0000 (11:28 +0200)]
scripts: Add glibcelf.py module

Hopefully, this will lead to tests that are easier to maintain.  The
current approach of parsing readelf -W output using regular expressions
is not necessarily easier than parsing the ELF data directly.

This module is still somewhat incomplete (e.g., coverage of relocation
types and versioning information is missing), but it is sufficient to
perform basic symbol analysis or program header analysis.

The EM_* mapping for architecture-specific constant classes (e.g.,
SttX86_64) is not yet implemented.  The classes are defined for the
benefit of elf/tst-glibcelf.py.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
(cherry picked from commit 30035d67728a846fa39749cd162afd278ac654c4)

2 years agom68k: Handle fewer relocations for RTLD_BOOTSTRAP (#BZ29071)
Fangrui Song [Wed, 20 Apr 2022 17:24:15 +0000 (10:24 -0700)]
m68k: Handle fewer relocations for RTLD_BOOTSTRAP (#BZ29071)

m68k is a non-PI_STATIC_AND_HIDDEN arch which uses a GOT relocation when
loading the address of a jump table. The GOT load may be reordered
before processing R_68K_RELATIVE relocations, leading to an
unrelocated/incorrect jump table, which will cause a crash.

The foolproof approach is to add an optimization barrier (e.g. calling
an non-inlinable function after relative relocations are resolved). That
is non-trivial given the current code structure, so just use the simple
approach to avoid the jump table: handle only the essential reloctions
for RTLD_BOOTSTRAP code.

This is based on Andreas Schwab's patch and fixed ld.so crash on m68k.

Reviewed-by: Adheemrval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit a8e9b5b8079d18116ca69c9797e77804ecf2ee7e)

2 years agonptl: Fix pthread_cancel cancelhandling atomic operations
Adhemerval Zanella [Wed, 20 Apr 2022 15:01:43 +0000 (12:01 -0300)]
nptl: Fix pthread_cancel cancelhandling atomic operations

The 404656009b reversion did not setup the atomic loop to set the
cancel bits correctly.  The fix is essentially what pthread_cancel
did prior 26cfbb7162ad.

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

(cherry picked from commit 62be9681677e7ce820db721c126909979382d379)

2 years agomips: Fix mips64n32 64 bit time_t stat support (BZ#29069)
=Joshua Kinard [Mon, 18 Apr 2022 12:55:08 +0000 (09:55 -0300)]
mips: Fix mips64n32 64 bit time_t stat support (BZ#29069)

Add missing support initially added by 4e8521333bea6e89fcef1020
(which missed n32 stat).

(cherry picked from commit 78fb88827362fbd2cc8aa32892ae5b015106e25c)

2 years agohurd: Fix arbitrary error code
Samuel Thibault [Tue, 12 Apr 2022 20:14:34 +0000 (22:14 +0200)]
hurd: Fix arbitrary error code

ELIBBAD is Linux-specific.

(cherry picked from commit 67ab66541dc1164540abda284645e38be90b5119)

2 years agonptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)
Adhemerval Zanella [Wed, 6 Apr 2022 15:24:42 +0000 (12:24 -0300)]
nptl: Handle spurious EINTR when thread cancellation is disabled (BZ#29029)

Some Linux interfaces never restart after being interrupted by a signal
handler, regardless of the use of SA_RESTART [1].  It means that for
pthread cancellation, if the target thread disables cancellation with
pthread_setcancelstate and calls such interfaces (like poll or select),
it should not see spurious EINTR failures due the internal SIGCANCEL.

However recent changes made pthread_cancel to always sent the internal
signal, regardless of the target thread cancellation status or type.
To fix it, the previous semantic is restored, where the cancel signal
is only sent if the target thread has cancelation enabled in
asynchronous mode.

The cancel state and cancel type is moved back to cancelhandling
and atomic operation are used to synchronize between threads.  The
patch essentially revert the following commits:

  8c1c0aae20 nptl: Move cancel type out of cancelhandling
  2b51742531 nptl: Move cancel state out of cancelhandling
  26cfbb7162 nptl: Remove CANCELING_BITMASK

However I changed the atomic operation to follow the internal C11
semantic and removed the MACRO usage, it simplifies a bit the
resulting code (and removes another usage of the old atomic macros).

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
and powerpc64-linux-gnu.

[1] https://man7.org/linux/man-pages/man7/signal.7.html

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry-picked from commit 404656009b459658138ed1bd18f3c6cf3863e6a6)

2 years agoS390: Add new s390 platform z16.
Stefan Liebler [Wed, 13 Apr 2022 12:36:09 +0000 (14:36 +0200)]
S390: Add new s390 platform z16.

The new IBM z16 is added to platform string array.
The macro _DL_PLATFORMS_COUNT is incremented.

_dl_hwcaps_subdir is extended by "z16" if HWCAP_S390_VXRS_PDE2
is set. HWCAP_S390_NNPA is not tested in _dl_hwcaps_subdirs_active
as those instructions may be replaced or removed in future.

tst-glibc-hwcaps.c is extended in order to test z16 via new marker5.

A fatal glibc error is dumped if glibc was build with architecture
level set for z16, but run on an older machine. (See dl-hwcap-check.h)

(cherry picked from commit 2376944b9e5c0364b9fb473e4d8dabca31b57167)

2 years agoelf: Fix memory leak in _dl_find_object_update (bug 29062)
Florian Weimer [Wed, 13 Apr 2022 12:18:28 +0000 (14:18 +0200)]
elf: Fix memory leak in _dl_find_object_update (bug 29062)

The count can be zero if an object has already been loaded as
an indirect dependency (so that l_searchlist.r_list in its link
map is still NULL) is promoted to global scope via RTLD_GLOBAL.

Fixes commit 5d28a8962dc ("elf: Add _dl_find_object function").

(cherry picked from commit 4a41fc3cd9cea9223ea4f13f9c766a1e149a0ccc)

2 years agoNEWS: Move PLT tracking slowdown to glibc 2.35.
Carlos O'Donell [Tue, 12 Apr 2022 17:26:10 +0000 (13:26 -0400)]
NEWS: Move PLT tracking slowdown to glibc 2.35.

In commit 063f9ba220f434c7f30dd65c4cff17c0c458a7cf the NEWS section
was accidentally added to the glibc 2.34 NEWS section. The NEWS entry
should have been added to glibc 2.35 which contained the committed
fix. This moves the NEWS entry to correct section.

(cherry picked from commit 2fe48f52833cf698374a9e607e447edec892e5c9)

2 years agohppa: Use END instead of PSEUDO_END in swapcontext.S
John David Anglin [Tue, 15 Mar 2022 23:04:39 +0000 (23:04 +0000)]
hppa: Use END instead of PSEUDO_END in swapcontext.S

(cherry picked from commit 7a5c440102d4ec7fafd9bbd98eca9bd90ecaaafd)

2 years agohppa: Implement swapcontext in assembler (bug 28960)
John David Anglin [Tue, 15 Mar 2022 15:12:03 +0000 (15:12 +0000)]
hppa: Implement swapcontext in assembler (bug 28960)

When swapcontext.c is compiled without -g, the following error occurs:
Error: CFI instruction used without previous .cfi_startproc

Fix by converting swapcontext routine to assembler.

(cherry picked from commit d05e6dc8d1032e1732542a48e0fb895432008b6e)

2 years agonss: Protect against errno changes in function lookup (bug 28953)
Florian Weimer [Fri, 11 Mar 2022 07:23:56 +0000 (08:23 +0100)]
nss: Protect against errno changes in function lookup (bug 28953)

dlopen may clobber errno.  The nss_test_errno module uses an ELF
constructor to achieve that, but there could be internal errors
during dlopen that cause this, too.  Therefore, the NSS framework
has to guard against such errno clobbers.

__nss_module_get_function is currently the only function that calls
__nss_module_load, so it is sufficient to save and restore errno
around this call.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 9bdf92c79d63b42f931101bb6df87129c408b0c4)

2 years agonss: Do not mention NSS test modules in <gnu/lib-names.h>
Florian Weimer [Fri, 11 Mar 2022 07:23:56 +0000 (08:23 +0100)]
nss: Do not mention NSS test modules in <gnu/lib-names.h>

They are not actually installed.  Use the nss_files version instead
in nss/Makefile, similar to how __nss_shlib_revision is derived
from LIBNSS_FILES_SO.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit aefc79ab5ad4bb9feea2876720cec70dca7cd8ed)

2 years agoio: Add fsync call in tst-stat
Florian Weimer [Mon, 28 Feb 2022 10:50:41 +0000 (11:50 +0100)]
io: Add fsync call in tst-stat

io/tst-stat and io/tst-stat-lfs fail sporadically on the Fedora
builders, and this change hopefully helps to avoid the issue.

(cherry picked from commit ae132284092edc5885315b44cd17d5ea91177e49)

2 years agonptl: Fix cleanups for stack grows up [BZ# 28899]
John David Anglin [Mon, 28 Feb 2022 15:47:38 +0000 (15:47 +0000)]
nptl: Fix cleanups for stack grows up [BZ# 28899]

_STACK_GROWS_DOWN is defined to 0 when the stack grows up.  The
code in unwind.c used `#ifdef _STACK_GROWS_DOWN' to selct the
stack grows down define for FRAME_LEFT.  As a result, the
_STACK_GROWS_DOWN define was always selected and cleanups were
incorrectly sequenced when the stack grows up.

(cherry picked from commit 2bbc694df279020a6620096d31c1e05c93966f9b)

2 years agohppa: Fix warnings from _dl_lookup_address
John David Anglin [Tue, 22 Feb 2022 18:51:35 +0000 (18:51 +0000)]
hppa: Fix warnings from _dl_lookup_address

This change fixes two warnings from _dl_lookup_address.

The first warning comes from dropping the volatile keyword from
desc in the call to _dl_read_access_allowed.  We now have a full
atomic barrier between loading desc[0] and the access check, so
desc no longer needs to be declared as volatile.

The second warning comes from the implicit declaration of
_dl_fix_reloc_arg.  This is fixed by including dl-runtime.h and
declaring _dl_fix_reloc_arg in dl-runtime.h.

(cherry picked from commit d2224ffbddc9d25ed5b0e34c212018c32d1e5a95)

2 years agohppa: Revise gettext trampoline design
John David Anglin [Tue, 22 Feb 2022 17:28:46 +0000 (17:28 +0000)]
hppa: Revise gettext trampoline design

The current getcontext return trampoline is overly complex and it
unnecessarily clobbers several registers.  By saving the context
pointer (r26) in the context, __getcontext_ret can restore any
registers not restored by setcontext.  This allows getcontext to
save and restore the entire register context present when getcontext
is entered.  We use the unused oR0 context slot for the return
from __getcontext_ret.

While this is not directly useful in C, it can be exploited in
assembly code.  Registers r20, r23, r24 and r25 are not clobbered
in the call path to getcontext.  This allows a small simplification
of swapcontext.

It also allows saving and restoring the 6-bit SAR register in the
LSB of the oSAR context slot.  The getcontext flag value can be
stored in the MSB of the oSAR slot.

(cherry picked from commit 9e7e5fda38471e00d1190479ea91d7b08ae3e304)

2 years agohppa: Fix swapcontext
John David Anglin [Fri, 18 Feb 2022 20:38:25 +0000 (20:38 +0000)]
hppa: Fix swapcontext

This change fixes the failure of stdlib/tst-setcontext2 and
stdlib/tst-setcontext7 on hppa.  The implementation of swapcontext
in C is broken.  C saves the return pointer (rp) and any non
call-clobbered registers (in this case r3, r4 and r5) on the
stack.  However, the setcontext call in swapcontext pops the
stack and subsequent calls clobber the saved registers.  When
the context in oucp is restored, both tests fault.

Here we rewrite swapcontext in assembly code to avoid using
the stack for register values that need to be used after
restoration.  The getcontext and setcontext routines are
revised to save and restore register ret1 for normal returns.
We copy the oucp pointer to ret1.  This allows access to
the old context after calling getcontext and setcontext.

(cherry picked from commit 71b108d7eb33b2bf3e61d5e92d2a47f74c1f7d96)

2 years agoFix elf/tst-audit2 on hppa
John David Anglin [Mon, 14 Feb 2022 15:14:49 +0000 (15:14 +0000)]
Fix elf/tst-audit2 on hppa

The test elf/tst-audit2 fails on hppa with a segmentation fault in the
long branch stub used to call malloc from calloc.  This occurs because
the test is not a PIC executable and calloc is called from the dynamic
linker before the dp register is initialized in _dl_start_user.

The fix is to move the dp register initialization into
elf_machine_runtime_setup.  Since the address of $global$ can't be
loaded directly, we continue to use the DT_PLTGOT value from the
the main_map to initialize dp.

(cherry picked from commit 2e20cd63c96555d650c525ad5633475e8f11bed4)

2 years agohppa: Fix bind-now audit (BZ #28857)
Adhemerval Zanella [Fri, 4 Feb 2022 18:54:59 +0000 (15:54 -0300)]
hppa: Fix bind-now audit (BZ #28857)

On hppa, a function pointer returned by la_symbind is actually a function
descriptor has the plabel bit set (bit 30).  This must be cleared to get
the actual address of the descriptor.  If the descriptor has been bound,
the first word of the descriptor is the physical address of theA function,
otherwise, the first word of the descriptor points to a trampoline in the
PLT.

This patch also adds a workaround on tests because on hppa (and it seems
to be the only ABI I have see it), some shared library adds a dynamic PLT
relocation to am empty symbol name:

$ readelf -r elf/tst-audit25mod1.so
[...]
Relocation section '.rela.plt' at offset 0x464 contains 6 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00002008  00000081 R_PARISC_IPLT                508
[...]

It breaks some assumptions on the test, where a symbol with an empty
name ("") is passed on la_symbind.

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

(Cherry-pick picked from 9e94f57484a2aba0fe67ea2059b5843f651887c2)

2 years agolocaledef: Handle symbolic links when generating locale-archive
Arjun Shankar [Thu, 24 Feb 2022 20:43:09 +0000 (21:43 +0100)]
localedef: Handle symbolic links when generating locale-archive

Whenever locale data for any locale included symbolic links, localedef
would throw the error "incomplete set of locale files" and exclude it
from the generated locale archive.  This commit fixes that.

Co-authored-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit ea89d5bbd9e5e514b606045d909e6ab87d851c88)

2 years agolocaledata: Do not generate output if warnings were present.
Carlos O'Donell [Thu, 3 Feb 2022 21:01:52 +0000 (16:01 -0500)]
localedata: Do not generate output if warnings were present.

With LC_MONETARY parsing fixed we can now generate locales
without forcing output with '-c'.

Removing '-c' from localedef invocation is the equivalent of
using -Werror for localedef.  The glibc locale sources should
always be clean and free from warnings.

We remove '-c' from both test locale generation and the targets
used for installing locales e.g. install-locale-archive, and
install-locale-files.

Tested on x86_64 and i686 without regressions.
Tested with install-locale-archive target.
Tested with install-locale-files target.

Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 1c7a34567d21fbd3b706c77cd794956b43daefe7)

2 years agolocaledef: Update LC_MONETARY handling (Bug 28845)
Carlos O'Donell [Thu, 3 Feb 2022 21:51:59 +0000 (16:51 -0500)]
localedef: Update LC_MONETARY handling (Bug 28845)

ISO C17, POSIX Issue 7, and ISO 30112 all allow the char*
types to be empty strings i.e. "", integer or char values to
be -1 or CHAR_MAX respectively, with the exception of
decimal_point which must be non-empty in ISO C. Note that
the defaults for mon_grouping vary, but are functionaly
equivalent e.g. "\177" (no further grouping reuqired) vs.
"" (no grouping defined for all groups).

We include a broad comment talking about harmonizing ISO C,
POSIX, ISO 30112, and the default C/POSIX locale for glibc.

We reorder all setting based on locale/categories.def order.

We soften all missing definitions from errors to warnings when
defaults exist.

Given that ISO C, POSIX and ISO 30112 allow the empty string
we change LC_MONETARY handling of mon_decimal_point to allow
the empty string.  If mon_decimal_point is not defined at all
then we pick the existing legacy glibc default value of
<U002E> i.e. ".".

We also set the default for mon_thousands_sep_wc at the
same time as mon_thousands_sep, but this is not a change in
behaviour, it is always either a matching value or L'\0',
but if in the future we change the default to a non-empty
string we would need to update both at the same time.

Tested on x86_64 and i686 without regressions.
Tested with install-locale-archive target.
Tested with install-locale-files target.

Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 2ab8b74567dc0a9a3c98696e6444881997dd6c49)

2 years agoNEWS: Add a bug fix entry for BZ #28688
H.J. Lu [Thu, 24 Feb 2022 15:58:36 +0000 (07:58 -0800)]
NEWS: Add a bug fix entry for BZ #28688

2 years agoresolv: Fix tst-resolv tests for 2.35 ABIs and later
Stafford Horne [Fri, 11 Feb 2022 23:17:55 +0000 (08:17 +0900)]
resolv: Fix tst-resolv tests for 2.35 ABIs and later

The commit 737e873b30 ("resolv: Do not build libanl.so for ABIs starting
at 2.35") disabled building libanl for ports supporting only 2.35 and
later like OpenRISC.

However, the if statement was not updated quite correctly and the change
ends up disabling many tst-resolv* tests.  This was not supposed to be
done and it causes test dependency errors like:

     make: Entering directory 'gnu-home/glibc/resolv'
     make: *** No rule to make target 'gnu-home/build-glibc/resolv/tst-resolv-res_ninit.out', needed by 'gnu-home/build-glibc/resolv/mtrace-tst-resolv-res_ninit.out'. Stop.
     make: Leaving directory 'gnu-home/glibc/resolv'

This patch move the extra-libs += libanl definition and condition down
to be closer to other libanl definitions.  The $(have-GLIBC_2.34)
condition now includes libanl-routines and libanl-shared-only-routines as
well.

Also, I have added a comment to endif of $(have-thread-library) to help
show the bondary of the have-thread-library definitions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit ee5d27bea53626c0187f77feec2c883f2c6ac4b3)

2 years agoelf: Replace tst-audit24bmod2.so with tst-audit24bmod2
H.J. Lu [Sun, 6 Feb 2022 19:12:24 +0000 (11:12 -0800)]
elf: Replace tst-audit24bmod2.so with tst-audit24bmod2

Replace tst-audit24bmod2.so with tst-audit24bmod2 to silence:

make[2]: Entering directory '/export/gnu/import/git/gitlab/x86-glibc/elf'
Makefile:2201: warning: overriding recipe for target '/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/elf/tst-audit24bmod2.so'
../Makerules:765: warning: ignoring old recipe for target '/export/build/gnu/tools-build/glibc-gitlab/build-x86_64-linux/elf/tst-audit24bmod2.so'

(cherry picked from commit fa7ad1df1915c8a62f50e3a5b7e10f9c7118cd7f)

2 years agoelf: Check invalid hole in PT_LOAD segments [BZ #28838]
H.J. Lu [Tue, 15 Feb 2022 14:57:11 +0000 (06:57 -0800)]
elf: Check invalid hole in PT_LOAD segments [BZ #28838]

Changes in v2:

1. Update commit log.

commit 163f625cf9becbb82dfec63a29e566324129c0cd
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 21 12:35:47 2021 -0800

    elf: Remove excessive p_align check on PT_LOAD segments [BZ #28688]

removed the p_align check against the page size.  It caused the loader
error or crash on elf/tst-p_align3 when loading elf/tst-p_alignmod3.so,
which has the invalid p_align in PT_LOAD segments, added by

commit d8d94863ef125a392b929732b37e07dc927fbcd1
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 21 13:42:28 2021 -0800

The loader failure caused by a negative length passed to __mprotect is
random, depending on architecture and toolchain.  Update _dl_map_segments
to detect invalid holes.  This fixes BZ #28838.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
(cherry picked from commit 2c0915cbf570cb9c8a65f1d20a55c5a7238e5b63)

2 years agoNEWS: Add a bug fix entry for BZ #28896
H.J. Lu [Sat, 19 Feb 2022 03:07:11 +0000 (19:07 -0800)]
NEWS: Add a bug fix entry for BZ #28896

2 years agox86: Fix TEST_NAME to make it a string in tst-strncmp-rtm.c
Noah Goldstein [Fri, 18 Feb 2022 23:00:25 +0000 (17:00 -0600)]
x86: Fix TEST_NAME to make it a string in tst-strncmp-rtm.c

Previously TEST_NAME was passing a function pointer. This didn't fail
because of the -Wno-error flag (to allow for overflow sizes passed
to strncmp/wcsncmp)

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit b98d0bbf747f39770e0caba7e984ce9f8f900330)

2 years agox86: Test wcscmp RTM in the wcsncmp overflow case [BZ #28896]
Noah Goldstein [Fri, 18 Feb 2022 20:19:15 +0000 (14:19 -0600)]
x86: Test wcscmp RTM in the wcsncmp overflow case [BZ #28896]

In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
call strcmp-avx2 and wcscmp-avx2 respectively. This would have
not checks around vzeroupper and would trigger spurious
aborts. This commit fixes that.

test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass on
AVX2 machines with and without RTM.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit 7835d611af0854e69a0c71e3806f8fe379282d6f)

2 years agox86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896]
Noah Goldstein [Tue, 15 Feb 2022 14:18:15 +0000 (08:18 -0600)]
x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896]

In the overflow fallback strncmp-avx2-rtm and wcsncmp-avx2-rtm would
call strcmp-avx2 and wcscmp-avx2 respectively. This would have
not checks around vzeroupper and would trigger spurious
aborts. This commit fixes that.

test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass on
AVX2 machines with and without RTM.

Co-authored-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit c6272098323153db373f2986c67786ea8c85f1cf)

2 years agostring: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]
H.J. Lu [Thu, 17 Feb 2022 16:10:35 +0000 (08:10 -0800)]
string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755]

Verify that wcsncmp (L("abc"), L("abd"), SIZE_MAX) == 0.  The new test
fails without

commit ddf0992cf57a93200e0c782e2a94d0733a5a0b87
Author: Noah Goldstein <goldstein.w.n@gmail.com>
Date:   Sun Jan 9 16:02:21 2022 -0600

    x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755]

and

commit 7e08db3359c86c94918feb33a1182cd0ff3bb10b
Author: Noah Goldstein <goldstein.w.n@gmail.com>
Date:   Sun Jan 9 16:02:28 2022 -0600

    x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755]

This is for BZ #28755.

Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
(cherry picked from commit aa5a720056d37cf24924c138a3dbe6dace98e97c)

2 years agolinux: Use socket-constants-time64.h on tst-socket-timestamp-compat
Adhemerval Zanella [Mon, 14 Feb 2022 13:35:30 +0000 (10:35 -0300)]
linux: Use socket-constants-time64.h on tst-socket-timestamp-compat

The kernel header might not define the SO_TIMESTAMP{NS}_OLD or
SO_TIMESTAMP{NS}_NEW if it older than v5.1.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
(cherry picked from commit fee62d6c6285548027e222c8dae597fec6577f23)

2 years agolinux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865]
Dmitry V. Levin [Sat, 5 Feb 2022 08:00:00 +0000 (08:00 +0000)]
linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865]

get_nprocs() and get_nprocs_conf() use various methods to obtain an
accurate number of processors.  Re-introduce __get_nprocs_sched() as
a source of information, and fix the order in which these methods are
used to return the most accurate information.  The primary source of
information used in both functions remains unchanged.

This also changes __get_nprocs_sched() error return value from 2 to 0,
but all its users are already prepared to handle that.

Old fallback order:
  get_nprocs:
    /sys/devices/system/cpu/online -> /proc/stat -> 2
  get_nprocs_conf:
    /sys/devices/system/cpu/ -> /proc/stat -> 2

New fallback order:
  get_nprocs:
    /sys/devices/system/cpu/online -> /proc/stat -> sched_getaffinity -> 2
  get_nprocs_conf:
    /sys/devices/system/cpu/ -> /proc/stat -> sched_getaffinity -> 2

Fixes: 342298278e ("linux: Revert the use of sched_getaffinity on get_nproc")
Closes: BZ #28865
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit e1d32b836410767270a3adf1f82b1a47e6e4cd51)

2 years agoAdd BZ#28860 reference on NEWS
Adhemerval Zanella [Thu, 3 Feb 2022 20:50:13 +0000 (17:50 -0300)]
Add BZ#28860 reference on NEWS

2 years agolinux: Fix missing __convert_scm_timestamps (BZ #28860)
Adhemerval Zanella [Thu, 3 Feb 2022 19:52:52 +0000 (16:52 -0300)]
linux: Fix missing __convert_scm_timestamps (BZ #28860)

Commit 948ce73b31 made recvmsg/recvmmsg to always call
__convert_scm_timestamps for 64 bit time_t symbol, so adjust it to
always build it for __TIMESIZE != 64.

It fixes build for architecture with 32 bit time_t support when
configured with minimum kernel of 5.1.

(cherry picked from 798d716df71fb23dc89d1d5dba1fc26a1b5c0024)

2 years agolinux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage [BZ #28850]
Gleb Fotengauer-Malinovskiy [Tue, 1 Feb 2022 22:39:02 +0000 (22:39 +0000)]
linux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage [BZ #28850]

Pass the actual number of bytes returned by the kernel.

Fixes: 33099d72e41c ("linux: Simplify get_nprocs")
Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
(cherry picked from commit 97ba273b505763325efd802dc3a9562dbba79579)

2 years agoposix: Fix tst-spawn6 terminal handling (BZ #28853)
Adhemerval Zanella [Wed, 2 Feb 2022 21:31:59 +0000 (18:31 -0300)]
posix: Fix tst-spawn6 terminal handling (BZ #28853)

The test changes the current foreground process group, which might
break testing depending of how the make check is issued.  For instance:

  nohup make -j1 test t=posix/tst-spawn6 | less

Will set 'make' and 'less' to be in the foreground process group in
the current session.  When tst-spawn6 new child takes over it becomes
the foreground process and 'less' is stopped and backgrounded which
interrupts the 'make check' command.

To fix it a pseudo-terminal is allocated, the test starts in new
session (so there is no controlling terminal associated), and the
pseudo-terminal is set as the controlling one (similar to what
login_tty does).

Checked on x86_64-linux-gnu.

Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from a9d35765728cbc5b66af5eeda5428298bccf9b69)

2 years agoRegenerate configure
Andreas Schwab [Thu, 3 Feb 2022 08:37:42 +0000 (09:37 +0100)]
Regenerate configure

2 years agoCreate ChangeLog.old/ChangeLog.24. glibc-2.35
Carlos O'Donell [Thu, 3 Feb 2022 05:27:54 +0000 (00:27 -0500)]
Create ChangeLog.old/ChangeLog.24.

2 years agoPrepare for glibc 2.35 release.
Carlos O'Donell [Thu, 3 Feb 2022 05:23:26 +0000 (00:23 -0500)]
Prepare for glibc 2.35 release.

Update version.h, and include/features.h.

2 years agoRegenerate configure.
Carlos O'Donell [Thu, 3 Feb 2022 05:10:03 +0000 (00:10 -0500)]
Regenerate configure.

2 years agoUpdate install.texi, and regenerate INSTALL.
Carlos O'Donell [Thu, 3 Feb 2022 05:06:38 +0000 (00:06 -0500)]
Update install.texi, and regenerate INSTALL.

2 years agoUpdate NEWS bug list.
Carlos O'Donell [Thu, 3 Feb 2022 04:55:20 +0000 (23:55 -0500)]
Update NEWS bug list.

2 years agoUpdate NEWS.
Carlos O'Donell [Thu, 3 Feb 2022 04:46:19 +0000 (23:46 -0500)]
Update NEWS.

Moved LD_AUDIT notes into requirements section since the LAV_CURRENT
bump is a requirements change that impacts loading old audit modules
or new audit modules on older loaders.

2 years agoUpdate translations.
Carlos O'Donell [Thu, 3 Feb 2022 04:30:15 +0000 (23:30 -0500)]
Update translations.

2 years agoLinux: Use ptrdiff_t for __rseq_offset
Florian Weimer [Wed, 2 Feb 2022 21:37:20 +0000 (22:37 +0100)]
Linux: Use ptrdiff_t for __rseq_offset

This matches the data size initial-exec relocations use on most
targets.

Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoFix elf/tst-audit25a with default bind now toolchains
Szabolcs Nagy [Wed, 2 Feb 2022 14:03:58 +0000 (14:03 +0000)]
Fix elf/tst-audit25a with default bind now toolchains

This test relies on lazy binding for the executable so request that
explicitly in case the toolchain defaults to bind now.

2 years agoposix: Replace posix_spawnattr_tc{get,set}pgrp_np with posix_spawn_file_actions_addtc...
Adhemerval Zanella [Thu, 27 Jan 2022 13:11:30 +0000 (10:11 -0300)]
posix: Replace posix_spawnattr_tc{get,set}pgrp_np with posix_spawn_file_actions_addtcsetpgrp_np

The posix_spawnattr_tcsetpgrp_np works on a file descriptor (the
controlling terminal), so it would make more sense to actually fit
it on the file actions API.

Also, POSIX_SPAWN_TCSETPGROUP is not really required since it is
implicit by the presence of tcsetpgrp file action.

The posix/tst-spawn6.c is also fixed when TTY can is not present.

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

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 years agoor1k: Define PI_STATIC_AND_HIDDEN
Stafford Horne [Fri, 28 Jan 2022 23:20:40 +0000 (08:20 +0900)]
or1k: Define PI_STATIC_AND_HIDDEN

PI_STATIC_AND_HIDDEN means that references to static functions, data
and symbols with hidden visibility do not need any run-time relocations
after the final link, with the build flags used by glibc.

OpenRISC follows this so enabled PI_STATIC_AND_HIDDEN by adding
configure.ac and generating configure.

Suggested-by: Florian Weimer <fweimer@redhat.com>
2 years agoSET_RELHOOK: merge i386 and x86_64, and move to sysdeps/mach/hurd/x86
Samuel Thibault [Tue, 1 Feb 2022 18:32:19 +0000 (18:32 +0000)]
SET_RELHOOK: merge i386 and x86_64, and move to sysdeps/mach/hurd/x86

It is not Hurd-specific, but H.J. Lu wants it there.

Also, dc.a can be used to avoid hardcoding .long vs .quad and thus use
the same implementation for i386 and x86_64.

2 years agoelf: Fix runtime linker auditing on aarch64 (BZ #26643)
Ben Woodard [Mon, 24 Jan 2022 13:46:18 +0000 (10:46 -0300)]
elf: Fix runtime linker auditing on aarch64 (BZ #26643)

The rtld audit support show two problems on aarch64:

  1. _dl_runtime_resolve does not preserve x8, the indirect result
      location register, which might generate wrong result calls
      depending of the function signature.

  2. The NEON Q registers pushed onto the stack by _dl_runtime_resolve
     were twice the size of D registers extracted from the stack frame by
     _dl_runtime_profile.

While 2. might result in wrong information passed on the PLT tracing,
1. generates wrong runtime behaviour.

The aarch64 rtld audit support is changed to:

  * Both La_aarch64_regs and La_aarch64_retval are expanded to include
    both x8 and the full sized NEON V registers, as defined by the
    ABI.

  * dl_runtime_profile needed to extract registers saved by
    _dl_runtime_resolve and put them into the new correctly sized
    La_aarch64_regs structure.

  * The LAV_CURRENT check is change to only accept new audit modules
    to avoid the undefined behavior of not save/restore x8.

  * Different than other architectures, audit modules older than
    LAV_CURRENT are rejected (both La_aarch64_regs and La_aarch64_retval
    changed their layout and there are no requirements to support multiple
    audit interface with the inherent aarch64 issues).

  * A new field is also reserved on both La_aarch64_regs and
    La_aarch64_retval to support variant pcs symbols.

Similar to x86, a new La_aarch64_vector type to represent the NEON
register is added on the La_aarch64_regs (so each type can be accessed
directly).

Since LAV_CURRENT was already bumped to support bind-now, there is
no need to increase it again.

Checked on aarch64-linux-gnu.

Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 years agoelf: Issue la_symbind for bind-now (BZ #23734)
Adhemerval Zanella [Mon, 24 Jan 2022 13:46:17 +0000 (10:46 -0300)]
elf: Issue la_symbind for bind-now (BZ #23734)

The audit symbind callback is not called for binaries built with
-Wl,-z,now or when LD_BIND_NOW=1 is used, nor the PLT tracking callbacks
(plt_enter and plt_exit) since this would change the expected
program semantics (where no PLT is expected) and would have performance
implications (such as for BZ#15533).

LAV_CURRENT is also bumped to indicate the audit ABI change (where
la_symbind flags are set by the loader to indicate no possible PLT
trace).

To handle powerpc64 ELFv1 function descriptor, _dl_audit_symbind
requires to know whether bind-now is used so the symbol value is
updated to function text segment instead of the OPD (for lazy binding
this is done by PPC64_LOAD_FUNCPTR on _dl_runtime_resolve).

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
powerpc64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 years agoelf: Fix initial-exec TLS access on audit modules (BZ #28096)
Adhemerval Zanella [Mon, 24 Jan 2022 13:46:16 +0000 (10:46 -0300)]
elf: Fix initial-exec TLS access on audit modules (BZ #28096)

For audit modules and dependencies with initial-exec TLS, we can not
set the initial TLS image on default loader initialization because it
would already be set by the audit setup.  However, subsequent thread
creation would need to follow the default behaviour.

This patch fixes it by setting l_auditing link_map field not only
for the audit modules, but also for all its dependencies.  This is
used on _dl_allocate_tls_init to avoid the static TLS initialization
at load time.

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

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 years agoelf: Add la_activity during application exit
Adhemerval Zanella [Mon, 24 Jan 2022 13:46:15 +0000 (10:46 -0300)]
elf: Add la_activity during application exit

la_activity is not called during application exit, even though
la_objclose is.

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

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 years agolocaledata: Adjust C.UTF-8 to align with C/POSIX.
Carlos O'Donell [Mon, 31 Jan 2022 05:34:42 +0000 (00:34 -0500)]
localedata: Adjust C.UTF-8 to align with C/POSIX.

We have had one downstream report from Canonical [1] that
an rrdtool test was broken by the differences in LC_TIME
that we had in the non-builtin C locale (C.UTF-8). If one
application has an issue there are going to be others, and
so with this commit we review and fix all the issues that
cause the builtin C locale to be different from C.UTF-8,
which includes:
* mon_decimal_point should be empty e.g. ""
 - Depends on mon_decimal_point_wc fix.
* negative_sign should be empty e.g. ""
* week should be aligned with the builtin C/POSIX locale
* d_fmt corrected with escaped slashes e.g. "%m//%d//%y"
* yesstr and nostr should be empty e.g. ""
* country_ab2 and country_ab3 should be empty e.g. ""

We bump LC_IDENTIFICATION version and adjust the date to
indicate the change in the locale.

A new tst-c-utf8-consistency test is added to ensure
consistency between C/POSIX and C.UTF-8.

Tested on x86_64 and i686 without regression.

[1] https://sourceware.org/pipermail/libc-alpha/2022-January/135703.html

Co-authored-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 years agolocaledef: Fix handling of empty mon_decimal_point (Bug 28847)
Carlos O'Donell [Mon, 31 Jan 2022 05:34:41 +0000 (00:34 -0500)]
localedef: Fix handling of empty mon_decimal_point (Bug 28847)

The handling of mon_decimal_point is incorrect when it comes to
handling the empty "" value.  The existing parser in monetary_read()
will correctly handle setting the non-wide-character value and the
wide-character value e.g. STR_ELEM_WC(mon_decimal_point) if they are
set in the locale definition.  However, in monetary_finish() we have
conflicting TEST_ELEM() which sets a default value (if the locale
definition doesn't include one), and subsequent code which looks for
mon_decimal_point to be NULL to issue a specific error message and set
the defaults. The latter is unused because TEST_ELEM() always sets a
default.  The simplest solution is to remove the TEST_ELEM() check,
and allow the existing check to look to see if mon_decimal_point is
NULL and set an appropriate default.  The final fix is to move the
setting of mon_decimal_point_wc so it occurs only when
mon_decimal_point is being set to a default, keeping both values
consistent. There is no way to tell the difference between
mon_decimal_point_wc having been set to the empty string and not
having been defined at all, for that distinction we must use
mon_decimal_point being NULL or "", and so we must logically set
the default together with mon_decimal_point.

Lastly, there are more fixes similar to this that could be made to
ld-monetary.c, but we avoid that in order to fix just the code
required for mon_decimal_point, which impacts the ability for C.UTF-8
to set mon_decimal_point to "", since without this fix we end up with
an inconsistent setting of mon_decimal_point set to "", but
mon_decimal_point_wc set to "." which is incorrect.

Tested on x86_64 and i686 without regression.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 years agomalloc: Fix tst-mallocalign1 macro spacing.
Carlos O'Donell [Tue, 1 Feb 2022 16:03:32 +0000 (11:03 -0500)]
malloc: Fix tst-mallocalign1 macro spacing.

Reported by Andreas Schwab <schwab@linux-m68k.org>

2 years agoelf: Add <dl-r_debug.h>
H.J. Lu [Sat, 29 Jan 2022 18:56:45 +0000 (10:56 -0800)]
elf: Add <dl-r_debug.h>

Add <dl-r_debug.h> to get the adddress of the r_debug structure after
relocation and its offset before relocation from the PT_DYNAMIC segment
to support DT_DEBUG, DT_MIPS_RLD_MAP_REL and DT_MIPS_RLD_MAP.

Co-developed-by: Xi Ruoyao <xry111@mengyan1223.wang>
2 years agoMention _FORTIFY_SOURCE=3 for gcc12 in NEWS
Siddhesh Poyarekar [Thu, 27 Jan 2022 09:03:49 +0000 (14:33 +0530)]
Mention _FORTIFY_SOURCE=3 for gcc12 in NEWS

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agomalloc: Fix -Wuse-after-free warning in tst-mallocalign1 [BZ #26779]
Carlos O'Donell [Fri, 28 Jan 2022 20:14:29 +0000 (15:14 -0500)]
malloc: Fix -Wuse-after-free warning in tst-mallocalign1 [BZ #26779]

The test leaks bits from the freed pointer via the return value
in ret, and the compiler correctly identifies this issue.
We switch the test to use TEST_VERIFY and terminate the test
if any of the pointers return an unexpected alignment.

This fixes another -Wuse-after-free error when compiling glibc
with gcc 12.

Tested on x86_64 and i686 without regression.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agoUpdate libc.pot for 2.35 release.
Carlos O'Donell [Sun, 30 Jan 2022 14:46:55 +0000 (09:46 -0500)]
Update libc.pot for 2.35 release.

2 years agotst-socket-timestamp-compat.c: Check __TIMESIZE [BZ #28837]
H.J. Lu [Sat, 29 Jan 2022 13:22:31 +0000 (05:22 -0800)]
tst-socket-timestamp-compat.c: Check __TIMESIZE [BZ #28837]

time_t size is defined by __TIMESIZE, not __WORDSIZE.  Check __TIMESIZE,
instead of __WORDSIZE, for time_t size.  This fixes BZ #28837.

2 years agoAdd prelink removal plan on NEWS
Adhemerval Zanella [Mon, 24 Jan 2022 18:57:55 +0000 (15:57 -0300)]
Add prelink removal plan on NEWS

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoLinux: Only generate 64 bit timestamps for 64 bit time_t recvmsg/recvmmsg
Adhemerval Zanella [Thu, 27 Jan 2022 19:45:18 +0000 (16:45 -0300)]
Linux: Only generate 64 bit timestamps for 64 bit time_t recvmsg/recvmmsg

The timestamps created by __convert_scm_timestamps only make sense for
64 bit time_t programs, 32 bit time_t programs will ignore 64 bit time_t
timestamps since SO_TIMESTAMP will be defined to old values (either by
glibc or kernel headers).

Worse, if the buffer is not suffice MSG_CTRUNC is set to indicate it
(which breaks some programs [1]).

This patch makes only 64 bit time_t recvmsg and recvmmsg to call
__convert_scm_timestamps.  Also, the assumption to called it is changed
from __ASSUME_TIME64_SYSCALLS to __TIMESIZE != 64 since the setsockopt
might be called by libraries built without __TIME_BITS=64.  The
MSG_CTRUNC is only set for the 64 bit symbols, it should happen only
if 64 bit time_t programs run older kernels.

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

[1] https://github.com/systemd/systemd/pull/20567

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 years agolinux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ#28350)
Adhemerval Zanella [Mon, 24 Jan 2022 11:55:53 +0000 (08:55 -0300)]
linux: Fix ancillary 64-bit time timestamp conversion (BZ #28349, BZ#28350)

The __convert_scm_timestamps only updates the control message last
pointer for SOL_SOCKET type, so if the message control buffer contains
multiple ancillary message types the converted timestamp one might
overwrite a valid message.

The test checks if the extra ancillary space is correctly handled
by recvmsg/recvmmsg, where if there is no extra space for the 64-bit
time_t converted message the control buffer should be marked with
MSG_TRUNC.  It also check if recvmsg/recvmmsg handle correctly multiple
ancillary data.

Checked on x86_64-linux and on i686-linux-gnu on both 5.11 and
4.15 kernel.

Co-authored-by: Fabian Vogt <fvogt@suse.de>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 years agosupport: Add support_socket_so_timestamp_time64
Adhemerval Zanella [Mon, 13 Dec 2021 14:36:42 +0000 (11:36 -0300)]
support: Add support_socket_so_timestamp_time64

Check if the socket support 64-bit network packages timestamps
(SO_TIMESTAMP and SO_TIMESTAMPNS).  This will be used on recvmsg
and recvmmsg tests to check if the timestamp should be generated.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 years agoFix elf/loadfail test build dependencies
Szabolcs Nagy [Fri, 28 Jan 2022 10:51:49 +0000 (10:51 +0000)]
Fix elf/loadfail test build dependencies

There was no direct or indirect make dependency on testobj3.so so the
test could fail with

/B/elf/loadfail: failed to load shared object: testobj3.so: cannot open
 shared object file: No such file or directory

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoFix glibc 2.34 ABI omission (missing GLIBC_2.34 in dynamic loader)
Florian Weimer [Thu, 27 Jan 2022 15:03:58 +0000 (16:03 +0100)]
Fix glibc 2.34 ABI omission (missing GLIBC_2.34 in dynamic loader)

The glibc 2.34 release really should have added a GLIBC_2.34
symbol to the dynamic loader. With it, we could move functions such
as dlopen or pthread_key_create that work on process-global state
into the dynamic loader (once we have fixed a longstanding issue
with static linking).  Without the GLIBC_2.34 symbol, yet another
new symbol version would be needed because old glibc will fail to
load binaries due to the missing symbol version in ld.so that newly
linked programs will require.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 years agox86: Use CHECK_FEATURE_PRESENT to check HLE [BZ #27398]
H.J. Lu [Tue, 25 Jan 2022 03:33:43 +0000 (19:33 -0800)]
x86: Use CHECK_FEATURE_PRESENT to check HLE [BZ #27398]

HLE is disabled on blacklisted CPUs.  Use CHECK_FEATURE_PRESENT, instead
of CHECK_FEATURE_ACTIVE, to check HLE.

2 years agoGuard tst-valgrind-smoke.out with run-built-tests
Mark Wielaard [Wed, 26 Jan 2022 17:57:29 +0000 (18:57 +0100)]
Guard tst-valgrind-smoke.out with run-built-tests

Prevent tst-valgrind-smoke from running when run-built-tests is not yes.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 years agohurd: Add posix_spawnattr_tc{get,set}pgrp_np on libc.abilist
Adhemerval Zanella [Wed, 26 Jan 2022 19:21:04 +0000 (16:21 -0300)]
hurd: Add posix_spawnattr_tc{get,set}pgrp_np on libc.abilist

Commit 342cc934a3bf74ac missed the update-abi for the ABI.

2 years agoAvoid -Wuse-after-free in tests [BZ #26779].
Martin Sebor [Tue, 25 Jan 2022 22:39:38 +0000 (15:39 -0700)]
Avoid -Wuse-after-free in tests [BZ #26779].

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoelf: Replace tst-p_alignmod1-editX with a python script
Adhemerval Zanella [Tue, 25 Jan 2022 16:33:13 +0000 (13:33 -0300)]
elf: Replace tst-p_alignmod1-editX with a python script

This avoid the cross-compiling breakage when the test should not run
($(run-built-tests) equal to no).

Checked on x86_64-linux-gnu and i686-linux-gnu as well with a cross
compile to aarch64-linux-gnu and powerpc64-linux-gnu.

2 years agostdlib: Avoid -Wuse-after-free in __add_to_environ [BZ #26779]
Martin Sebor [Wed, 26 Jan 2022 00:39:36 +0000 (17:39 -0700)]
stdlib: Avoid -Wuse-after-free in __add_to_environ [BZ #26779]

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoio: Fix use-after-free in ftw [BZ #26779]
Martin Sebor [Wed, 26 Jan 2022 00:39:02 +0000 (17:39 -0700)]
io: Fix use-after-free in ftw [BZ #26779]

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agointl: Avoid -Wuse-after-free [BZ #26779]
Martin Sebor [Wed, 26 Jan 2022 00:38:31 +0000 (17:38 -0700)]
intl: Avoid -Wuse-after-free [BZ #26779]

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoelf: Fix use-after-free in ldconfig [BZ #26779]
Martin Sebor [Wed, 26 Jan 2022 00:37:56 +0000 (17:37 -0700)]
elf: Fix use-after-free in ldconfig [BZ #26779]

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 years agoposix: Add terminal control setting support for posix_spawn
Adhemerval Zanella [Mon, 14 Jun 2021 17:41:31 +0000 (14:41 -0300)]
posix: Add terminal control setting support for posix_spawn

Currently there is no proper way to set the controlling terminal through
posix_spawn in race free manner [1].  This forces shell implementations
to keep using fork+exec when launching background process groups,
even when using posix_spawn yields better performance.

This patch adds a new GNU extension so the creating process can
configure the created process terminal group.  This is done with a new
flag, POSIX_SPAWN_TCSETPGROUP, along with two new attribute functions:
posix_spawnattr_tcsetpgrp_np, and posix_spawnattr_tcgetpgrp_np.
The function sets a new attribute, spawn-tcgroupfd, that references to
the controlling terminal.

The controlling terminal is set after the spawn-pgroup attribute, and
uses the spawn-tcgroupfd along with current creating process group
(so it is composable with POSIX_SPAWN_SETPGROUP).

To create a process and set the controlling terminal, one can use the
following sequence:

    posix_spawnattr_t attr;
    posix_spawnattr_init (&attr);
    posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP);
    posix_spawnattr_tcsetpgrp_np (&attr, tcfd);

If the idea is also to create a new process groups:

    posix_spawnattr_t attr;
    posix_spawnattr_init (&attr);
    posix_spawnattr_setflags (&attr, POSIX_SPAWN_TCSETPGROUP
     | POSIX_SPAWN_SETPGROUP);
    posix_spawnattr_tcsetpgrp_np (&attr, tcfd);
    posix_spawnattr_setpgroup (&attr, 0);

The controlling terminal file descriptor is ignored if the new flag is
not set.

This interface is slight different than the one provided by QNX [2],
which only provides the POSIX_SPAWN_TCSETPGROUP flag.  The QNX
documentation does not specify how the controlling terminal is obtained
nor how it iteracts with POSIX_SPAWN_SETPGROUP.  Since a glibc
implementation is library based, it is more straightforward and avoid
requires additional file descriptor operations to request the caller
to setup the controlling terminal file descriptor (and it also allows
a bit less error handling by posix_spawn).

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

[1] https://github.com/ksh93/ksh/issues/79
[2] https://www.qnx.com/developers/docs/7.0.0/index.html#com.qnx.doc.neutrino.lib_ref/topic/p/posix_spawn.html

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 years agoLinux: Detect user namespace support in io/tst-getcwd-smallbuff
Florian Weimer [Mon, 24 Jan 2022 17:14:24 +0000 (18:14 +0100)]
Linux: Detect user namespace support in io/tst-getcwd-smallbuff

Otherwise the test fails with certain container runtimes.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agoFix handling of unterminated bracket expressions in fnmatch (bug 28792)
Andreas Schwab [Tue, 18 Jan 2022 15:31:39 +0000 (16:31 +0100)]
Fix handling of unterminated bracket expressions in fnmatch (bug 28792)

When fnmatch processes a bracket expression, and eventually finds it to be
unterminated, it should rescan it, treating the starting bracket as a
normal character.  That didn't happen when a matching character was found
while scanning the bracket expression.

2 years agorealpath: Avoid overwriting preexisting error (CVE-2021-3998)
Siddhesh Poyarekar [Mon, 24 Jan 2022 16:06:41 +0000 (21:36 +0530)]
realpath: Avoid overwriting preexisting error (CVE-2021-3998)

Set errno and failure for paths that are too long only if no other error
occurred earlier.

Related: BZ #28770

Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agoelf: Add a test for PT_LOAD segments with invalid p_align [BZ #28688]
H.J. Lu [Tue, 21 Dec 2021 21:42:28 +0000 (13:42 -0800)]
elf: Add a test for PT_LOAD segments with invalid p_align [BZ #28688]

Build tst-p_alignmod3.so with 256 byte page size and verify that it is
rejected with a proper error message.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 years agoelf: Add a test for PT_LOAD segments with p_align == 1 [BZ #28688]
H.J. Lu [Tue, 21 Dec 2021 20:25:20 +0000 (12:25 -0800)]
elf: Add a test for PT_LOAD segments with p_align == 1 [BZ #28688]

Add tst-p_alignmod2-edit to edit the copy of tst-p_alignmod-base.so to
set p_align of the first PT_LOAD segment to 1 and verify that the shared
library can be loaded normally.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 years agoelf: Add a test for PT_LOAD segments with mixed p_align [BZ #28676]
H.J. Lu [Tue, 21 Dec 2021 02:33:55 +0000 (18:33 -0800)]
elf: Add a test for PT_LOAD segments with mixed p_align [BZ #28676]

Add tst-p_alignmod1-edit to edit the copy of tst-p_alignmod-base.so to
reduce p_align of the first PT_LOAD segment by half and verify that the
shared library is mapped with the maximum p_align of all PT_LOAD segments.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 years agoAdd and use link-test-modules-rpath-link [BZ #28455]
H.J. Lu [Fri, 15 Oct 2021 13:33:05 +0000 (06:33 -0700)]
Add and use link-test-modules-rpath-link [BZ #28455]

DT_RUNPATH is only used to find the immediate dependencies of the
executable or shared object containing the DT_RUNPATH entry:

1. Define link-test-modules-rpath-link if $(build-hardcoded-path-in-tests)
is yes.
2. Use $(link-test-modules-rpath-link) in build-module-helper so that
test modules can dlopen modules with DT_RUNPATH.
3. Add a test to show why link-test-modules-rpath-link is needed.

This partially fixes BZ #28455.

2 years agotst-realpath-toolong: Fix hurd build
Siddhesh Poyarekar [Mon, 24 Jan 2022 05:27:09 +0000 (10:57 +0530)]
tst-realpath-toolong: Fix hurd build

Define PATH_MAX to a constant if it isn't already defined, like in hurd.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agogetcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999)
Siddhesh Poyarekar [Fri, 21 Jan 2022 18:02:56 +0000 (23:32 +0530)]
getcwd: Set errno to ERANGE for size == 1 (CVE-2021-3999)

No valid path returned by getcwd would fit into 1 byte, so reject the
size early and return NULL with errno set to ERANGE.  This change is
prompted by CVE-2021-3999, which describes a single byte buffer
underflow and overflow when all of the following conditions are met:

- The buffer size (i.e. the second argument of getcwd) is 1 byte
- The current working directory is too long
- '/' is also mounted on the current working directory

Sequence of events:

- In sysdeps/unix/sysv/linux/getcwd.c, the syscall returns ENAMETOOLONG
  because the linux kernel checks for name length before it checks
  buffer size

- The code falls back to the generic getcwd in sysdeps/posix

- In the generic func, the buf[0] is set to '\0' on line 250

- this while loop on line 262 is bypassed:

    while (!(thisdev == rootdev && thisino == rootino))

  since the rootfs (/) is bind mounted onto the directory and the flow
  goes on to line 449, where it puts a '/' in the byte before the
  buffer.

- Finally on line 458, it moves 2 bytes (the underflowed byte and the
  '\0') to the buf[0] and buf[1], resulting in a 1 byte buffer overflow.

- buf is returned on line 469 and errno is not set.

This resolves BZ #28769.

Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Qualys Security Advisory <qsa@qualys.com>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agoAdd valgrind smoke test
Alexandra Hájková [Tue, 26 Oct 2021 09:42:44 +0000 (11:42 +0200)]
Add valgrind smoke test

Check if whether valgrind is available in the test environment.
If not, skip the test. Run smoke tests with valgrind to verify dynamic loader.
First, check if algrind works with the system ld.so in the test
environment. Then run the actual test inside the test environment,
using the just build ld.so and new libraries.

Co-authored-by: Mark Wielaard <mark@klomp.org>
2 years agohtl: Fix cleaning the reply port
Samuel Thibault [Sat, 22 Jan 2022 00:12:05 +0000 (00:12 +0000)]
htl: Fix cleaning the reply port

If any RPC fails, the reply port will already be deallocated.
__pthread_thread_terminate thus has to defer taking its name until the very last
__thread_terminate_release which doesn't reply a message.  But then we
have to read from the pthread structure.

This introduces __pthread_dealloc_finish() which does the recording of
the thread termination, so the slot can be reused really only just before
the __thread_terminate_release call. Only the real thread can set it, so
let's decouple this from the pthread_state by just removing the
PTHREAD_TERMINATED state and add a terminated field.

2 years agoelf: Properly align all PT_LOAD segments [BZ #28676]
H.J. Lu [Wed, 15 Dec 2021 21:58:33 +0000 (13:58 -0800)]
elf: Properly align all PT_LOAD segments [BZ #28676]

Linker may set p_align of a PT_LOAD segment larger than p_align of the
first PT_LOAD segment to satisfy a section alignment:

Elf file type is DYN (Shared object file)
Entry point 0x0
There are 10 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000834 0x0000000000000834  R E    0x1000
  LOAD           0x0000000000000e00 0x0000000000001e00 0x0000000000001e00
                 0x0000000000000230 0x0000000000000230  RW     0x1000
  LOAD           0x0000000000400000 0x0000000000400000 0x0000000000400000
                 0x0000000000000004 0x0000000000000008  RW     0x400000
...

 Section to Segment mapping:
  Segment Sections...
   00     .note.gnu.property .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .plt.got .text .fini .rodata .eh_frame_hdr .eh_frame
   01     .init_array .fini_array .data.rel.ro .dynamic .got .got.plt
   02     .data .bss

We should align the first PT_LOAD segment to the maximum p_align of all
PT_LOAD segments, similar to the kernel commit:

commit ce81bb256a224259ab686742a6284930cbe4f1fa
Author: Chris Kennelly <ckennelly@google.com>
Date:   Thu Oct 15 20:12:32 2020 -0700

    fs/binfmt_elf: use PT_LOAD p_align values for suitable start address

This fixes BZ #28676.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 years agorealpath: Set errno to ENAMETOOLONG for result larger than PATH_MAX [BZ #28770]
Siddhesh Poyarekar [Thu, 13 Jan 2022 05:58:36 +0000 (11:28 +0530)]
realpath: Set errno to ENAMETOOLONG for result larger than PATH_MAX [BZ #28770]

realpath returns an allocated string when the result exceeds PATH_MAX,
which is unexpected when its second argument is not NULL.  This results
in the second argument (resolved) being uninitialized and also results
in a memory leak since the caller expects resolved to be the same as the
returned value.

Return NULL and set errno to ENAMETOOLONG if the result exceeds
PATH_MAX.  This fixes [BZ #28770], which is CVE-2021-3998.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agosupport: Add helpers to create paths longer than PATH_MAX
Siddhesh Poyarekar [Tue, 18 Jan 2022 07:59:36 +0000 (13:29 +0530)]
support: Add helpers to create paths longer than PATH_MAX

Add new helpers support_create_and_chdir_toolong_temp_directory and
support_chdir_toolong_temp_directory to create and descend into
directory trees longer than PATH_MAX.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2 years agonptl: Effectively skip CAS in spinlock loop
Jangwoong Kim [Tue, 14 Dec 2021 12:30:51 +0000 (21:30 +0900)]
nptl: Effectively skip CAS in spinlock loop

The commit:
"Add LLL_MUTEX_READ_LOCK [BZ #28537]"
SHA1: d672a98a1af106bd68deb15576710cd61363f7a6

introduced LLL_MUTEX_READ_LOCK, to skip CAS in spinlock loop
if atomic load fails. But, "continue" inside of do-while loop
does not skip the evaluation of escape expression, thus CAS
is not skipped.

Replace do-while with while and skip LLL_MUTEX_TRYLOCK if
LLL_MUTEX_READ_LOCK fails.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2 years agomips: Move DT_MIPS into <ldsodefs.h>
Florian Weimer [Wed, 19 Jan 2022 19:11:55 +0000 (20:11 +0100)]
mips: Move DT_MIPS into <ldsodefs.h>

ELF_MACHINE_XHASH_SETUP in that file needs it.

Fixes commit c90363403b57b3b7919061851cb3e6d9c85e784a
("elf: Move _dl_setup_hash to its own file").

2 years agox86_64: Document libmvec vector functions accuracy [BZ #28766]
Sunil K Pandey [Tue, 18 Jan 2022 15:07:44 +0000 (07:07 -0800)]
x86_64: Document libmvec vector functions accuracy [BZ #28766]

Document maximum 4 ulps accuracy for x86_64 libmvec functions.
This fixes BZ #28766.

Reviewed-By: Paul Zimmermann <Paul.Zimmermann@inria.fr>
2 years agox86: Black list more Intel CPUs for TSX [BZ #27398]
H.J. Lu [Fri, 14 Jan 2022 22:48:01 +0000 (14:48 -0800)]
x86: Black list more Intel CPUs for TSX [BZ #27398]

Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:

https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html

This fixes BZ #27398.

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2 years agoelf: Fix tst-align3
Adhemerval Zanella [Tue, 18 Jan 2022 17:36:45 +0000 (14:36 -0300)]
elf: Fix tst-align3

The elf/tst-align3.c declares the function using a wrong prototype.

Checked on aarch64-linux-gnu.

This page took 0.09227 seconds and 5 git commands to generate.