Commit Graph

39249 Commits

Author SHA1 Message Date
Samuel Thibault
385f2ecda9 hurd: Fix SIOCADD/DELRT ioctls
The hurd network stack uses struct ifrtreq rather than ortentry.
2022-09-21 19:58:44 +02:00
Samuel Thibault
b84199eb18 hurd: Drop struct rtentry and in6_rtmsg
These were cargo-culted, they are not used at all in Hurd interfaces.
2022-09-21 19:58:44 +02:00
Damien Zammit
9ba0f010a6 hurd: Add _IOT_ifrtreq to <net/route.h>
So that we can use struct ifrtreq in ioctls.
2022-09-21 19:58:44 +02:00
Adhemerval Zanella
fd36873ff9 elf: Use C11 atomics on _dl_mcount
All atomic operation are counters, so relaxed MO should be suffice.

Checked on x86_64-linux-gnu.
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
2022-09-21 10:57:47 -03:00
Samuel Thibault
c0c9092f75 hurd: Use IF_NAMESIZE rather than IFNAMSIZ
The latter is not available without __USE_MISC.
2022-09-21 08:51:50 +02:00
Damien Zammit
ffd0b295d9 hurd: Add ifrtreq structure to net/route.h
As used by the hurdish route ioctls.
2022-09-21 00:42:13 +02:00
John David Anglin
fa47e8e6df hppa: undef __ASSUME_SET_ROBUST_LIST
QEMU does not support support set_robust_list. Thus, we need
to enable detection of set_robust_list system call.

