Commit graph

42063 commits

Author SHA1 Message Date
gfleury
265c5991af htl: move pthread_mutex_consistent, pthread_mutex_consistent_np into libc.
Message-ID: <20250103103750.870897-6-gfleury@disroot.org>
2025-01-29 02:32:36 +01:00
gfleury
8bfabe7a92 htl: move pthread_mutex_destroy into libc.
Message-ID: <20250103103750.870897-5-gfleury@disroot.org>
2025-01-29 02:32:36 +01:00
gfleury
be9f0e7681 htl: move pthread_mutex_getprioceiling, pthread_mutex_setprioceiling into libc
Message-ID: <20250103103750.870897-4-gfleury@disroot.org>
2025-01-29 02:32:36 +01:00
gfleury
2ebc2d8e24 htl: move pthread_mutex_{lock, unlock, trylock, timedlock, clocklock}
I haven't exposed _pthread_mutex_lock,  _pthread_mutex_trylock and
_pthread_mutex_unlock in GLIBC_PRIVATE since there aren't used in any
code in libpthread
Message-ID: <20250103103750.870897-3-gfleury@disroot.org>
2025-01-29 02:32:36 +01:00
gfleury
e892a93073 htl: move pthread_mutex_init into libc.
Message-ID: <20250103103750.870897-2-gfleury@disroot.org>
2025-01-29 02:32:36 +01:00
gfleury
56b25bfd60 htl: remove leftover for pthread_mutexattr_settype
from b386295727
2025-01-29 02:32:36 +01:00
Joseph Myers
203452a460 Add test of input file flushing / offset issues
Having fixed several bugs relating to flushing of FILE* streams (with
fflush and other operations) and their offsets (both the file position
indicator in the FILE*, and the offset in the underlying open file
description), especially after ungetc but not limited to that case,
add a test that more systematically covers different combinations of
cases for such issues, with 57220 separate scenarios tested (which
include examples of all the five separate fixed bugs), all of which
pass given the five previous bug fixes.

Tested for x86_64.
2025-01-28 23:39:12 +00:00
Joseph Myers
3ff3b9997c Fix fflush handling for mmap files after ungetc (bug 32535)
As discussed in bug 32535, fflush fails on files opened for reading
using mmap after ungetc.  Fix the logic to handle this case and still
compute the file offset correctly.

Tested for x86_64.
2025-01-28 23:20:08 +00:00
Joseph Myers
0dcc0b2f63 Fix fseek handling for mmap files after ungetc or fflush (bug 32529)
As discussed in bug 32529, fseek fails on files opened for reading
using mmap after ungetc.  The implementation of fseek for such files
has an offset computation that's also incorrect after fflush.  A
combined fix addresses both problems (with tests for both included as
well) and it seems reasonable to consider them a single bug.

Tested for x86_64.
2025-01-28 22:35:21 +00:00
Joseph Myers
94251ae99e Make fflush (NULL) flush input files (bug 32369)
As discussed in bug 32369 and required by POSIX, the POSIX feature
fflush (NULL) should flush input files, not just output files.  The
POSIX requirement is that "fflush() shall perform this flushing action
on all streams for which the behavior is defined above", and the
definition for input files is for "a stream open for reading with an
underlying file description, if the file is not already at EOF, and
the file is one capable of seeking".

Implement this requirement in glibc.  (The underlying flushing
implementation is what deals with avoiding errors for seeking on an
unseekable file.)

Tested for x86_64.
2025-01-28 21:53:49 +00:00
Joseph Myers
be6818be31 Make fclose seek input file to right offset (bug 12724)
As discussed in bug 12724 and required by POSIX, before an input file
(based on an underlying seekable file descriptor) is closed, fclose is
sometimes required to seek that file descriptor to the correct offset,
so that any other file descriptors sharing the underlying open file
description are left at that offset (as a motivating example, a script
could call a sequence of commands each of which processes some data
from (seekable) stdin using stdio; fclose needs to do this so that
each successive command can read exactly the data not handled by
previous commands), but glibc fails to do this.

The precise POSIX wording has changed a few times; in the 2024 edition
it's "If the file is not already at EOF, and the file is one capable
of seeking, the file offset of the underlying open file description
shall be set to the file position of the stream if the stream is the
active handle to the underlying file description.".

