<feed xmlns='http://www.w3.org/2005/Atom'>
<title>glibc/malloc, branch vdso</title>
<subtitle>Fork of glibc for development</subtitle>
<id>https://git.zx2c4.com/glibc/atom/malloc?h=vdso</id>
<link rel='self' href='https://git.zx2c4.com/glibc/atom/malloc?h=vdso'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/'/>
<updated>2024-09-27T18:25:36Z</updated>
<entry>
<title>linux: Add support for getrandom vDSO</title>
<updated>2024-09-27T18:25:36Z</updated>
<author>
<name>Adhemerval Zanella</name>
<email>adhemerval.zanella@linaro.org</email>
</author>
<published>2024-09-18T14:01:22Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=f766fb0a85fa06a9081e6b39c0834960202fde85'/>
<id>urn:sha1:f766fb0a85fa06a9081e6b39c0834960202fde85</id>
<content type='text'>
Linux 6.11 has getrandom() in vDSO. It operates on a thread-local opaque
state allocated with mmap using flags specified by the vDSO.

Multiple states are allocated at once, as many as fit into a page, and
these are held in an array of available states to be doled out to each
thread upon first use, and recycled when a thread terminates. As these
states run low, more are allocated.

To make this procedure async-signal-safe, a simple guard is used in the
LSB of the opaque state address, falling back to the syscall if there's
reentrancy contention.

Also, _Fork() is handled by blocking signals on opaque state allocation
(so _Fork() always sees a consistent state even if it interrupts a
getrandom() call) and by iterating over the thread stack cache on
reclaim_stack. Each opaque state will be in the free states list
(grnd_alloc.states) or allocated to a running thread.

The cancellation is handled by always using GRND_NONBLOCK flags while
calling the vDSO, and falling back to the cancellable syscall if the
kernel returns EAGAIN (would block). Since getrandom is not defined by
POSIX and cancellation is supported as an extension, the cancellation is
handled as 'may occur' instead of 'shall occur' [1], meaning that if
vDSO does not block (the expected behavior) getrandom will not act as a
cancellation entrypoint. It avoids a pthread_testcancel call on the fast
path (different than 'shall occur' functions, like sem_wait()).

It is currently enabled for x86_64, which is available in Linux 6.11,
and aarch64, powerpc32, powerpc64, loongarch64, and s390x, which are
available in Linux 6.12.

Link: https://pubs.opengroup.org/onlinepubs/9799919799/nframe.html [1]
Co-developed-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt;
Tested-by: Jason A. Donenfeld &lt;Jason@zx2c4.com&gt; # x86_64
Tested-by: Adhemerval Zanella &lt;adhemerval.zanella@linaro.org&gt; # x86_64, aarch64
Tested-by: Xi Ruoyao &lt;xry111@xry111.site&gt; # x86_64, aarch64, loongarch64
Tested-by: Stefan Liebler &lt;stli@linux.ibm.com&gt; # s390x
</content>
</entry>
<entry>
<title>malloc: Link threading tests with $(shared-thread-library)</title>
<updated>2024-08-20T14:16:25Z</updated>
<author>
<name>Samuel Thibault</name>
<email>samuel.thibault@ens-lyon.org</email>
</author>
<published>2024-08-20T14:16:25Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=251843e16fcec4e2b328577be66dcb2f3fa1c1e7'/>
<id>urn:sha1:251843e16fcec4e2b328577be66dcb2f3fa1c1e7</id>
<content type='text'>
Fixes build failures on Hurd.
</content>
</entry>
<entry>
<title>malloc: Link threading tests with $(shared-thread-library)</title>
<updated>2024-07-27T14:46:49Z</updated>
<author>
<name>Florian Weimer</name>
<email>fweimer@redhat.com</email>
</author>
<published>2024-07-27T14:23:55Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=a57cbbd85379874177d40d675f5b905e669d0a47'/>
<id>urn:sha1:a57cbbd85379874177d40d675f5b905e669d0a47</id>
<content type='text'>
Fixes build failures on Hurd.
</content>
</entry>
<entry>
<title>malloc: add multi-threaded tests for aligned_alloc/calloc/malloc</title>
<updated>2024-07-22T09:54:46Z</updated>
<author>
<name>Miguel Martín</name>
<email>mmartinv@redhat.com</email>
</author>
<published>2024-07-16T15:14:57Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=b0fbcb7d0051a68baf26b2aed51a8a31c34d68e5'/>
<id>urn:sha1:b0fbcb7d0051a68baf26b2aed51a8a31c34d68e5</id>
<content type='text'>
Improve aligned_alloc/calloc/malloc test coverage by adding
multi-threaded tests with random memory allocations and with/without
cross-thread memory deallocations.

Perform a number of memory allocation calls with random sizes limited
to 0xffff.

Use the existing DSO ('malloc/tst-aligned_alloc-lib.c') to randomize
allocator selection.

The multi-threaded allocation/deallocation is staged as described below:

- Stage 1: Half of the threads will be allocating memory and the
  other half will be waiting for them to finish the allocation.
- Stage 2: Half of the threads will be allocating memory and the
  other half will be deallocating memory.
- Stage 3: Half of the threads will be deallocating memory and the
  second half waiting on them to finish.

Add 'malloc/tst-aligned-alloc-random-thread.c' where each thread will
deallocate only the memory that was previously allocated by itself.

Add 'malloc/tst-aligned-alloc-random-thread-cross.c' where each thread
will deallocate memory that was previously allocated by another thread.