Signed-off-by: John David Anglin <dave.anglin@bell.net>
2022-09-20 20:14:14 +00:00
Adhemerval Zanella
85a3228744 linux: Use same type for MMAP2_PAGE_UNIT
It avoid a possible compiler warning where right size of operator
is converted from a negative value to unsigned.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-09-20 10:57:40 -03:00
Adhemerval Zanella
aeb4d2e981 m68k: Enforce 4-byte alignment on internal locks (BZ #29537)
A new internal definition, __LIBC_LOCK_ALIGNMENT, is used to force
the 4-byte alignment only for m68k, other architecture keep the
natural alignment of the type used internally (and hppa does not
require 16-byte alignment for kernel-assisted CAS).

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-09-20 10:56:54 -03:00
Florian Weimer
c75d20b5b2 nss: Fix tst-nss-files-hosts-long on single-stack hosts (bug 24816)
getent implicitly passes AI_ADDRCONFIG to getaddrinfo by default.
Use --no-addrconfig to suppress that, so that both IPv4 and IPv6
lookups succeed even if the address family is not supported by the
host.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-09-20 13:09:55 +02:00
Florian Weimer
a623f13adf nss: Implement --no-addrconfig option for getent
The ahosts, ahostsv4, ahostsv6 commands unconditionally pass
AI_ADDRCONFIG to getaddrinfo, which is not always desired.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-09-20 13:09:25 +02:00
Florian Weimer
f97905f246 gconv: Use 64-bit interfaces in gconv_parseconfdir (bug 29583)
It's possible that inode numbers are outside the 32-bit range.
The existing code only handles the in-libc case correctly, and
still uses the legacy interfaces when building iconv.

Suggested-by: Helge Deller <deller@gmx.de>
2022-09-20 12:12:43 +02:00
Florian Weimer
1df71d32fe elf: Implement force_first handling in _dl_sort_maps_dfs (bug 28937)
The implementation in _dl_close_worker requires that the first
element of l_initfini is always this very map (“We are always the
zeroth entry, and since we don't include ourselves in the
dependency analysis start at 1.”).  Rather than fixing that
assumption, this commit adds an implementation of the force_first
argument to the new dependency sorting algorithm.  This also means
that the directly dlopen'ed shared object is always initialized last,
which is the least surprising behavior in the presence of cycles.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-09-20 11:00:42 +02:00
Florian Weimer
766b73768b Linux: Do not skip d_ino == 0 entries in readdir, readdir64 (bug 12165)
POSIX does not say this value is special.  For example, old XFS file
systems may still use inode number zero.

Also update the comment regarding ENOENT.  Linux may return ENOENT
for some file systems.
2022-09-19 12:04:57 +02:00
Samuel Thibault
7ae60af75b hurd: Factorize at/non-at functions
Non-at functions can be implemented by just calling the corresponding at
function with AT_FDCWD and zero at_flags.

In the linkat case, the at behavior is different (O_NOLINK), so this introduces
__linkat_common to pass O_NOLINK as appropriate.

lstat functions can also be implemented with fstatat by adding
__fstatat64_common which takes a flags parameter in addition to the at_flags
parameter,

In the end this factorizes chmod, chown, link, lstat64, mkdir, readlink,
rename, stat64, symlink, unlink, utimes.

This also makes __lstat, __lxstat64, __stat and __xstat64 directly use
__fstatat64_common instead of __lstat64 or __stat64.
2022-09-17 19:58:30 +00:00
Samuel Thibault
6841aed6c4 tst-sprintf-errno: Update Hurd message length
03ad444e8e ("mach: Fix incoherency between perror and strerror") fixesd
the output of error messages, but tst-sprintf-errno.c was still checking
the old (erroneous) format length. This updates the expected output length
according to the 03ad444e8e fix.
2022-09-17 17:42:42 +02:00
Łukasz Stelmach
22c96052ac RISC-V: Allow long jumps to __syscall_error
__syscall_error may end up farther than 1MiB away from a caller,
especially when linking statically large binaries. tail allows for
4GiB jumps and is reduced to j when a linked symbol is within range.

Fixes: 36960f0c76 ("RISC-V: Linux Syscall Interface")
Fixes: 7f33b09c65 ("RISC-V: Linux ABI")
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
2022-09-16 23:25:45 -04:00
Samuel Thibault
5652e12cce hurd: Make readlink* just reopen the file used for stat
9e5c991106 ("hurd: Fix readlink() hanging on fifo") separated opening
the file for the stat call from opening the file for the read call. That
however opened a small window for the file to change. Better make this
atomic by reopening the file with O_READ.
2022-09-15 21:53:57 +02:00
Samuel Thibault
9e5c991106 hurd: Fix readlink() hanging on fifo
readlink() opens the target with O_READ to be able to read the symlink
content. When the target is actually a fifo, that would hang waiting for a
writer (caught in the coreutils testsuite). We thus have to first lookup the
target without O_READ to perform io_stat and lookout for fifos, and only
after checking the symlink type, we can re-lookup with O_READ.
2022-09-14 18:57:44 +02:00
Paul Eggert
05967faf0e Fix BRE typos in check-safety.sh
* manual/check-safety.sh: Fix BRE portability typos.
POSIX says \] produces undefined results.
2022-09-14 00:12:20 -05:00
Sergei Trofimovich
2d7ed98add Makerules: fix MAKEFLAGS assignment for upcoming make-4.4 [BZ# 29564]
make-4.4 will add long flags to MAKEFLAGS variable:

    * WARNING: Backward-incompatibility!
      Previously only simple (one-letter) options were added to the MAKEFLAGS
      variable that was visible while parsing makefiles.  Now, all options
      are available in MAKEFLAGS.

This causes locale builds to fail when long options are used:

    $ make --shuffle
    ...
    make  -C localedata install-locales
    make: invalid shuffle mode: '1662724426r'

The change fixes it by passing eash option via whitespace and dashes.
That way option is appended to both single-word form and whitespace
separated form.

While at it fixed --silent mode detection in $(MAKEFLAGS) by filtering
out --long-options. Otherwise options like --shuffle flag enable silent
mode unintentionally. $(silent-make) variable consolidates the checks.

Resolves: BZ# 29564

CC: Paul Smith <psmith@gnu.org>
CC: Siddhesh Poyarekar <siddhesh@gotplt.org>
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-09-13 13:45:32 -04:00
Wilco Dijkstra
a30e960328 Use relaxed atomics since there is no MO dependence
Replace the 3 uses of atomic_bit_set and atomic_bit_test_set with
atomic_fetch_or_relaxed.  Using relaxed MO is correct since the
atomics are used to ensure memory is released only once.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-09-13 11:58:07 +01:00
Aurelien Jarno
f278835f59 makedb: fix build with libselinux >= 3.1 (Bug 26233)
glibc doesn't build with libselinux 3.1 that has been released recently
due to new deprecations introduced in that version and the fact that
glibc is built with -Werror by default:

| makedb.c: In function ‘set_file_creation_context’:
| makedb.c:849:3: error: ‘security_context_t’ is deprecated [-Werror=deprecated-declarations]
|   849 |   security_context_t ctx;
|       |   ^~~~~~~~~~~~~~~~~~
| makedb.c:863:3: error: ‘matchpathcon’ is deprecated: Use selabel_lookup instead [-Werror=deprecated-declarations]
|   863 |   if (matchpathcon (outname, S_IFREG | mode, &ctx) == 0 && ctx != NULL)
|       |   ^~
| In file included from makedb.c:50:
| /usr/include/selinux/selinux.h:500:12: note: declared here
|   500 | extern int matchpathcon(const char *path,
|       |            ^~~~~~~~~~~~
| cc1: all warnings being treated as errors

This patch fixes the makedb half of bug 26233 by moving to the new
SELinux APIs and removes the existing compiler pragmas as no longer
required. Upstream API usage feedback gathered by Arjun is integrated
into this version of the fix.

The built makedb was tested and operates as expected on x86_64 with
SELinu in enforcing mode.

No regressions on x86_64 with libselinux 3.3.

Co-authored-by: Arjun Shankar <arjun@redhat.com>
Co-authored-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-09-12 18:26:49 -04:00
Samuel Thibault
1918241b55 tst-sprintf-errno: Update Hurd message output
03ad444e8e ("mach: Fix incoherency between perror and strerror")
fixesd the output of error messages, but tst-sprintf-errno.c was still
checking the old (erroneous) format. This updates the expected output
according to the 03ad444e8e fix.
2022-09-11 14:22:04 +02:00
Wilco Dijkstra
a364a3a709 Use C11 atomics instead of atomic_decrement(_val)
Replace atomic_decrement and atomic_decrement_val with
atomic_fetch_add_relaxed.

Reviewed-by: DJ Delorie <dj@redhat.com>
2022-09-09 14:22:26 +01:00
Wilco Dijkstra
53b251c9ff Use C11 atomics instead atomic_add(_zero)
Replace atomic_add and atomic_add_zero with atomic_fetch_add_relaxed.

Reviewed-by: DJ Delorie <dj@redhat.com>
2022-09-09 14:11:23 +01:00
Paul Eggert
83859e1115 mktime: improve heuristic for ca-1986 Indiana DST
This patch syncs mktime.c from Gnulib, fixing a
problem reported by Mark Krenz <https://bugs.gnu.org/48085>,
and it should fix BZ#29035 too.
* time/mktime.c (__mktime_internal): Be more generous about
accepting arguments with the wrong value of tm_isdst, by falling
back to a one-hour DST difference if we find no nearby DST that is
unusual.  This fixes a problem where "1986-04-28 00:00 EDT" was
rejected when TZ="America/Indianapolis" because the nearest DST
timestamp occurred in 1970, a temporal distance too great for the
old heuristic.  This also also narrows the search a bit, which
is a minor performance win.
2022-09-08 22:55:54 -05:00
Paul Eggert
82a1ec8510 Assume HAVE_TZSET in time/mktime.c
This patch does not affect glibc.  It affects only Gnulib-specific
code and is for coordination with Gnulib.
2022-09-08 22:55:54 -05:00
Javier Pello
a23820f605 elf: Fix hwcaps string size overestimation
Commit dad90d5282 added glibc-hwcaps
support for LD_LIBRARY_PATH and, for this, it adjusted the total
string size required in _dl_important_hwcaps. However, in doing so
it inadvertently altered the calculation of the size required for
the power set strings, as the computation of the power set string
size depended on the first value assigned to the total variable,
which is later shifted, resulting in overallocation of string
space. Fix this now by using a different variable to hold the
string size required for glibc-hwcaps.

Signed-off-by: Javier Pello <devel@otheo.eu>
2022-09-08 12:12:35 +02:00
Andreas Schwab
3d7d5c10c8 errlist: add missing entry for EDEADLOCK (bug 29545)
Some architectures (mips, powerpc and sparc) define separate values for
EDEADLOCK and EDEADLK.  Readd the errlist entry for EDEADLOCK for those
configurations.  Also use the dependency files from generating the
auxiliary errlist and siglist files.
2022-09-08 11:40:24 +02:00
Joseph Myers
b8cc607f3c Do not define static_assert or thread_local in headers for C2x
C2x makes static_assert and thread_local into keywords, removing the
definitions as macros in assert.h and threads.h.  Thus, disable those
macros in those glibc headers for C2x.

The disabling is done based on a combination of language version and
__GNUC_PREREQ, *not* based on __GLIBC_USE (ISOC2X), on the principle
that users of the header (when requesting C11 or later APIs - not
assert.h for C99 and older API versions) should always have the names
static_assert or thread_local available after inclusion of the header,
whether as a keyword or as a macro.  Thus, when using a compiler
without the keywords (whether an older compiler, possibly in C2x mode,
or _GNU_SOURCE with any compiler but in an older language mode, for
example) the macros should be defined, even when C2x APIs have been
requested.  The __GNUC_PREREQ conditionals here may well need updating
with the versions of other compilers that gained support for these
keywords in C2x mode.

Tested for x86_64.
2022-09-07 18:39:28 +00:00
Wilco Dijkstra
89d40cacd0 malloc: Use C11 atomics rather than atomic_exchange_and_add
Replace a few counters using atomic_exchange_and_add with
atomic_fetch_add_relaxed.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-09-06 16:49:01 +01:00
Siddhesh Poyarekar
76fe56020e Add NEWS entry for CVE-2022-39046 2022-09-06 09:31:50 -04:00
Florian Weimer
dbb75513f5 elf: Rename _dl_sort_maps parameter from skip to force_first
The new implementation will not be able to skip an arbitrary number
of objects.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-09-06 07:38:33 +02:00
Florian Weimer
183d997372 scripts/dso-ordering-test.py: Generate program run-time dependencies
The main program needs to depend on all shared objects, even objects
that have link-time dependencies among shared objects.  Filtering
out shared objects that already have an link-time dependencies is not
necessary here; make will do this automatically.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-09-06 07:38:16 +02:00
Adhemerval Zanella
2fc7320668 math: x86: Use prefix for FP_INIT_ROUNDMODE
Not all compilers support the inline asm prefix '%v' to emit the avx
instruction if AVX is enable.  Use a prefix instead.

Checked on x86_64-linux-gnu and i686-linux-gnu.
2022-09-05 10:54:41 -03:00
Florian Weimer
0784e7913f scripts/build-many-glibcs.py: Use https:// for sourceware.org Git clones
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-09-05 15:52:24 +02:00
Adhemerval Zanella
cd84e30c04 debug: test for more required cacellation points (BZ# 29274)
Generalize the test for cancellation point in __read_chk to also test
the other fortified functions with required cancellation points.

Since there is not easy way to force some syscalls to block (for
instance pread) the test tests two modes: cancellation on blocked
syscalls and early cancellation on pending request.

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

Co-authored-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-09-05 10:47:34 -03:00
Florian Weimer
29eb796119 elf.h: Remove duplicate definition of VER_FLG_WEAK
This did not cause a warning before because the token sequence for
the two definitions was identical.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-09-05 15:02:09 +02:00
Adhemerval Zanella
45459476ec syslog: Remove extra whitespace between timestamp and message (BZ#29544)
The rfc3164 clear states that a single space character must follow
the timestamp field.

Checked on x86_64-linux-gnu.
2022-09-05 09:34:39 -03:00
caiyinyu
930993921f LoongArch: Add soft float support. 2022-09-01 09:10:08 +08:00
Adhemerval Zanella
1e903124ce elf: Restore how vDSO dependency is printed with LD_TRACE_LOADED_OBJECTS (BZ #29539)
The d7703d3176 changed how vDSO like
dependencies are printed, instead of just the name and address it
follows other libraries mode and prints 'name => path'.

Unfortunately, this broke some ldd consumer that uses the output to
filter out the program's dependencies.  For instance CMake
bundleutilities module [1], where GetPrequirite uses the regex to filter
out 'name => path' [2].

This patch restore the previous way to print just the name and the
mapping address.

Checked on x86_64-linux-gnu.

[1] https://github.com/Kitware/CMake/tree/master/Tests/BundleUtilities
[2] https://github.com/Kitware/CMake/blob/master/Modules/GetPrerequisites.cmake#L733

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-08-31 09:08:33 -03:00
Adhemerval Zanella
8cd559cf5a nptl: x86_64: Use same code for CURRENT_STACK_FRAME and stackinfo_get_sp
It avoids the possible warning of uninitialized 'frame' variable when
building with clang:

  ../sysdeps/nptl/jmp-unwind.c:27:42: error: variable 'frame' is
  uninitialized when used here [-Werror,-Wuninitialized]
    __pthread_cleanup_upto (env->__jmpbuf, CURRENT_STACK_FRAME);

The resulting code is similar to CURRENT_STACK_FRAME.

Checked on x86_64-linux-gnu.
2022-08-31 09:04:27 -03:00
Raphael Moreira Zinsly
c7509d49c4 Apply asm redirections in wchar.h before first use
Similar to d0fa09a770, but for wchar.h.  Fixes [BZ #27087] by applying
all long double related asm redirections before using functions in
bits/wchar2.h.
Moves the function declarations from wcsmbs/bits/wchar2.h to a new file
wcsmbs/bits/wchar2-decl.h that will be included first in wcsmbs/wchar.h.

Tested with build-many-glibcs.py.
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-08-30 12:50:16 -03:00
Florian Weimer
d09aa4a172 resolv: Fix building tst-resolv-invalid-cname for earlier C standards
This fixes this compiler error:

tst-resolv-invalid-cname.c: In function ‘test_mode_to_string’:
tst-resolv-invalid-cname.c:164:10: error: label at end of compound statement
     case test_mode_num:
          ^~~~~~~~~~~~~

Fixes commit 9caf782276
("resolv: Add new tst-resolv-invalid-cname").
2022-08-30 14:04:12 +02:00
Adhemerval Zanella
52a5be0df4 syslog: Fix large messages (BZ#29536)
The a583b6add4 change did not handle large messages that
would require a heap allocation correctly, where the message itself
is not take in consideration.

This patch fixes it and extend the tst-syslog to check for large
messages as well.

Checked on x86_64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-08-30 08:54:52 -03:00
Adhemerval Zanella
ddcf5a9170 posix: Fix macro expansion producing 'defined' has undefined behavior
The NEED_CHECK_SPEC is defined as:

  #define NEED_CHECK_SPEC \
    (!defined _XBS5_ILP32_OFF32 || !defined _XBS5_ILP32_OFFBIG \
     || !defined _XBS5_LP64_OFF64 || !defined _XBS5_LPBIG_OFFBIG \
     || !defined _POSIX_V6_ILP32_OFF32 || !defined _POSIX_V6_ILP32_OFFBIG \
     || !defined _POSIX_V6_LP64_OFF64 || !defined _POSIX_V6_LPBIG_OFFBIG \
     || !defined _POSIX_V7_ILP32_OFF32 || !defined _POSIX_V7_ILP32_OFFBIG \
     || !defined _POSIX_V7_LP64_OFF64 || !defined _POSIX_V7_LPBIG_OFFBIG)

Which is undefined behavior accordingly to C Standard (Preprocessing
directives, p4).

Checked on x86_64-linux-gnu.
2022-08-30 08:40:47 -03:00
Adhemerval Zanella
6c4ee1aba1 stdlib: Fix macro expansion producing 'defined' has undefined behavior
The FPIOCONST_HAVE_EXTENDED_RANGE is defined as:

  #define FPIOCONST_HAVE_EXTENDED_RANGE \
    ((!defined __NO_LONG_DOUBLE_MATH && __LDBL_MAX_EXP__ > 1024) \
    || __HAVE_DISTINCT_FLOAT128)

Which is undefined behavior accordingly to C Standard (Preprocessing
directives, p4).

Checked on x86_64-linux-gnu.
2022-08-30 08:40:47 -03:00
Stefan Liebler
e57d8fc97b S390: Always use svc 0
On s390x syscalls are triggered by svc instruction. One can
pass the syscall number encoded in the instruction "svc 123"
or by storing it in r1:
lghi r1,123
svc 0

If the syscall number is encoded in the instruction, this can
cause broken syscall restarts.  Therefore this patch is now just
passing the syscall number in r1.

See also kernel-commit:
"s390/signal: switch to using vdso for sigreturn and syscall restart"
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/s390/[%e2%80%a6]call.c?h=v6.0-rc1&id=df29a7440c4b5c65765c8f60396b3b13063e24e9

As information, the "svc 0" feature was introduced in kernel 2.5.62:
commit b5aad611393ef2e132e3648fa4c6e56a9cfa8708
2022-08-30 10:54:46 +02:00
Florian Weimer
1d495912a7 nss_dns: Rewrite _nss_dns_gethostbyname4_r using current interfaces
Introduce struct alloc_buffer to this function, and use it and
struct ns_rr_cursor in gaih_getanswer_slice.  Adjust gaih_getanswer
and gaih_getanswer_noaaaa accordingly.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-08-30 10:02:49 +02:00