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