2024-01-01 18:12:26 +00:00
|
|
|
# Copyright (C) 2016-2024 Free Software Foundation, Inc.
|
2016-12-31 18:02:17 +00:00
|
|
|
# This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
# The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
# The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
# <https://www.gnu.org/licenses/>.
|
2016-12-31 18:02:17 +00:00
|
|
|
|
|
|
|
# Allowed attributes for tunables:
|
|
|
|
#
|
|
|
|
# type: Defaults to STRING
|
|
|
|
# minval: Optional minimum acceptable value
|
|
|
|
# maxval: Optional maximum acceptable value
|
2023-11-23 17:29:14 +00:00
|
|
|
# default: Optional default value (if not specified it will be 0 or "")
|
2016-12-31 18:02:17 +00:00
|
|
|
# env_alias: An alias environment variable
|
|
|
|
|
|
|
|
glibc {
|
|
|
|
malloc {
|
|
|
|
check {
|
|
|
|
type: INT_32
|
|
|
|
minval: 0
|
|
|
|
maxval: 3
|
|
|
|
env_alias: MALLOC_CHECK_
|
|
|
|
}
|
|
|
|
top_pad {
|
|
|
|
type: SIZE_T
|
|
|
|
env_alias: MALLOC_TOP_PAD_
|
2022-08-04 08:24:47 +00:00
|
|
|
default: 131072
|
2016-12-31 18:02:17 +00:00
|
|
|
}
|
|
|
|
perturb {
|
|
|
|
type: INT_32
|
|
|
|
minval: 0
|
|
|
|
maxval: 0xff
|
|
|
|
env_alias: MALLOC_PERTURB_
|
|
|
|
}
|
|
|
|
mmap_threshold {
|
|
|
|
type: SIZE_T
|
|
|
|
env_alias: MALLOC_MMAP_THRESHOLD_
|
|
|
|
}
|
|
|
|
trim_threshold {
|
|
|
|
type: SIZE_T
|
|
|
|
env_alias: MALLOC_TRIM_THRESHOLD_
|
|
|
|
}
|
|
|
|
mmap_max {
|
|
|
|
type: INT_32
|
|
|
|
env_alias: MALLOC_MMAP_MAX_
|
2021-02-05 08:39:24 +00:00
|
|
|
minval: 0
|
2016-12-31 18:02:17 +00:00
|
|
|
}
|
|
|
|
arena_max {
|
|
|
|
type: SIZE_T
|
|
|
|
env_alias: MALLOC_ARENA_MAX
|
|
|
|
minval: 1
|
|
|
|
}
|
|
|
|
arena_test {
|
|
|
|
type: SIZE_T
|
|
|
|
env_alias: MALLOC_ARENA_TEST
|
|
|
|
minval: 1
|
|
|
|
}
|
2017-07-06 17:37:30 +00:00
|
|
|
tcache_max {
|
|
|
|
type: SIZE_T
|
|
|
|
}
|
|
|
|
tcache_count {
|
|
|
|
type: SIZE_T
|
|
|
|
}
|
|
|
|
tcache_unsorted_limit {
|
|
|
|
type: SIZE_T
|
|
|
|
}
|
2019-08-08 23:09:43 +00:00
|
|
|
mxfast {
|
|
|
|
type: SIZE_T
|
|
|
|
minval: 0
|
|
|
|
}
|
2021-08-13 11:36:29 +00:00
|
|
|
hugetlb {
|
malloc: Add Huge Page support for mmap
With the morecore hook removed, there is not easy way to provide huge
pages support on with glibc allocator without resorting to transparent
huge pages. And some users and programs do prefer to use the huge pages
directly instead of THP for multiple reasons: no splitting, re-merging
by the VM, no TLB shootdowns for running processes, fast allocation
from the reserve pool, no competition with the rest of the processes
unlike THP, no swapping all, etc.
This patch extends the 'glibc.malloc.hugetlb' tunable: the value
'2' means to use huge pages directly with the system default size,
while a positive value means and specific page size that is matched
against the supported ones by the system.
Currently only memory allocated on sysmalloc() is handled, the arenas
still uses the default system page size.
To test is a new rule is added tests-malloc-hugetlb2, which run the
addes tests with the required GLIBC_TUNABLE setting. On systems without
a reserved huge pages pool, is just stress the mmap(MAP_HUGETLB)
allocation failure. To improve test coverage it is required to create
a pool with some allocated pages.
Checked on x86_64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
2021-08-16 18:08:27 +00:00
|
|
|
type: SIZE_T
|
2021-08-13 11:36:29 +00:00
|
|
|
minval: 0
|
|
|
|
}
|
2016-12-31 18:02:17 +00:00
|
|
|
}
|
2018-08-02 18:19:19 +00:00
|
|
|
cpu {
|
2017-04-17 04:30:35 +00:00
|
|
|
hwcap_mask {
|
|
|
|
type: UINT_64
|
|
|
|
env_alias: LD_HWCAP_MASK
|
|
|
|
default: HWCAP_IMPORTANT
|
2017-12-14 19:18:12 +00:00
|
|
|
}
|
2017-04-17 04:30:35 +00:00
|
|
|
}
|
2017-12-05 16:24:14 +00:00
|
|
|
|
|
|
|
elision {
|
|
|
|
enable {
|
|
|
|
type: INT_32
|
|
|
|
minval: 0
|
|
|
|
maxval: 1
|
|
|
|
}
|
|
|
|
skip_lock_busy {
|
|
|
|
type: INT_32
|
|
|
|
default: 3
|
2021-02-05 08:39:24 +00:00
|
|
|
minval: 0
|
2017-12-05 16:24:14 +00:00
|
|
|
}
|
|
|
|
skip_lock_internal_abort {
|
|
|
|
type: INT_32
|
|
|
|
default: 3
|
2021-02-05 08:39:24 +00:00
|
|
|
minval: 0
|
2017-12-05 16:24:14 +00:00
|
|
|
}
|
|
|
|
skip_lock_after_retries {
|
|
|
|
type: INT_32
|
|
|
|
default: 3
|
2021-02-05 08:39:24 +00:00
|
|
|
minval: 0
|
2017-12-05 16:24:14 +00:00
|
|
|
}
|
|
|
|
tries {
|
|
|
|
type: INT_32
|
|
|
|
default: 3
|
2021-02-05 08:39:24 +00:00
|
|
|
minval: 0
|
2017-12-05 16:24:14 +00:00
|
|
|
}
|
|
|
|
skip_trylock_internal_abort {
|
|
|
|
type: INT_32
|
|
|
|
default: 3
|
2021-02-05 08:39:24 +00:00
|
|
|
minval: 0
|
2017-12-05 16:24:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-09 08:57:28 +00:00
|
|
|
|
|
|
|
rtld {
|
|
|
|
nns {
|
|
|
|
type: SIZE_T
|
|
|
|
minval: 1
|
|
|
|
maxval: 16
|
|
|
|
default: 4
|
|
|
|
}
|
2020-06-10 12:40:40 +00:00
|
|
|
optional_static_tls {
|
|
|
|
type: SIZE_T
|
|
|
|
minval: 0
|
|
|
|
default: 512
|
|
|
|
}
|
2024-02-29 19:55:58 +00:00
|
|
|
enable_secure {
|
|
|
|
type: INT_32
|
|
|
|
minval: 0
|
|
|
|
maxval: 1
|
|
|
|
default: 0
|
|
|
|
}
|
2020-06-09 08:57:28 +00:00
|
|
|
}
|
2020-12-21 15:03:03 +00:00
|
|
|
|
|
|
|
mem {
|
|
|
|
tagging {
|
|
|
|
type: INT_32
|
|
|
|
minval: 0
|
|
|
|
maxval: 255
|
|
|
|
}
|
elf: Add glibc.mem.decorate_maps tunable
The PR_SET_VMA_ANON_NAME support is only enabled through a configurable
kernel switch, mainly because assigning a name to a
anonymous virtual memory area might prevent that area from being
merged with adjacent virtual memory areas.
For instance, with the following code:
void *p1 = mmap (NULL,
1024 * 4096,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0);
void *p2 = mmap (p1 + (1024 * 4096),
1024 * 4096,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS,
-1,
0);
The kernel will potentially merge both mappings resulting in only one
segment of size 0x800000. If the segment is names with
PR_SET_VMA_ANON_NAME with different names, it results in two mappings.
Although this will unlikely be an issue for pthread stacks and malloc
arenas (since for pthread stacks the guard page will result in
a PROT_NONE segment, similar to the alignment requirement for the arena
block), it still might prevent the mmap memory allocated for detail
malloc.
There is also another potential scalability issue, where the prctl
requires
to take the mmap global lock which is still not fully fixed in Linux
[1] (for pthread stacks and arenas, it is mitigated by the stack
cached and the arena reuse).
So this patch disables anonymous mapping annotations as default and
add a new tunable, glibc.mem.decorate_maps, can be used to enable
it.
[1] https://lwn.net/Articles/906852/
Checked on x86_64-linux-gnu and aarch64-linux-gnu.
Reviewed-by: DJ Delorie <dj@redhat.com>
2023-11-01 12:56:11 +00:00
|
|
|
decorate_maps {
|
|
|
|
type: INT_32
|
|
|
|
minval: 0
|
|
|
|
maxval: 1
|
|
|
|
}
|
2020-12-21 15:03:03 +00:00
|
|
|
}
|
2021-10-21 13:41:22 +00:00
|
|
|
|
|
|
|
rtld {
|
|
|
|
dynamic_sort {
|
|
|
|
type: INT_32
|
|
|
|
minval: 1
|
|
|
|
maxval: 2
|
2021-12-14 11:37:44 +00:00
|
|
|
default: 2
|
2021-10-21 13:41:22 +00:00
|
|
|
}
|
|
|
|
}
|
gmon: improve mcount overflow handling [BZ# 27576]
When mcount overflows, no gmon.out file is generated, but no message is printed
to the user, leaving the user with no idea why, and thinking maybe there is
some bug - which is how BZ 27576 ended up being logged. Print a message to
stderr in this case so the user knows what is going on.
As a comment in sys/gmon.h acknowledges, the hardcoded MAXARCS value is too
small for some large applications, including the test case in that BZ. Rather
than increase it, add tunables to enable MINARCS and MAXARCS to be overridden
at runtime (glibc.gmon.minarcs and glibc.gmon.maxarcs). So if a user gets the
mcount overflow error, they can try increasing maxarcs (they might need to
increase minarcs too if the heuristic is wrong in their case.)
Note setting minarcs/maxarcs too large can cause monstartup to fail with an
out of memory error. If you set them large enough, it can cause an integer
overflow in calculating the buffer size. I haven't done anything to defend
against that - it would not generally be a security vulnerability, since these
tunables will be ignored in suid/sgid programs (due to the SXID_ERASE default),
and if you can set GLIBC_TUNABLES in the environment of a process, you can take
it over anyway (LD_PRELOAD, LD_LIBRARY_PATH, etc). I thought about modifying
the code of monstartup to defend against integer overflows, but doing so is
complicated, and I realise the existing code is susceptible to them even prior
to this change (e.g. try passing a pathologically large highpc argument to
monstartup), so I decided just to leave that possibility in-place.
Add a test case which demonstrates mcount overflow and the tunables.
Document the new tunables in the manual.
Signed-off-by: Simon Kissane <skissane@gmail.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
2023-02-11 09:12:13 +00:00
|
|
|
|
|
|
|
gmon {
|
|
|
|
minarcs {
|
|
|
|
type: INT_32
|
|
|
|
minval: 50
|
|
|
|
default: 50
|
|
|
|
}
|
|
|
|
maxarcs {
|
|
|
|
type: INT_32
|
|
|
|
minval: 50
|
|
|
|
default: 1048576
|
|
|
|
}
|
|
|
|
}
|
2016-12-31 18:02:17 +00:00
|
|
|
}
|