[PATCH v7 2/4] Add system-wide tunables: cache ld.so.cache
Yury Khrustalev
yury.khrustalev@arm.com
Thu May 28 13:10:22 GMT 2026
On Wed, Feb 21, 2024 at 06:47:53PM -0500, DJ Delorie wrote:
> The purpose of this change is twofold:
>
> 1. The ld.so.cache is cached in memory and only re-read if/when
> it changes on disk. This allows us to have much more intensive
> security checks in the future, without impacting performance as
> much. It also allows for cases where the cache is corrupted -
> we continue using the last valid one.
>
> 2. We break out the load/check logic so that the cache can be
> loaded independently of the library lookup, such as for
> code that only needs to look at the extensions.
>
OK, just 2 small things below.
> ...
>
> diff --git a/elf/Makefile b/elf/Makefile
> index 6b366df91b..5398fe0d2c 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -559,6 +559,7 @@ endif
> tests-container += \
> tst-dlopen-self-container \
> tst-dlopen-tlsmodid-container \
> + tst-ldconfig-cache \
> tst-pldd \
> tst-preload-pthread-libc \
> tst-rootdir \
> @@ -714,6 +715,8 @@ one-hundred = $(foreach x,0 1 2 3 4 5 6 7 8 9, \
> 0$x 1$x 2$x 3$x 4$x 5$x 6$x 7$x 8$x 9$x)
> tst-tls-many-dynamic-modules := \
> $(foreach n,$(one-hundred),tst-tls-manydynamic$(n)mod)
> +tst-ldconfig-cache-modules := \
> + $(foreach n,1 2 3 4 5,tst-tls-manydynamic$(n)mod)
I think tst-ldconfig-cache.out should depend on $(tst-ldconfig-cache-modules)
otherwise this test cannot be executed individually.
>
> ...
>
> diff --git a/elf/dl-cache.c b/elf/dl-cache.c
> index 9458ffae2a..9d5fc05cd6 100644
> --- a/elf/dl-cache.c
> +++ b/elf/dl-cache.c
OK except for...
> + /* At this point, NEW_CACHE_FILE_TIME is valid as well as
> + CACHE_FILE_TIME, so we compare them. */
> + return (memcmp (&new_cache_file_time, &cache_file_time,
> + sizeof(new_cache_file_time)));
> +}
> +
> +/* Attemps to load and validate the cache. On return, CACHE is either
Nit: typo in "Attemps".
>
> ...
>
> diff --git a/elf/tst-ldconfig-cache.c b/elf/tst-ldconfig-cache.c
> new file mode 100644
> index 0000000000..9f71418b3a
> --- /dev/null
> +++ b/elf/tst-ldconfig-cache.c
OK, thanks for adding this test.
>
> ...
>
> diff --git a/elf/tst-ldconfig-cache.root/etc/ld.so.conf b/elf/tst-ldconfig-cache.root/etc/ld.so.conf
> new file mode 100644
> index 0000000000..2b4c2d7817
> --- /dev/null
> +++ b/elf/tst-ldconfig-cache.root/etc/ld.so.conf
OK
> diff --git a/elf/tst-ldconfig-cache.root/ldconfig.req b/elf/tst-ldconfig-cache.root/ldconfig.req
> new file mode 100644
> index 0000000000..e69de29bb2
> diff --git a/elf/tst-ldconfig-cache.root/tst-ldconfig-cache.script b/elf/tst-ldconfig-cache.root/tst-ldconfig-cache.script
> new file mode 100644
> index 0000000000..4f258cac1e
> --- /dev/null
> +++ b/elf/tst-ldconfig-cache.root/tst-ldconfig-cache.script
OK
More information about the Libc-alpha
mailing list