public inbox for cygwin-developers@cygwin.com
 help / color / mirror / Atom feed
From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
To: cygwin-developers@cygwin.com
Subject: Re: About the dll search algorithm of dlopen (patch-r3)
Date: Tue, 30 Aug 2016 16:41:00 -0000	[thread overview]
Message-ID: <57C5B749.4010401@ssi-schaefer.com> (raw)
In-Reply-To: <20160830133508.GE23664@calimero.vinschen.de>

Hi Corinna,

On 08/30/2016 03:35 PM, Corinna Vinschen wrote:
> On Aug 29 11:24, Michael Haubenwallner wrote:
>> On 08/26/2016 02:04 PM, Corinna Vinschen wrote:
>>> On Aug 25 19:48, Michael Haubenwallner wrote:
>>>> On 08/22/2016 08:37 PM, Corinna Vinschen wrote:
>>>>> (*) Yuk!  Do we really, *really* want that?  The redirection from
>>>>>     /usr/lib to /usr/bin is only done for system libs, and only because
>>>>>     otherwise we had trouble starting Cygwin from CMD or the Explorer
>>>>>     GUI "Run..." box.  We can't change this without breaking everything
>>>>>     since we *do* depend on the Windows loader yet.
>>>>>     
>>>>>     However, as long as this is restricted to /usr/lib, /usr/bin, it's a
>>>>>     closed system under control of "the distro".  If you extend this to
>>>>>     *any* external path ending in "lib", isn't it inherently dangerous
>>>>>     to automate this under the hood, without the application's consent?
>>>>>     Or, FWIW, the user's consent in case of LD_LIBRARY_PATH?
>>>>
>>>> 've split into add_lib_searchdir (), used for "/usr/lib" only.
>>>
>>> Btw., I just noticed something interesting, independently of your patch.
>>> Consider the file /usr/bin/cygz.dll:
>>>
>>> - dlopen (libz.so)            success

This one succeeds because of /usr/bin being the fallback path, but ...

>>>
>>> - dlopen (/usr/bin/libz.so)   success
>>>
>>> - dlopen (/usr/lib/libz.so)   fails
>>>
>>> That's pretty clear when looking through the code, but... wouldn't
>>> it make sense to allow that?  If a path is given, and the path points
>>> to /usr/lib, search the file in /usr/bin as well?
>>
>> Easy enough - but this should apply to any prefix IMO: While the
>> application specific prefix often isn't /usr - but something like
>> /usr/local or /opt/application, application specific libs may be
>> built & installed with libtool or something similar as well - at
>> least some tool that knows about installing the real dll into
>> <app-prefix>/bin (because of the missing Cygwin loader).
> 
> You have a point there.

Thanks!

... I forgot about dlopen("libAPP.so") (without path): This I expect
to find <app-prefix>/bin/cygAPP.dll - which is the application dir.

>> But agreed, it makes sense doing /lib->/bin for the explicit path and
>> the /usr/lib default only and not for the environment-provided paths.
> 
> It feels certainly more safe to restrict this to the system path for
> now.  But... yeah, you have a point.
> 
> Not well thought out, just an idea kicking around:
> 
> Apart from the obvious system path handling, what if other lib->bin
> transitions only take place if the calling application is installed
> in that very bin dir...?

Interesting idea - might work indeed! Even for prefix=/usr, to
have consistent behaviour across different application prefixes.

For safety regarding the application dir: If one can write to the
application dir, couldn't one put a malicious kernel32.dll there
as well, and/or an empty application.exe.local for dll redirection?

/haubi/

  reply	other threads:[~2016-08-30 16:41 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-01  6:39 About the dll search algorithm of dlopen Michael Haubenwallner
2016-06-01 11:09 ` Corinna Vinschen
2016-06-01 14:25   ` Michael Haubenwallner
2016-06-01 20:18     ` Corinna Vinschen
2016-06-01 23:29       ` Yaakov Selkowitz
2016-08-19 16:37       ` Michael Haubenwallner
2016-08-19 16:39         ` Michael Haubenwallner
2016-08-20 19:32           ` Corinna Vinschen
2016-08-22 12:15             ` Michael Haubenwallner
2016-08-22 12:48               ` Peter Rosin
2016-08-22 13:01                 ` Michael Haubenwallner
2016-08-22 16:02               ` About the dll search algorithm of dlopen (patch-r2) Michael Haubenwallner
2016-08-22 18:37                 ` Corinna Vinschen
2016-08-23  8:16                   ` Corinna Vinschen
2016-08-25 17:48                   ` About the dll search algorithm of dlopen (patch-r3) Michael Haubenwallner
2016-08-26 10:59                     ` Corinna Vinschen
2016-08-26 11:18                       ` Corinna Vinschen
2016-08-26 11:49                         ` Corinna Vinschen
2016-08-29 16:50                           ` Michael Haubenwallner
2016-08-30 14:51                             ` Corinna Vinschen
2016-08-30 15:57                               ` Michael Haubenwallner
2016-08-31 18:48                                 ` Corinna Vinschen
2016-09-01  8:58                         ` Michael Haubenwallner
2016-08-26 14:08                       ` Michael Haubenwallner
2016-08-30 13:26                         ` Corinna Vinschen
2016-08-26 12:04                     ` Corinna Vinschen
2016-08-29  9:24                       ` Michael Haubenwallner
2016-08-30 13:35                         ` Corinna Vinschen
2016-08-30 16:41                           ` Michael Haubenwallner [this message]
2016-08-31 18:43                             ` Corinna Vinschen
2016-08-22 18:49               ` About the dll search algorithm of dlopen Corinna Vinschen
2016-08-23  8:55                 ` Michael Haubenwallner

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=57C5B749.4010401@ssi-schaefer.com \
    --to=michael.haubenwallner@ssi-schaefer.com \
    --cc=cygwin-developers@cygwin.com \
    /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).