Add appropriate logic to _IO_new_file_close_it to handle this case.  I
haven't made any attempt to test or change things in this area for the
"old" functions.

Note that there was a previous attempt to fix bug 12724, reverted in
commit eb6cbd249f.  The fix version here
addresses the original test in that bug report without breaking the
one given in a subsequent comment in that bug report (which works with
glibc before the patch, but maybe was broken by the original fix that
was reverted).

The logic here tries to take care not to seek the file, even to its
newly computed current offset, if at EOF / possibly not the active
handle; even seeking to the current offset would be problematic
because of a potential race (fclose computes the current offset,
another thread or process with the active handle does its own seek,
fclose does a seek (not permitted by POSIX in this case) that loses
the effect of the seek on the active handle in another thread or
process).  There are tests included for various cases of being or not
being the active handle, though there aren't tests for the potential
race condition.

Tested for x86_64.
2025-01-28 20:22:56 +00:00
Joseph Myers
377e9733b5 Fix fflush after ungetc on input file (bug 5994)
As discussed in bug 5994 (plus duplicates), POSIX requires fflush
after ungetc to discard pushed-back characters but preserve the file
position indicator.  For this purpose, each ungetc decrements the file
position indicator by 1; it is unspecified after ungetc at the start
of the file, and after ungetwc, so no special handling is needed for
either of those cases.

This is fixed with appropriate logic in _IO_new_file_sync.  I haven't
made any attempt to test or change things in this area for the "old"
functions; the case of files using mmap is addressed in a subsequent
patch (and there seem to be no problems in this area with files opened
with fmemopen).

Tested for x86_64.
2025-01-28 19:38:27 +00:00
Tulio Magno Quites Machado Filho
1515f74fd8 libio: Add a new fwrite test that evaluates partial writes
Test if the file-position is correctly updated when fwrite tries to
flush its internal cache but is not able to completely write all items.

Reviewed-by: DJ Delorie <dj@redhat.com>
2025-01-28 15:37:44 -03:00
Tulio Magno Quites Machado Filho
596a61cf6b libio: Start to return errors when flushing fwrite's buffer [BZ #29459]
When an error happens, fwrite is expected to return a value that is less
than nmemb.  If this error happens while flushing its internal buffer,
fwrite is in a complex scenario: all the data might have been written to
the buffer, indicating a successful copy, but the buffer is expected to
be flushed and it was not.

POSIX.1-2024 states the following about errors on fwrite:

    If an error occurs, the resulting value of the file-position indicator
    for the stream is unspecified.

    The fwrite() function shall return the number of elements successfully
    written, which may be less than nitems if a write error is encountered.

With that in mind, this commit modifies _IO_new_file_write in order to
return the total number of bytes written via the file pointer.  It also
modifies fwrite in order to use the new information and return the
correct number of bytes written even when sputn returns EOF.

Add 2 tests:

1. tst-fwrite-bz29459: This test is based on the reproducer attached to
   bug 29459.  In order to work, it requires to pipe stdout to another
   process making it hard to reuse test-driver.c.  This code is more
   specific to the issue reported.
2. tst-fwrite-pipe: Recreates the issue by creating a pipe that is shared
   with a child process.  Reuses test-driver.c.  Evaluates a more generic
   scenario.

