<feed xmlns='http://www.w3.org/2005/Atom'>
<title>glibc.git/libio/Makefile, branch master</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/'/>
<entry>
<title>Enable --enable-fortify-source with clang</title>
<updated>2025-11-21T16:13:11+00:00</updated>
<author>
<name>Adhemerval Zanella</name>
<email>adhemerval.zanella@linaro.org</email>
</author>
<published>2025-11-20T18:30:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=8d26bed1ebcefd5d2059fd7d7462bdf6593d77fa'/>
<id>8d26bed1ebcefd5d2059fd7d7462bdf6593d77fa</id>
<content type='text'>
clang generates internal calls for some _chk symbol, so add internal
aliases for them, and stub some with rtld-stubbed-symbols to avoid
ld.so linker issues.

Reviewed-by: Sam James &lt;sam@gentoo.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
clang generates internal calls for some _chk symbol, so add internal
aliases for them, and stub some with rtld-stubbed-symbols to avoid
ld.so linker issues.

Reviewed-by: Sam James &lt;sam@gentoo.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libio: Properly link in libio functions in static binaries</title>
<updated>2025-08-22T19:03:00+00:00</updated>
<author>
<name>H.J. Lu</name>
<email>hjl.tools@gmail.com</email>
</author>
<published>2025-08-21T23:57:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=b4ab549ae5558b9fd818a6268c32480b51fda9f6'/>
<id>b4ab549ae5558b9fd818a6268c32480b51fda9f6</id>
<content type='text'>
commit 3020f72618e4f1d7338cd42b8bc7b2813e961b5a
Author: Adhemerval Zanella Netto &lt;adhemerval.zanella@linaro.org&gt;
Date:   Tue Dec 27 18:11:43 2022 -0300

    libio: Remove the usage of __libc_IO_vtables

added

 #define libio_static_fn_required(name) __asm (".globl " #name);

to link in libio functions in static binaries.  But there is no relocation
in
	.globl	_IO_file_open

and "strip --strip-unneeded" will remove such unreferenced symbols which
breaks static binaries.  Redefine libio_static_fn_required to create a
reference to the required function with

static __typeof (name) *const name##_p __attribute__((used)) = name;

This fixes BZ #33300.

Signed-off-by: H.J. Lu &lt;hjl.tools@gmail.com&gt;
Tested-by: Xi Ruoyao &lt;xry111@xry111.site&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
commit 3020f72618e4f1d7338cd42b8bc7b2813e961b5a
Author: Adhemerval Zanella Netto &lt;adhemerval.zanella@linaro.org&gt;
Date:   Tue Dec 27 18:11:43 2022 -0300

    libio: Remove the usage of __libc_IO_vtables

added

 #define libio_static_fn_required(name) __asm (".globl " #name);

to link in libio functions in static binaries.  But there is no relocation
in
	.globl	_IO_file_open

and "strip --strip-unneeded" will remove such unreferenced symbols which
breaks static binaries.  Redefine libio_static_fn_required to create a
reference to the required function with

static __typeof (name) *const name##_p __attribute__((used)) = name;

This fixes BZ #33300.

Signed-off-by: H.J. Lu &lt;hjl.tools@gmail.com&gt;
Tested-by: Xi Ruoyao &lt;xry111@xry111.site&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libio: Add test case for fflush</title>
<updated>2025-04-14T11:27:12+00:00</updated>
<author>
<name>Frédéric Bérat</name>
<email>fberat@redhat.com</email>
</author>
<published>2024-09-09T12:43:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=11e188659db264f6b101d8eb65824ffa5bc91a0a'/>
<id>11e188659db264f6b101d8eb65824ffa5bc91a0a</id>
<content type='text'>
Since one path uses _IO_SYNC and the other _IO_OVERFLOW, the newly added
test cases verifies that `fflush (FILE)` and `fflush (NULL)` are
semantically equivalent from the FILE perspective.

