<feed xmlns='http://www.w3.org/2005/Atom'>
<title>glibc.git/stdlib/Makefile, branch release/2.37/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>stdlib: Test using setenv with updated environ [BZ #32588]</title>
<updated>2025-01-25T03:07:47+00:00</updated>
<author>
<name>H.J. Lu</name>
<email>hjl.tools@gmail.com</email>
</author>
<published>2025-01-24T10:53:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=24d69e33fc8b83bc170bdce3fae3dc220d681d32'/>
<id>24d69e33fc8b83bc170bdce3fae3dc220d681d32</id>
<content type='text'>
Add a test for setenv with updated environ.  Verify that BZ #32588 is
fixed.

Signed-off-by: H.J. Lu &lt;hjl.tools@gmail.com&gt;
Reviewed-by: Florian Weimer &lt;fweimer@redhat.com&gt;
(cherry picked from commit 8ab34497de14e35aff09b607222fe1309ef156da)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a test for setenv with updated environ.  Verify that BZ #32588 is
fixed.

Signed-off-by: H.J. Lu &lt;hjl.tools@gmail.com&gt;
Reviewed-by: Florian Weimer &lt;fweimer@redhat.com&gt;
(cherry picked from commit 8ab34497de14e35aff09b607222fe1309ef156da)
</pre>
</div>
</content>
</entry>
<entry>
<title>hurd: fix build of tst-system.c</title>
<updated>2024-05-02T17:20:08+00:00</updated>
<author>
<name>Adam Yi</name>
<email>ayi@janestreet.com</email>
</author>
<published>2023-03-08T08:11:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=f4de99ea83794152296c5448c5cd00e3becb92bb'/>
<id>f4de99ea83794152296c5448c5cd00e3becb92bb</id>
<content type='text'>
We made tst-system.c depend on pthread, but that requires linking with
$(shared-thread-library). It does not fail under Linux because the
variable expands to nothing under Linux, but it fails for Hurd.

I tested verified via cross-compiling that "make check" now works
for Hurd.

Signed-off-by: Adam Yi &lt;ayi@janestreet.com&gt;
Reviewed-by: Adhemerval Zanella  &lt;adhemerval.zanella@linaro.org&gt;
(cherry picked from commit d03094649d39949a30513bf3ffb03a28fecbccd8)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We made tst-system.c depend on pthread, but that requires linking with
$(shared-thread-library). It does not fail under Linux because the
variable expands to nothing under Linux, but it fails for Hurd.

I tested verified via cross-compiling that "make check" now works
for Hurd.

Signed-off-by: Adam Yi &lt;ayi@janestreet.com&gt;
Reviewed-by: Adhemerval Zanella  &lt;adhemerval.zanella@linaro.org&gt;
(cherry picked from commit d03094649d39949a30513bf3ffb03a28fecbccd8)
</pre>
</div>
</content>
</entry>
<entry>
<title>stdlib: Undo post review change to 16adc58e73f3 [BZ #27749]</title>
<updated>2023-02-20T13:16:22+00:00</updated>
<author>
<name>Vitaly Buka</name>
<email>vitalybuka@google.com</email>
</author>
<published>2023-02-18T20:53:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=790e504a172a5ef7399b3e3f481d76394dce0a23'/>
<id>790e504a172a5ef7399b3e3f481d76394dce0a23</id>
<content type='text'>
Post review removal of "goto restart" from
https://sourceware.org/pipermail/libc-alpha/2021-April/125470.html
introduced a bug when some atexit handers skipped.

Signed-off-by: Vitaly Buka &lt;vitalybuka@google.com&gt;

Reviewed-by: Adhemerval Zanella  &lt;adhemerval.zanella@linaro.org&gt;
(cherry picked from commit fd78cfa72ea2bab30fdb4e1e0672b34471426c05)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Post review removal of "goto restart" from
https://sourceware.org/pipermail/libc-alpha/2021-April/125470.html
introduced a bug when some atexit handers skipped.

Signed-off-by: Vitaly Buka &lt;vitalybuka@google.com&gt;

Reviewed-by: Adhemerval Zanella  &lt;adhemerval.zanella@linaro.org&gt;
(cherry picked from commit fd78cfa72ea2bab30fdb4e1e0672b34471426c05)
</pre>
</div>
</content>
</entry>
<entry>
<title>Update copyright dates with scripts/update-copyrights</title>
<updated>2023-01-06T21:14:39+00:00</updated>
<author>
<name>Joseph Myers</name>
<email>joseph@codesourcery.com</email>
</author>
<published>2023-01-06T21:08:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=6d7e8eda9b85b08f207a6dc6f187e94e4817270f'/>
<id>6d7e8eda9b85b08f207a6dc6f187e94e4817270f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>configure: Use -Wno-ignored-attributes if compiler warns about multiple aliases</title>
<updated>2022-11-01T12:51:06+00:00</updated>
<author>
<name>Adhemerval Zanella</name>
<email>adhemerval.zanella@linaro.org</email>
</author>
<published>2022-03-11T13:40:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=8d98c7c00f3f06545de9e5ce5cf778d2ab2450a4'/>
<id>8d98c7c00f3f06545de9e5ce5cf778d2ab2450a4</id>
<content type='text'>
clang emits an warning when a double alias redirection is used, to warn
the the original symbol will be used even when weak definition is
overridden.  However, this is a common pattern for weak_alias, where
multiple alias are set to same symbol.

Reviewed-by: Fangrui Song &lt;maskray@google.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
clang emits an warning when a double alias redirection is used, to warn
the the original symbol will be used even when weak definition is
overridden.  However, this is a common pattern for weak_alias, where
multiple alias are set to same symbol.

Reviewed-by: Fangrui Song &lt;maskray@google.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>arc4random: simplify design for better safety</title>
<updated>2022-07-27T11:58:27+00:00</updated>
<author>
<name>Jason A. Donenfeld</name>
<email>Jason@zx2c4.com</email>
</author>
<published>2022-07-26T19:58:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=eaad4f9e8f07fc43618f6c8635a7e82831a423dd'/>
<id>eaad4f9e8f07fc43618f6c8635a7e82831a423dd</id>
<content type='text'>
Rather than buffering 16 MiB of entropy in userspace (by way of
chacha20), simply call getrandom() every time.

This approach is doubtlessly slower, for now, but trying to prematurely
optimize arc4random appears to be leading toward all sorts of nasty
properties and gotchas. Instead, this patch takes a much more
conservative approach. The interface is added as a basic loop wrapper
around getrandom(), and then later, the kernel and libc together can
work together on optimizing that.

This prevents numerous issues in which userspace is unaware of when it
really must throw away its buffer, since we avoid buffering all
together. Future improvements may include userspace learning more from
the kernel about when to do that, which might make these sorts of
chacha20-based optimizations more possible. The current heuristic of 16
MiB is meaningless garbage that doesn't correspond to anything the
kernel might know about. So for now, let's just do something
conservative that we know is correct and won't lead to cryptographic
issues for users of this function.

This patch might be considered along the lines of, "optimization is the
root of all evil," in that the much more complex implementation it
replaces moves too fast without considering security implications,
whereas the incremental approach done here is a much safer way of going
about things. Once this lands, we can take our time in optimizing this
properly using new interplay between the kernel and userspace.

getrandom(0) is used, since that's the one that ensures the bytes
returned are cryptographically secure. But on systems without it, we
fallback to using /dev/urandom. This is unfortunate because it means
opening a file descriptor, but there's not much of a choice. Secondly,
as part of the fallback, in order to get more or less the same
properties of getrandom(0), we poll on /dev/random, and if the poll
succeeds at least once, then we assume the RNG is initialized. This is a
rough approximation, as the ancient "non-blocking pool" initialized
after the "blocking pool", not before, and it may not port back to all
ancient kernels, though it does to all kernels supported by glibc
(≥3.2), so generally it's the best approximation we can do.

The motivation for including arc4random, in the first place, is to have
source-level compatibility with existing code. That means this patch
doesn't attempt to litigate the interface itself. It does, however,
choose a conservative approach for implementing it.

Cc: Adhemerval Zanella Netto &lt;adhemerval.zanella@linaro.org&gt;
Cc: Florian Weimer &lt;fweimer@redhat.com&gt;
Cc: Cristian Rodríguez &lt;crrodriguez@opensuse.org&gt;
Cc: Paul Eggert &lt;eggert@cs.ucla.edu&gt;
Cc: Mark Harris &lt;mark.hsj@gmail.com&gt;
Cc: Eric Biggers &lt;ebiggers@kernel.org&gt;
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.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>
Rather than buffering 16 MiB of entropy in userspace (by way of
chacha20), simply call getrandom() every time.

This approach is doubtlessly slower, for now, but trying to prematurely
optimize arc4random appears to be leading toward all sorts of nasty
properties and gotchas. Instead, this patch takes a much more
conservative approach. The interface is added as a basic loop wrapper
around getrandom(), and then later, the kernel and libc together can
work together on optimizing that.

This prevents numerous issues in which userspace is unaware of when it
really must throw away its buffer, since we avoid buffering all
together. Future improvements may include userspace learning more from
the kernel about when to do that, which might make these sorts of
chacha20-based optimizations more possible. The current heuristic of 16
MiB is meaningless garbage that doesn't correspond to anything the
kernel might know about. So for now, let's just do something
conservative that we know is correct and won't lead to cryptographic
issues for users of this function.

This patch might be considered along the lines of, "optimization is the
root of all evil," in that the much more complex implementation it
replaces moves too fast without considering security implications,
whereas the incremental approach done here is a much safer way of going
about things. Once this lands, we can take our time in optimizing this
properly using new interplay between the kernel and userspace.

getrandom(0) is used, since that's the one that ensures the bytes
returned are cryptographically secure. But on systems without it, we
fallback to using /dev/urandom. This is unfortunate because it means
opening a file descriptor, but there's not much of a choice. Secondly,
as part of the fallback, in order to get more or less the same
properties of getrandom(0), we poll on /dev/random, and if the poll
succeeds at least once, then we assume the RNG is initialized. This is a
rough approximation, as the ancient "non-blocking pool" initialized
after the "blocking pool", not before, and it may not port back to all
ancient kernels, though it does to all kernels supported by glibc
(≥3.2), so generally it's the best approximation we can do.

The motivation for including arc4random, in the first place, is to have
source-level compatibility with existing code. That means this patch
doesn't attempt to litigate the interface itself. It does, however,
choose a conservative approach for implementing it.

Cc: Adhemerval Zanella Netto &lt;adhemerval.zanella@linaro.org&gt;
Cc: Florian Weimer &lt;fweimer@redhat.com&gt;
Cc: Cristian Rodríguez &lt;crrodriguez@opensuse.org&gt;
Cc: Paul Eggert &lt;eggert@cs.ucla.edu&gt;
Cc: Mark Harris &lt;mark.hsj@gmail.com&gt;
Cc: Eric Biggers &lt;ebiggers@kernel.org&gt;
Cc: linux-crypto@vger.kernel.org
Signed-off-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;

Reviewed-by: Adhemerval Zanella  &lt;adhemerval.zanella@linaro.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>stdlib: Add arc4random tests</title>
<updated>2022-07-22T14:58:27+00:00</updated>
<author>
<name>Adhemerval Zanella Netto</name>
<email>adhemerval.zanella@linaro.org</email>
</author>
<published>2022-07-21T13:05:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=8dd890d96f1833a58de6e112a14d63ab44e0a402'/>
<id>8dd890d96f1833a58de6e112a14d63ab44e0a402</id>
<content type='text'>
The basic tst-arc4random-chacha20.c checks if the output of ChaCha20
implementation matches the reference test vectors from RFC8439.

The tst-arc4random-fork.c check if subprocesses generate distinct
streams of randomness (if fork handling is done correctly).

The tst-arc4random-stats.c is a statistical test to the randomness of
arc4random, arc4random_buf, and arc4random_uniform.

The tst-arc4random-thread.c check if threads generate distinct streams
of randomness (if function are thread-safe).

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

Co-authored-by: Florian Weimer &lt;fweimer@redhat.com&gt;

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The basic tst-arc4random-chacha20.c checks if the output of ChaCha20
implementation matches the reference test vectors from RFC8439.

The tst-arc4random-fork.c check if subprocesses generate distinct
streams of randomness (if fork handling is done correctly).

The tst-arc4random-stats.c is a statistical test to the randomness of
arc4random, arc4random_buf, and arc4random_uniform.

The tst-arc4random-thread.c check if threads generate distinct streams
of randomness (if function are thread-safe).

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

Co-authored-by: Florian Weimer &lt;fweimer@redhat.com&gt;

Checked on x86_64-linux-gnu and aarch64-linux-gnu.
</pre>
</div>
</content>
</entry>
<entry>
<title>stdlib: Add arc4random, arc4random_buf, and arc4random_uniform (BZ #4417)</title>
<updated>2022-07-22T14:58:27+00:00</updated>
<author>
<name>Adhemerval Zanella Netto</name>
<email>adhemerval.zanella@linaro.org</email>
</author>
<published>2022-07-21T13:04:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=6f4e0fcfa2d2b0915816a3a3a1d48b4763a7dee2'/>
<id>6f4e0fcfa2d2b0915816a3a3a1d48b4763a7dee2</id>
<content type='text'>
The implementation is based on scalar Chacha20 with per-thread cache.
It uses getrandom or /dev/urandom as fallback to get the initial entropy,
and reseeds the internal state on every 16MB of consumed buffer.

To improve performance and lower memory consumption the per-thread cache
is allocated lazily on first arc4random functions call, and if the
memory allocation fails getentropy or /dev/urandom is used as fallback.
The cache is also cleared on thread exit iff it was initialized (so if
arc4random is not called it is not touched).

Although it is lock-free, arc4random is still not async-signal-safe
(the per thread state is not updated atomically).

The ChaCha20 implementation is based on RFC8439 [1], omitting the final
XOR of the keystream with the plaintext because the plaintext is a
stream of zeros.  This strategy is similar to what OpenBSD arc4random
does.

The arc4random_uniform is based on previous work by Florian Weimer,
where the algorithm is based on Jérémie Lumbroso paper Optimal Discrete
Uniform Generation from Coin Flips, and Applications (2013) [2], who
credits Donald E. Knuth and Andrew C. Yao, The complexity of nonuniform
random number generation (1976), for solving the general case.

The main advantage of this method is the that the unit of randomness is not
the uniform random variable (uint32_t), but a random bit.  It optimizes the
internal buffer sampling by initially consuming a 32-bit random variable
and then sampling byte per byte.  Depending of the upper bound requested,
it might lead to better CPU utilization.

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

Co-authored-by: Florian Weimer &lt;fweimer@redhat.com&gt;
Reviewed-by: Yann Droneaud &lt;ydroneaud@opteya.com&gt;

[1] https://datatracker.ietf.org/doc/html/rfc8439
[2] https://arxiv.org/pdf/1304.1916.pdf
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The implementation is based on scalar Chacha20 with per-thread cache.
It uses getrandom or /dev/urandom as fallback to get the initial entropy,
and reseeds the internal state on every 16MB of consumed buffer.

To improve performance and lower memory consumption the per-thread cache
is allocated lazily on first arc4random functions call, and if the
memory allocation fails getentropy or /dev/urandom is used as fallback.
The cache is also cleared on thread exit iff it was initialized (so if
arc4random is not called it is not touched).

Although it is lock-free, arc4random is still not async-signal-safe
(the per thread state is not updated atomically).

The ChaCha20 implementation is based on RFC8439 [1], omitting the final
XOR of the keystream with the plaintext because the plaintext is a
stream of zeros.  This strategy is similar to what OpenBSD arc4random
does.

The arc4random_uniform is based on previous work by Florian Weimer,
where the algorithm is based on Jérémie Lumbroso paper Optimal Discrete
Uniform Generation from Coin Flips, and Applications (2013) [2], who
credits Donald E. Knuth and Andrew C. Yao, The complexity of nonuniform
random number generation (1976), for solving the general case.

The main advantage of this method is the that the unit of randomness is not
the uniform random variable (uint32_t), but a random bit.  It optimizes the
internal buffer sampling by initially consuming a 32-bit random variable
and then sampling byte per byte.  Depending of the upper bound requested,
it might lead to better CPU utilization.

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

Co-authored-by: Florian Weimer &lt;fweimer@redhat.com&gt;
Reviewed-by: Yann Droneaud &lt;ydroneaud@opteya.com&gt;

[1] https://datatracker.ietf.org/doc/html/rfc8439
[2] https://arxiv.org/pdf/1304.1916.pdf
</pre>
</div>
</content>
</entry>
<entry>
<title>stdlib: Remove attr_write from mbstows if dst is NULL [BZ: 29265]</title>
<updated>2022-06-22T18:12:33+00:00</updated>
<author>
<name>Noah Goldstein</name>
<email>goldstein.w.n@gmail.com</email>
</author>
<published>2022-06-22T15:24:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=464d189b9622932a75302290625de84931656ec0'/>
<id>464d189b9622932a75302290625de84931656ec0</id>
<content type='text'>
mbstows is defined if dst is NULL and is defined to special cased if
dst is NULL so the fortify objsize check if incorrect in that case.

Tested on x86-64 linux.
Reviewed-by: Siddhesh Poyarekar &lt;siddhesh@sourceware.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
mbstows is defined if dst is NULL and is defined to special cased if
dst is NULL so the fortify objsize check if incorrect in that case.

Tested on x86-64 linux.
Reviewed-by: Siddhesh Poyarekar &lt;siddhesh@sourceware.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>stdlib: Remove trailing whitespace from Makefile</title>
<updated>2022-06-22T18:12:25+00:00</updated>
<author>
<name>Noah Goldstein</name>
<email>goldstein.w.n@gmail.com</email>
</author>
<published>2022-06-22T17:53:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=dd06af4f81be9e6d6b5e3a72357a51fa7205d856'/>
<id>dd06af4f81be9e6d6b5e3a72357a51fa7205d856</id>
<content type='text'>
This causes precommit tests to fail when pushing commits that modify
this file.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This causes precommit tests to fail when pushing commits that modify
this file.
</pre>
</div>
</content>
</entry>
</feed>
