8a8cfb
commit e37c2cf299b61ce18f62852f6c5624c27829b610
8a8cfb
Author: Florian Weimer <fweimer@redhat.com>
8a8cfb
Date:   Thu Oct 31 18:48:43 2019 +0100
8a8cfb
8a8cfb
    Move _dl_open_check to its original place in dl_open_worker
8a8cfb
    
8a8cfb
    This reverts the non-test change from commit d0093c5cefb7f7a4143f
8a8cfb
    ("Call _dl_open_check after relocation [BZ #24259]"), given that
8a8cfb
    the underlying bug has been fixed properly in commit 61b74477fa7f63
8a8cfb
    ("Remove all loaded objects if dlopen fails, ignoring NODELETE
8a8cfb
    [BZ #20839]").
8a8cfb
    
8a8cfb
    Tested on x86-64-linux-gnu, with and without --enable-cet.
8a8cfb
    
8a8cfb
    Change-Id: I995a6cfb89f25d2b0cf5e606428c2a93eb48fc33
8a8cfb
8a8cfb
diff --git a/elf/dl-open.c b/elf/dl-open.c
8a8cfb
index 25838b073ac1edaf..e13968d4d7c4c83f 100644
8a8cfb
--- a/elf/dl-open.c
8a8cfb
+++ b/elf/dl-open.c
8a8cfb
@@ -619,6 +619,8 @@ dl_open_worker (void *a)
8a8cfb
   _dl_debug_state ();
8a8cfb
   LIBC_PROBE (map_complete, 3, args->nsid, r, new);
8a8cfb
 
8a8cfb
+  _dl_open_check (new);
8a8cfb
+
8a8cfb
   /* Print scope information.  */
8a8cfb
   if (__glibc_unlikely (GLRO(dl_debug_mask) & DL_DEBUG_SCOPES))
8a8cfb
     _dl_show_scope (new, 0);
8a8cfb
@@ -699,12 +701,6 @@ dl_open_worker (void *a)
8a8cfb
 	_dl_relocate_object (l, l->l_scope, reloc_mode, 0);
8a8cfb
     }
8a8cfb
 
8a8cfb
-  /* NB: Workaround for [BZ #20839] which doesn't remove the NODELETE
8a8cfb
-     object when _dl_open_check throws an exception.  Move it after
8a8cfb
-     relocation to avoid leaving the NODELETE object mapped without
8a8cfb
-     relocation.  */
8a8cfb
-  _dl_open_check (new);
8a8cfb
-
8a8cfb
   /* This only performs the memory allocations.  The actual update of
8a8cfb
      the scopes happens below, after failure is impossible.  */
8a8cfb
   resize_scopes (new);