Bug 7064 - Caching _dl_library_path is invalid
Summary: Caching _dl_library_path is invalid
Status: NEW
Alias: None
Product: uClibc
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: unspecified
Hardware: Other Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-28 07:02 UTC by Aleksander Wabik
Modified: 2014-04-28 07:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments
The workaround patch that makes things work correctly, although may be suboptimal solution (671 bytes, application/octet-stream)
2014-04-28 07:02 UTC, Aleksander Wabik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksander Wabik 2014-04-28 07:02:59 UTC
Created attachment 5372 [details]
The workaround patch that makes things work correctly, although may be suboptimal solution

uClibc caches LD_LIBRARY_PATH env variable value in _dl_library_path, causing two bugs:

1. Caching the pointer obtained from getenv() is forbidden, as the application may change the environment afterwards, rendering the pointer invalid. In our case the application is modifying the environ global variable by calling setproctitle() (a function not present in uClibc, but provided by other library), and then the cached _dl_library_path in uClibc contains program's command line instead of the LD_LIBRARY_PATH value.

2. Caching such an env variable in any correct way which fixes problem 1 (eg. by doing strdup()) is non-spec anyway, and should not be done. The application may modify LD_LIBRARY_PATH and call dlopen() afterwards. It should cause reading the modified LD_LIBRARY_PATH instead of using the cached value.

We currently use a workaround in libdl.c (see attachment), but a correct fix would be to make _dl_library_path variable local.