public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Christian Häggström (Code Review)" <gerrit@gnutoolchain-gerrit.osci.io>
To: Florian Weimer <fweimer@redhat.com>,
	Florian Weimer <fw@deneb.enyo.de>,
	libc-alpha@sourceware.org
Subject: [review v2] Remove all loaded objects if dlopen fails, ignoring NODELETE [BZ #20839]
Date: Wed, 13 Nov 2019 14:28:00 -0000	[thread overview]
Message-ID: <20191113142805.9A5CD20AF6@gnutoolchain-gerrit.osci.io> (raw)
In-Reply-To: <gerrit.1572549639000.Ib2a3d86af6f92d75baca65431d74783ee0dbc292@gnutoolchain-gerrit.osci.io>

Christian Häggström has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/471
......................................................................


Patch Set 2: Code-Review+1

(3 comments)

| --- elf/dl-lookup.c
| +++ elf/dl-lookup.c
| @@ -315,6 +315,17 @@ #define INITIAL_NUNIQUE_SYM_TABLE 31
| -	   setting the appropriate flag.  */
| -	((struct link_map *) map)->l_flags_1 |= DF_1_NODELETE;
| +	{
| +	  /* Make sure we don't unload this object by
| +	     setting the appropriate flag.  */
| +	  if (__glibc_unlikely (GLRO (dl_debug_mask) & DL_DEBUG_BINDINGS)
| +	      && map->l_nodelete == link_map_nodelete_inactive)
| +	    _dl_debug_printf ("\
| +marking %s [%lu] as NODELETE due to unique symbol\n",
| +			      map->l_name, map->l_ns);

PS1, Line 322:

Yes, I mean to wrap both the if statement and _dl_debug_printf in a
macro. But I agree it is a separate cleanup. Marking as resolved.

| +	  if (flags & DL_LOOKUP_FOR_RELOCATE)
| +	    map->l_nodelete = link_map_nodelete_pending;
| +	  else
| +	    map->l_nodelete = link_map_nodelete_active;
| +	}
|      }
|    ++tab->n_elements;
|  
|  #ifdef SHARED
| --- include/link.h
| +++ include/link.h
| @@ -82,7 +85,19 @@ enum link_map_nodelete
| + /* This link map can be deallocated.  */
| + link_map_nodelete_inactive,
| +
| + /* This link map cannot be deallocated.  */
| + link_map_nodelete_active,
| +
| + /* This link map cannot be deallocated after dlopen has succeded.
| +    dlopen turns this into link_map_nodelete_active.  dlclose treats
| +    this intermediate state as link_map_nodelete_active.  */
| + link_map_nodelete_pending,

PS1, Line 94:

Ok, leave it in lowercase and we can make a separate patch changing
all existing constants to caps. Resolving thread.

| +};
| +
|  
|  /* Structure describing a loaded shared object.  The `l_next' and `l_prev'
|     members form a chain of all the shared objects loaded at startup.
|  
|     These data structures exist in space used by the run-time dynamic linker;
|     modifying them may have disastrous results.
|  

 ...

| @@ -199,15 +214,19 @@ struct link_map
|  						 during LD_TRACE_PRELINKING=1
|  						 contains any DT_SYMBOLIC
|  						 libraries.  */
|      unsigned int l_free_initfini:1; /* Nonzero if l_initfini can be
|  				       freed, ie. not allocated with
|  				       the dummy malloc in ld.so.  */
|  
| +    /* Actually of type enum link_map_nodelete.  Separate byte due to
| +       concurrent access.  Only valid for l_type == lt_loaded.  */
| +    unsigned char l_nodelete;

PS1, Line 223:

Uh, reads to concurrent variables with unspecified memory ordering is
a ticking bomb as the compilers gets smarter. But that's a separate
issue. Glad you have updated the comment.

Thanks for commenting the initializer value. Marking resolved.

| +
|  #include <link_map.h>
|  
|      /* Collected information about own RPATH directories.  */
|      struct r_search_path_struct l_rpath_dirs;
|  
|      /* Collected results of relocation while profiling.  */
|      struct reloc_result
|      {

-- 
Gerrit-Project: glibc
Gerrit-Branch: master
Gerrit-Change-Id: Ib2a3d86af6f92d75baca65431d74783ee0dbc292
Gerrit-Change-Number: 471
Gerrit-PatchSet: 2
Gerrit-Owner: Florian Weimer <fweimer@redhat.com>
Gerrit-Reviewer: Christian Häggström <gnugerrit@kalvdans.no-ip.org>
Gerrit-Reviewer: Florian Weimer <fweimer@redhat.com>
Gerrit-Comment-Date: Wed, 13 Nov 2019 14:28:05 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Florian Weimer <fweimer@redhat.com>
Comment-In-Reply-To: Christian Häggström <gnugerrit@kalvdans.no-ip.org>
Gerrit-MessageType: comment

  parent reply	other threads:[~2019-11-13 14:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-31 19:21 [review] " Florian Weimer (Code Review)
2019-10-31 20:18 ` Christian Häggström (Code Review)
2019-11-13 12:56 ` [review v2] " Florian Weimer (Code Review)
2019-11-13 14:28 ` Christian Häggström (Code Review) [this message]
2019-11-15 16:02 ` [review v3] " Florian Weimer (Code Review)
2019-12-02 16:07   ` Florian Weimer
2019-12-02 16:53     ` Carlos O'Donell
2019-11-21 12:57 ` Carlos O'Donell (Code Review)
2019-11-27 20:31 ` [pushed] " Sourceware to Gerrit sync (Code Review)
2019-12-02 10:07   ` Szabolcs Nagy
2019-12-02 12:17     ` Florian Weimer
2019-12-02 13:52       ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191113142805.9A5CD20AF6@gnutoolchain-gerrit.osci.io \
    --to=gerrit@gnutoolchain-gerrit.osci.io \
    --cc=fw@deneb.enyo.de \
    --cc=fweimer@redhat.com \
    --cc=gnutoolchain-gerrit@osci.io \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).