]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Fix UB on _dl_map_object_from_fd
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 7 May 2025 14:17:29 +0000 (11:17 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 2 Jun 2025 16:32:19 +0000 (13:32 -0300)
On 32-bit architecture ubsan triggers:

UBSAN: Undefined behaviour in dl-load.c:1345:54 pointer index expression with base 0x00612508 overflowed  to 0xf7c3a508

Use explicit uintptr_t operation instead.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
elf/dl-load.c

index bf29ec725d57adb960f4690f23281aa33e33ca26..6e26ef05837004e4d3f7e9b268aa7b92d9f5c7fc 100644 (file)
@@ -1340,7 +1340,7 @@ cannot enable executable stack as shared object requires");
 
   /* Adjust the address of the TLS initialization image.  */
   if (l->l_tls_initimage != NULL)
-    l->l_tls_initimage = (char *) l->l_tls_initimage + l->l_addr;
+    l->l_tls_initimage = (void*)((uintptr_t)l->l_tls_initimage + l->l_addr);
 
   /* Process program headers again after load segments are mapped in
      case processing requires accessing those segments.  Scan program