The intention is to be able to utilize existing malloc testing to ensure
that similar allocation APIs are also exposed to the same rigors.
Reviewed-by: Arjun Shankar &lt;arjun@redhat.com&gt;
</content>
</entry>
<entry>
<title>malloc: avoid global locks in tst-aligned_alloc-lib.c</title>
<updated>2024-07-22T09:54:46Z</updated>
<author>
<name>Miguel Martín</name>
<email>mmartinv@redhat.com</email>
</author>
<published>2024-07-16T15:14:56Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=9a27b566b2048f599048f2f4afe1cce06c4ef43d'/>
<id>urn:sha1:9a27b566b2048f599048f2f4afe1cce06c4ef43d</id>
<content type='text'>
Make sure the DSO used by aligned_alloc/calloc/malloc tests does not get
a global lock on multithreaded tests.
Reviewed-by: Arjun Shankar &lt;arjun@redhat.com&gt;
</content>
</entry>
<entry>
<title>Fix usage of _STACK_GROWS_DOWN and _STACK_GROWS_UP defines [BZ 31989]</title>
<updated>2024-07-19T14:10:17Z</updated>
<author>
<name>John David Anglin</name>
<email>danglin@gcc.gnu.org</email>
</author>
<published>2024-07-19T14:10:17Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=8cfa4ecff21adf226984f135aa576dd8063bbba3'/>
<id>urn:sha1:8cfa4ecff21adf226984f135aa576dd8063bbba3</id>
<content type='text'>
Signed-off-by: John David Anglin &lt;dave.anglin@bell.net&gt;
Reviewed-By: Andreas K. Hüttel &lt;dilfridge@gentoo.org&gt;
</content>
</entry>
<entry>
<title>mtrace: make shell commands robust against meta characters</title>
<updated>2024-06-24T07:33:49Z</updated>
<author>
<name>Andreas Schwab</name>
<email>schwab@suse.de</email>
</author>
<published>2024-06-20T12:13:01Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=2a6c922f09e7a1c206e0cbdb4424f1cf101a5bda'/>
<id>urn:sha1:2a6c922f09e7a1c206e0cbdb4424f1cf101a5bda</id>
<content type='text'>
Use the list form of the open function to avoid interpreting meta
characters in the arguments.
</content>
</entry>
<entry>
<title>malloc: Replace shell/Perl gate in mtrace</title>
<updated>2024-06-20T18:55:10Z</updated>
<author>
<name>Florian Weimer</name>
<email>fweimer@redhat.com</email>
</author>
<published>2024-06-20T18:55:10Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=dd144dce21c864781fade4561581d50fb4549956'/>
<id>urn:sha1:dd144dce21c864781fade4561581d50fb4549956</id>
<content type='text'>
The previous version expanded $0 and $@ twice.

The new version defines a q no-op shell command.  The Perl syntax
error is masked by the eval Perl function.  The q { … } construct
is executed by the shell without errors because the q shell function
was defined, but treated as a non-expanding quoted string by Perl,
effectively hiding its context from the Perl interpreter.  As before
the script is read by require instead of executed directly, to avoid
infinite recursion because the #! line contains /bin/sh.

Introduce the “fatal” function to produce diagnostics that are not
suppressed by “do”.  Use “do” instead of “require” because it has
fewer requirements on the executed script than “require”.

Prefix relative paths with './' because “do” (and “require“ before)
searches for the script in @INC if the path is relative and does not
start with './'.  Use $_ to make the trampoline shorter.

Add an Emacs mode marker to indentify the script as a Perl script.
</content>
</entry>
<entry>
<title>malloc: Always install mtrace (bug 31892)</title>
<updated>2024-06-20T08:32:16Z</updated>
<author>
<name>Florian Weimer</name>
<email>fweimer@redhat.com</email>
</author>
<published>2024-06-20T08:32:16Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=086910fc41655152812b515dc324d2ac0dc36e67'/>
<id>urn:sha1:086910fc41655152812b515dc324d2ac0dc36e67</id>
<content type='text'>
Generation of the Perl script does not depend on Perl, so we can
always install it even if $(PERL) is not set during the build.

Change the malloc/mtrace.pl text substition not to rely on $(PERL).
Instead use PATH at run time to find the Perl interpreter. The Perl
interpreter cannot execute directly a script that starts with
“#! /bin/sh”: it always executes it with /bin/sh.  There is no
perl command line switch to disable this behavior.  Instead, use
the Perl require function to execute the script.  The additional
shift calls remove the “.” shell arguments.  Perl interprets the
“.” as a string concatenation operator, making the expression
syntactically valid.

Reviewed-by: Carlos O'Donell &lt;carlos@redhat.com&gt;
</content>
</entry>
<entry>
<title>malloc: New test to check malloc alternate path using memory obstruction</title>
<updated>2024-06-04T16:00:29Z</updated>
<author>
<name>sayan paul</name>
<email>saypaul@redhat.com</email>
</author>
<published>2024-05-29T10:01:04Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/glibc/commit/?id=127fc56152347d73cb7c1c283e60e1cb1f15e9f9'/>
<id>urn:sha1:127fc56152347d73cb7c1c283e60e1cb1f15e9f9</id>
<content type='text'>
The test aims to ensure that malloc uses the alternate path to
allocate memory when sbrk() or brk() fails.To achieve this,
the test first creates an obstruction at current program break,
tests that obstruction with a failing sbrk(), then checks if malloc
is still returning a valid ptr thus inferring that malloc() used
mmap() instead of brk() or sbrk() to allocate the memory.
Reviewed-by: Arjun Shankar &lt;arjun@redhat.com&gt;
Reviewed-by: Zack Weinberg &lt;zack@owlfolio.org&gt;
</content>
</entry>
</feed>
