[2/8] elf: Verify the tunable cache header signature and version

Message ID 20260706211524.3801466-3-adhemerval.zanella@linaro.org (mailing list archive)
State Committed
Commit 4e971f555850f856e70ceb05d963baa9e0a455a4
Headers
Series Fixes for the system-wide tunables support |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Adhemerval Zanella Netto July 6, 2026, 9:14 p.m. UTC
  The tunable header signature and version are written by ldconfig but
never checked them on read, so the version field was inert.  Reject
the section unless both match.

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 elf/dl-cache.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

DJ Delorie July 9, 2026, 2:04 a.m. UTC | #1
Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> +  /* Reject data produced by a different tunable cache format.  */
> +  if (thc->signature != TUNCONF_SIGNATURE || thc->version != TUNCONF_VERSION)
> +    return NULL;

In the future, we'll have to handle multiple versions, but this works
for now.

LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
  

Patch

diff --git a/elf/dl-cache.c b/elf/dl-cache.c
index 5d8d3cae908..498196d0aa3 100644
--- a/elf/dl-cache.c
+++ b/elf/dl-cache.c
@@ -642,6 +642,11 @@  _dl_load_cache_tunables (const char **data)
 
   thc = (struct tunable_header_cached *)
     ext.sections[cache_extension_tag_tunables].base;
+
+  /* Reject data produced by a different tunable cache format.  */
+  if (thc->signature != TUNCONF_SIGNATURE || thc->version != TUNCONF_VERSION)
+    return NULL;
+
   tec = thc->tunables;
   count = thc->num_tunables;