This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Compatibility symlink from old dynamic loader name to new dynamicloader name doesn't work.


On Wed, Oct 24, 2012 at 3:16 PM, Carlos O'Donell
<carlos@systemhalted.org> wrote:
> On Wed, Oct 24, 2012 at 1:16 PM, Roland McGrath <roland@hack.frob.com> wrote:
>> The patch is clearly a dismal kludge that would never be acceptable.
>>
>> I don't understand why the stat-based logic at the top of
>> _dl_map_object_from_fd is not handling this case already.
>
> There are a couple of filename checks in _dl_map_object, but the files
> names aren't the same name:
> ~~~ e.g.
>           soname = ((const char *) D_PTR (l, l_info[DT_STRTAB])
>                     + l->l_info[DT_SONAME]->d_un.d_val);
>           if (strcmp (name, soname) != 0)
>             continue;
> ~~~
>
> Then in _dl_map_object_from_fd we check only that the inodes are the
> same, which isn't true for a symlink.
> ~~~ e.g.
>   /* Look again to see if the real name matched another already loaded.  */
>   for (l = GL(dl_ns)[nsid]._ns_loaded; l; l = l->l_next)
>     if (l->l_removed == 0 && l->l_ino == st.st_ino && l->l_dev == st.st_dev)
> ...
> #ifdef SHARED
>   /* When loading into a namespace other than the base one we must
>      avoid loading ld.so since there can only be one copy.  Ever.  */
>   if (__builtin_expect (nsid != LM_ID_BASE, 0)
>       && ((st.st_ino == GL(dl_rtld_map).l_ino
>            && st.st_dev == GL(dl_rtld_map).l_dev)
>           || _dl_name_match_p (name, &GL(dl_rtld_map))))
> ...
> ~~~
>
> The code probably works for a hardlink.
>
> It seems rather sloppy that your choice of hardlink vs. symlink can
> break things.
>
>>> In summary:
>>> - To support compatibility symlinks from old dynamic loader names to new
>>> dynamic loader names will require refactoring _dl_map_object_from_fd to
>>> actually detect if two DSOs are the same.
>>
>> That's exactly what it already does.
>
> Unfortunately I don't see how without following the symlink, which it
> doesn't do.

For avoidance of doubt I am definately *not* suggesting following symlinks.

My suggestion is simply that if the names aren't the same, and the inodes
aren't the same, then we need to:

(a) Load up enough to read the SONAME
(b) Check again if we already have this loaded and skip loading if we do.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]