about summary refs log tree commit diff
path: root/elf/rtld.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-11-02 21:55:35 +0100
committerFlorian Weimer <fweimer@redhat.com>2019-11-15 13:03:32 +0100
commitc7bf5ceab6ec776ac7350d3b0190776bf532ac54 (patch)
tree0a55d917ee9439e22eb1242fb1b13f935e2b45e3 /elf/rtld.c
parentc9bf28d625ad1533935d40ae94b15453d0c98508 (diff)
downloadglibc-c7bf5ceab6ec776ac7350d3b0190776bf532ac54.tar.gz
glibc-c7bf5ceab6ec776ac7350d3b0190776bf532ac54.tar.xz
glibc-c7bf5ceab6ec776ac7350d3b0190776bf532ac54.zip
Properly initialize audit cookie for the dynamic loader [BZ #25157]
The l_audit array is indexed by audit module, not audit function.

Change-Id: I180eb3573dc1c57433750f5d8cb18271460ba5f2
Diffstat (limited to 'elf/rtld.c')
-rw-r--r--elf/rtld.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index 8a6e1a11b2..d54a7965b4 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1008,13 +1008,7 @@ ERROR: audit interface '%s' requires version %d (maximum supported version %d);
 
       /* Store the pointer.  */
       if (err_str == NULL && largs.result != NULL)
-	{
-	  newp->fptr[cnt] = largs.result;
-
-	  /* The dynamic linker link map is statically allocated,
-	     initialize the data now.  */
-	  GL(dl_rtld_map).l_audit[cnt].cookie = (intptr_t) &GL(dl_rtld_map);
-	}
+	newp->fptr[cnt] = largs.result;
       else
 	newp->fptr[cnt] = NULL;
       ++cnt;
@@ -1030,6 +1024,12 @@ ERROR: audit interface '%s' requires version %d (maximum supported version %d);
     *last_audit = GLRO(dl_audit) = &newp->ifaces;
   else
     *last_audit = (*last_audit)->next = &newp->ifaces;
+
+  /* The dynamic linker link map is statically allocated, initialize
+     the data now.  */
+  GL (dl_rtld_map).l_audit[GLRO (dl_naudit)].cookie
+    = (intptr_t) &GL (dl_rtld_map);
+
   ++GLRO(dl_naudit);
 
   /* Mark the DSO as being used for auditing.  */