Co-authored-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
2025-01-28 15:37:44 -03:00
Martin Coufal
45c42b65c2 Add new tests for fopen
Adding some basic tests for fopen, testing different modes, stream
positioning and concurrent read/write operation on files.
Reviewed-by: DJ Delorie <dj@redhat.com>
2025-01-28 12:50:50 -05:00
Andreas K. Hüttel
42aba91895
Increase version to 2.41.9000, add new section to NEWS
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-28 18:42:35 +01:00
Andreas K. Hüttel
74f59e9271
Create ChangeLog.old/ChangeLog.30
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-28 18:31:33 +01:00
Andreas K. Hüttel
f46351b491
Bump version to 2.41
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-28 18:25:13 +01:00
Andreas K. Hüttel
9b2f20dd54
po: update translations (final, only timestamp and line number changes)
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-28 13:47:28 +01:00
Andreas K. Hüttel
b8c0cb4b1c
libc.pot: regenerate (only line number changes)
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-28 12:36:07 +01:00
Andreas K. Hüttel
fda82f6e80
INSTALL: update last tested version numbers
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-28 12:31:08 +01:00
Andreas K. Hüttel
27bebf9b4f
contrib.texi: minor improvements
Mention CORE-MATH developers by name
Fix accent

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-27 16:30:54 +01:00
Andreas K. Hüttel
115afa9daa
NEWS: Add some more news from the 2.41 cycle
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-27 14:36:43 +01:00
Andreas K. Hüttel
604a340e91
contrib.texi: Update from 2.40..2.41 commit log
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-27 01:06:16 +01:00
Andreas K. Hüttel
181b6258e3
NEWS: Add reference to (single) advisory
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-26 23:30:13 +01:00
Andreas K. Hüttel
306acc0519
NEWS: Add list of bugs fixed in 2.41
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-26 23:26:07 +01:00
Andreas K. Hüttel
dc650eb715
NEWS: editorial changes (language, line breaks)
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-26 20:09:26 +01:00
Xi Ruoyao
b31ed9581b
testsuite: Make stdio-common/tst-printf-format-*-mem UNSUPPORTED if the mtrace output does not exist
When gawk was not built with MPFR, there's no mtrace output and those
tests FAIL.  But we should make them UNSUPPORTED like other
tst-printf-format-* tests in the case.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Sam James <sam@gentoo.org>
Reviewed-by: Andreas K Hüttel <dilfridge@gentoo.org>
2025-01-26 16:15:38 +01:00
Sam James
8d55f2fb17
elf: fix 'valgrind' typo in comment 2025-01-25 05:34:20 +00:00
Sam James
fc8f253d80
malloc: cleanup casts in tst-calloc
Followup to c3d1dac96b. As pointed out by
Maciej W. Rozycki, the casts are obviously useless now.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-25 05:34:05 +00:00
H.J. Lu
8ab34497de stdlib: Test using setenv with updated environ [BZ #32588]
Add a test for setenv with updated environ.  Verify that BZ #32588 is
fixed.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-25 07:31:41 +08:00
Aurelien Jarno
aba14403c6 LICENSES: update CORE-MATH copyright
Many more files from the CORE-MATH have been added. Also update the
authors and copyright years.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-24 23:21:49 +01:00
Aurelien Jarno
1ed3e44688 LICENSES: update location of getaddrinfo.c and getnameinfo.c
posix/getaddrinfo.c got moved into nss/getaddrinfo.c in commit
7f602256ab ("Move getaddrinfo from 'posix' into 'nss'")

inet/getnameinfo.c got moved into nss/getnameinfo.c in commit
2f1c 6652 d7b3 ("Move getnameinfo from 'inet' to 'nss'")

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-24 23:21:49 +01:00
Aurelien Jarno
4871ab841b LICENSES: remove Intel License Agreement
The corresponding files are gone with the IA64 removal in commit
460860f457 ("Remove ia64-linux-gnu").

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-24 23:21:49 +01:00
Florian Weimer
12b4a1fc6e stdlib: Re-implement free (environ) compatibility kludge for setenv
For the originally failing application (userhelper from usermode),
it is not actually necessary to call realloc on the environ
pointer.  Yes, there will be a memory leak because the application
assigns a heap-allocated pointer to environ that it never frees,
but this leak was always there: the old realloc-based setenv had
a hidden internal variable, last_environ, that was used in a similar
way to __environ_array_list.  The application is not impacted by
the leak anyway because the relevant operations do not happen in
a loop.

The change here just uses a separte heap allocation and points
environ to that.  This means that if an application calls
free (environ) and restores the environ pointer to the value
at process start, and does not modify the environment further,
nothing bad happens.

This change should not invalidate any previous testing that went into
the original getenv thread safety change, commit 7a61e7f557
("stdlib: Make getenv thread-safe in more cases").

The new test cases are modeled in part on the env -i use case from
bug 32588 (with !DO_MALLOC && !DO_EARLY_SETENV), and the previous
stdlib/tst-setenv-malloc test.  The DO_MALLOC && !DO_EARLY_SETENV
case in the new test should approximate what userhelper from the
usermode package does.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-01-24 22:37:49 +01:00
Florian Weimer
36fcdfbbc5 Revert "stdlib: Support malloc-managed environ arrays for compatibility"
This reverts commit b62759db04.

Reason for revert: Incompatible with “env -i” and coreutils (bug 32588).

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2025-01-24 12:25:29 +01:00
Florian Weimer
b62759db04 stdlib: Support malloc-managed environ arrays for compatibility
Some applications set environ to a heap-allocated pointer, call
setenv (expecting it to call realloc), free environ, and then
restore the original environ pointer.  This breaks after
commit 7a61e7f557 ("stdlib: Make
getenv thread-safe in more cases") because after the setenv call,
the environ pointer does not point to the start of a heap allocation.
Instead, setenv creates a separate allocation and changes environ
to point into that.  This means that the free call in the application
results in heap corruption.

The interim approach was more compatible with other libcs because
it does not assume that the incoming environ pointer is allocated
as if by malloc (if it was written by the application).  However,
it seems to be more important to stay compatible with previous
glibc version: assume the incoming pointer is heap allocated,
and preserve this property after setenv calls.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2025-01-23 17:43:15 +01:00
Andreas K. Hüttel
76c3f7f81b
po: Incorporate translations
be ca cs da de el eo es fi fr gl hr hu ia id it ja ka ko lt nb nl pl pt ro ru rw sk sl sr sv tr uk vi zh_CN zh_TW

Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
2025-01-22 22:51:01 +01:00
Siddhesh Poyarekar
d9dcfe766e Update advisory GLIBC-SA-2025-0001 (2.40)
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2025-01-22 09:41:05 -05:00
Siddhesh Poyarekar
94e908cee9 Add advisory text for CVE-2025-0395
Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-22 08:23:53 -05:00
Siddhesh Poyarekar
68ee0f704c Fix underallocation of abort_msg_s struct (CVE-2025-0395)
Include the space needed to store the length of the message itself, in
addition to the message string.  This resolves BZ #32582.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-22 08:17:17 -05:00
Yury Khrustalev
d4626340b9
NEWS: Add note on Guarded Control Stack support
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
2025-01-21 21:34:03 +01:00
Paul Pluzhnikov
c6b6a8cf04 Fix typo: _POSIX_REATIME_SIGNALS -> _POSIX_REALTIME_SIGNALS [BZ# 32515]
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-21 15:03:42 +00:00
Yury Khrustalev
50eaf54883 aarch64: Add HWCAP_GCS
Use upper 32 bits of HWCAP.

Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
2025-01-21 11:45:14 +00:00
Florian Weimer
71b49e299d nptl: Include <stdbool.h> in tst-skeleton-affinity-inheritance.c
The file uses the identifiers bool, false, true.
2025-01-21 10:37:54 +01:00
Florian Weimer
1ac28b7818 stdlib: Test for expected sequence of random numbers from rand
As the test comment explains, this test is not quite valid, but
preserving the exact sequences helps distributions to port to
newer glibc versions.  We can remove this test if we ever switch
to a different implementation.

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2025-01-20 21:31:59 +01:00
Florian Weimer
33b684e019 stdlib: Fix unintended change to the random_r implementation
Commit d5bceac99d changed the sequence
of random numbers.  This was completely unintended.  The statistical
properties of the new sequences are unclear, so restore the old
behavior.

Fixes commit d5bceac99d ("stdlib:
random_r: fix unaligned access in initstate and initstate_r
[BZ #30584]").

Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
2025-01-20 21:31:55 +01:00
Florian Weimer
a3131e71cf elf: Make tst-ro-dynamic-mod.map compatible with older binutils
Older versions such as binutils 2.35.2 do not recognize
PT_GNU_PROPERTY.

Fixes commit d3f2b71ef1
("aarch64: Fix tests not compatible with targets supporting GCS").
2025-01-20 20:35:10 +01:00
Michael Jeanson
5eafafc46c NEWS: Add the extensible rseq ABI to new features
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
2025-01-20 18:47:11 +00:00
Florian Weimer
b3a6bd625c Linux: Do not check unused bytes after sched_getattr in tst-sched_setattr
Linux 6.13 was released with a change that overwrites those bytes.
This means that the check_unused subtest fails.

Update the manual accordingly.

Tested-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-01-20 15:20:57 +01:00