Reviewed-by: Joseph Myers &lt;josmyers@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since one path uses _IO_SYNC and the other _IO_OVERFLOW, the newly added
test cases verifies that `fflush (FILE)` and `fflush (NULL)` are
semantically equivalent from the FILE perspective.

Reviewed-by: Joseph Myers &lt;josmyers@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Update copyright dates with scripts/update-copyrights</title>
<updated>2025-01-01T19:22:09+00:00</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2025-01-01T18:14:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=2642002380aafb71a1d3b569b6d7ebeab3284816'/>
<id>2642002380aafb71a1d3b569b6d7ebeab3284816</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>libio: asprintf should write NULL upon failure</title>
<updated>2024-12-27T08:18:21+00:00</updated>
<author>
<name>Florian Weimer</name>
<email>fweimer@redhat.com</email>
</author>
<published>2024-12-27T08:17:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=cb4692ce1edd5a81c2521de49dfef6125141d1c7'/>
<id>cb4692ce1edd5a81c2521de49dfef6125141d1c7</id>
<content type='text'>
This was suggested most recently by Solar Designer, noting
that code replacing vsprintf with vasprintf in a security fix
was subtly wrong:

  Re: GStreamer Security Advisory 2024-0003: Orc compiler
  stack-based buffer overflow
  &lt;https://www.openwall.com/lists/oss-security/2024/07/26/2&gt;

Previous libc-alpha discussions:

  I: [PATCH] asprintf error handling fix
  &lt;https://inbox.sourceware.org/libc-alpha/20011205185828.GA8376@ldv.office.alt-linux.org/&gt;

  asprintf() issue
  &lt;https://inbox.sourceware.org/libc-alpha/CANSoFxt-cdc-+C4u-rTENMtY4X9RpRSuv+axDswSPxbDgag8_Q@mail.gmail.com/&gt;

I don't think we need a compatibility symbol for this.  As the
GStreamer example shows, this change is much more likely to fix bugs
than cause compatibility issues.

Suggested-by: Dmitry V. Levin &lt;ldv@altlinux.org&gt;
Suggested-by: Archie Cobbs &lt;archie.cobbs@gmail.com&gt;
Suggested-by: Solar Designer &lt;solar@openwall.com&gt;
Reviewed-by: Sam James &lt;sam@gentoo.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This was suggested most recently by Solar Designer, noting
that code replacing vsprintf with vasprintf in a security fix
was subtly wrong:

  Re: GStreamer Security Advisory 2024-0003: Orc compiler
  stack-based buffer overflow
  &lt;https://www.openwall.com/lists/oss-security/2024/07/26/2&gt;

Previous libc-alpha discussions:

  I: [PATCH] asprintf error handling fix
  &lt;https://inbox.sourceware.org/libc-alpha/20011205185828.GA8376@ldv.office.alt-linux.org/&gt;

  asprintf() issue
  &lt;https://inbox.sourceware.org/libc-alpha/CANSoFxt-cdc-+C4u-rTENMtY4X9RpRSuv+axDswSPxbDgag8_Q@mail.gmail.com/&gt;

I don't think we need a compatibility symbol for this.  As the
GStreamer example shows, this change is much more likely to fix bugs
than cause compatibility issues.

Suggested-by: Dmitry V. Levin &lt;ldv@altlinux.org&gt;
Suggested-by: Archie Cobbs &lt;archie.cobbs@gmail.com&gt;
Suggested-by: Solar Designer &lt;solar@openwall.com&gt;
Reviewed-by: Sam James &lt;sam@gentoo.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Check if TEST_CC supports -Wno-restrict before using it</title>
<updated>2024-12-22T20:32:51+00:00</updated>
<author>
<name>Adhemerval Zanella</name>
<email>adhemerval.zanella@linaro.org</email>
</author>
<published>2023-07-27T18:49:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=2271e0d2b606637870daa2a39894eb8d8bbfe5dc'/>
<id>2271e0d2b606637870daa2a39894eb8d8bbfe5dc</id>
<content type='text'>
Check if TEST_CC supports -Wno-restrict before using it to avoid Clang
error:

