00c0d4
commit 3ad5dab476205d6e16156cf0511fa6884b3b0fc4
00c0d4
Author: Florian Weimer <fweimer@redhat.com>
00c0d4
Date:   Tue Jul 7 09:58:45 2020 +0200
00c0d4
00c0d4
    elf: Do not signal LA_ACT_CONSISTENT for an empty namespace [BZ #26076]
00c0d4
    
00c0d4
    The auditing interface identifies namespaces by their first loaded
00c0d4
    module.  Once the namespace is empty, it is no longer possible to signal
00c0d4
    LA_ACT_CONSISTENT for it because the first loaded module is already gone
00c0d4
    at that point.
00c0d4
    
00c0d4
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
00c0d4
00c0d4
diff --git a/elf/dl-close.c b/elf/dl-close.c
00c0d4
index 7fe91bdd9aaf694e..698bda929c0eab6c 100644
00c0d4
--- a/elf/dl-close.c
00c0d4
+++ b/elf/dl-close.c
00c0d4
@@ -795,8 +795,14 @@ _dl_close_worker (struct link_map *map, bool force)
00c0d4
   if (__glibc_unlikely (do_audit))
00c0d4
     {
00c0d4
       struct link_map *head = ns->_ns_loaded;
00c0d4
-      /* Do not call the functions for any auditing object.  */
00c0d4
-      if (head->l_auditing == 0)
00c0d4
+      /* If head is NULL, the namespace has become empty, and the
00c0d4
+	 audit interface does not give us a way to signal
00c0d4
+	 LA_ACT_CONSISTENT for it because the first loaded module is
00c0d4
+	 used to identify the namespace.
00c0d4
+
00c0d4
+	 Furthermore, do not notify auditors of the cleanup of a
00c0d4
+	 failed audit module loading attempt.  */
00c0d4
+      if (head != NULL && head->l_auditing == 0)
00c0d4
 	{
00c0d4
 	  struct audit_ifaces *afct = GLRO(dl_audit);
00c0d4
 	  for (unsigned int cnt = 0; cnt < GLRO(dl_naudit); ++cnt)