error: unknown warning option '-Wno-restrict' [-Werror,-Wunknown-warning-option]

Signed-off-by: H.J. Lu &lt;hjl.tools@gmail.com&gt;
Reviewed-by: Sam James &lt;sam@gentoo.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Check if TEST_CC supports -Wno-restrict before using it to avoid Clang
error:

error: unknown warning option '-Wno-restrict' [-Werror,-Wunknown-warning-option]

Signed-off-by: H.J. Lu &lt;hjl.tools@gmail.com&gt;
Reviewed-by: Sam James &lt;sam@gentoo.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libio: Fix crash in fputws [BZ #20632]</title>
<updated>2024-10-25T18:05:06+00:00</updated>
<author>
<name>Peter Ammon</name>
<email>corydoras@ridiculousfish.com</email>
</author>
<published>2024-09-09T03:34:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=18596c5415e1415285b28120b70ee82792509ea2'/>
<id>18596c5415e1415285b28120b70ee82792509ea2</id>
<content type='text'>
This fixes a buffer overflow in wide character string output, reproducing
when output fails, such as if the output fd is closed or is redirected
to a full device.

Wide character output data attempts to maintain the invariant that
`_IO_buf_base &lt;= _IO_write_base &lt;= _IO_write_end &lt;= _IO_buf_end` (that is,
that the write region is a sub-region of `_IO_buf`). Prior to this commit,
this invariant is violated by the `_IO_wfile_overflow` function as so:

1. `_IO_wsetg` is called, assigning `_IO_write_base` to `_IO_buf_base`
2. `_IO_doallocbuf` is called, which jumps to `_IO_wfile_doallocate` via
    the _IO_wfile_jumps vtable. This function then assigns the wide data
    `_IO_buf_base` and `_IO_buf_end` to a malloc'd buffer.

Thus the invariant is violated. The fix is simply to reverse the order:
malloc the `_IO_buf` first and then assign `_IO_write_base` to it.

We also take this opportunity to defensively guard the initialization of
the number of unwritten characters via pointer arithmetic. We now check
that the buffer end is not before the buffer beginning; this matches a
similar defensive check in the narrow analogue `fileops.c`.

Add a test which fails without the fix.

Signed-off-by: Peter Ammon &lt;corydoras@ridiculousfish.com&gt;
Reviewed-by: Adhemerval Zanella  &lt;adhemerval.zanella@linaro.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes a buffer overflow in wide character string output, reproducing
when output fails, such as if the output fd is closed or is redirected
to a full device.

Wide character output data attempts to maintain the invariant that
`_IO_buf_base &lt;= _IO_write_base &lt;= _IO_write_end &lt;= _IO_buf_end` (that is,
that the write region is a sub-region of `_IO_buf`). Prior to this commit,
this invariant is violated by the `_IO_wfile_overflow` function as so:

1. `_IO_wsetg` is called, assigning `_IO_write_base` to `_IO_buf_base`
2. `_IO_doallocbuf` is called, which jumps to `_IO_wfile_doallocate` via
    the _IO_wfile_jumps vtable. This function then assigns the wide data
    `_IO_buf_base` and `_IO_buf_end` to a malloc'd buffer.

Thus the invariant is violated. The fix is simply to reverse the order:
malloc the `_IO_buf` first and then assign `_IO_write_base` to it.

We also take this opportunity to defensively guard the initialization of
the number of unwritten characters via pointer arithmetic. We now check
that the buffer end is not before the buffer beginning; this matches a
similar defensive check in the narrow analogue `fileops.c`.

Add a test which fails without the fix.

Signed-off-by: Peter Ammon &lt;corydoras@ridiculousfish.com&gt;
Reviewed-by: Adhemerval Zanella  &lt;adhemerval.zanella@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libio: Correctly link tst-popen-fork against libpthread</title>
<updated>2024-10-25T11:43:46+00:00</updated>
<author>
<name>Arjun Shankar</name>
<email>arjun@redhat.com</email>
</author>
<published>2024-10-25T07:33:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=6a290b2895b77be839fcb7c44a6a9879560097ad'/>
<id>6a290b2895b77be839fcb7c44a6a9879560097ad</id>
<content type='text'>
tst-popen-fork failed to build for Hurd due to not being linked with
libpthread.  This commit fixes that.

Tested with build-many-glibcs.py for i686-gnu.

Reviewed-by: Florian Weimer &lt;fweimer@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
tst-popen-fork failed to build for Hurd due to not being linked with
libpthread.  This commit fixes that.

Tested with build-many-glibcs.py for i686-gnu.

Reviewed-by: Florian Weimer &lt;fweimer@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libio: Fix a deadlock after fork in popen</title>
<updated>2024-10-23T11:40:16+00:00</updated>
<author>
<name>Arjun Shankar</name>
<email>arjun@redhat.com</email>
</author>
<published>2024-10-18T14:03:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=9f0d2c0ee6c728643fcf9a4879e9f20f5e45ce5f'/>
<id>9f0d2c0ee6c728643fcf9a4879e9f20f5e45ce5f</id>
<content type='text'>
popen modifies its file handler book-keeping under a lock that wasn't
being taken during fork.  This meant that a concurrent popen and fork
could end up copying the lock in a "locked" state into the fork child,
where subsequently calling popen would lead to a deadlock due to the
already (spuriously) held lock.

This commit fixes the deadlock by appropriately taking the lock before
fork, and releasing/resetting it in the parent/child after the fork.

A new test for concurrent popen and fork is also added.  It consistently
hangs (and therefore fails via timeout) without the fix applied.
Reviewed-by: Florian Weimer &lt;fweimer@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
popen modifies its file handler book-keeping under a lock that wasn't
being taken during fork.  This meant that a concurrent popen and fork
could end up copying the lock in a "locked" state into the fork child,
where subsequently calling popen would lead to a deadlock due to the
already (spuriously) held lock.

This commit fixes the deadlock by appropriately taking the lock before
fork, and releasing/resetting it in the parent/child after the fork.

A new test for concurrent popen and fork is also added.  It consistently
hangs (and therefore fails via timeout) without the fix applied.
Reviewed-by: Florian Weimer &lt;fweimer@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>libio: Set _vtable_offset before calling _IO_link_in [BZ #32148]</title>
<updated>2024-09-30T23:31:25+00:00</updated>
<author>
<name>H.J. Lu</name>
<email>hjl.tools@gmail.com</email>
</author>
<published>2024-09-07T15:32:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=9dfea3de7f690bff70e3c6eb346b9ad082bb2e35'/>
<id>9dfea3de7f690bff70e3c6eb346b9ad082bb2e35</id>
<content type='text'>
Since _IO_vtable_offset is used to detect the old binaries, set it
in _IO_old_file_init_internal before calling _IO_link_in which checks
_IO_vtable_offset.  Add a glibc 2.0 test with copy relocation on
_IO_stderr_@GLIBC_2.0 to verify that fopen won't cause memory corruption.
This fixes BZ #32148.

Signed-off-by: H.J. Lu &lt;hjl.tools@gmail.com&gt;
Reviewed-by: Noah Goldstein &lt;goldstein.w.n@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since _IO_vtable_offset is used to detect the old binaries, set it
in _IO_old_file_init_internal before calling _IO_link_in which checks
_IO_vtable_offset.  Add a glibc 2.0 test with copy relocation on
_IO_stderr_@GLIBC_2.0 to verify that fopen won't cause memory corruption.
This fixes BZ #32148.

Signed-off-by: H.J. Lu &lt;hjl.tools@gmail.com&gt;
Reviewed-by: Noah Goldstein &lt;goldstein.w.n@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
