ldd secure execution mode
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Hello,
I noticed that ldd gives wrong results when run
a) with the LD_LIBRARY_PATH environment variable set to some folder and
b) on a binary that will be launched in "secure execution mode" by ld.so (see "man ld.so").
Steps to reproduce:
1. Create a file hello_world.c:
#include <stdio.h>
int main() {
puts("Hello, World!");
puts("Press enter to quit");
scanf("%*c");
}
2. Compile:
$ gcc -o hello_world hello_world.c
3. Attach a capability to the compiled binary, in order to trigger secure execution mode:
$ sudo setcap CAP_NET_
4. Make the system's libc available somewhere else:
$ cp /lib/x86_
In this setup, when you run LD_LIBRARY_PATH=. ldd hello_world, then ldd will report that the binary will use the libc in the local folder.
Actual output:
$ LD_LIBRARY_PATH=. ldd hello_world
linux-vdso.so.1 => (0x00007ffdbb76
libc.so.6 => ./libc.so.6 (0x00007f68a182
/lib64/
However, when you actually run the binary with
$ LD_LIBRARY_PATH=. ./hello_world
then the binary will use the standard library search path and _not_ use ./libc.so.6 .
You can see this by starting the binary in one terminal, and running the following command in another terminal while the binary is still running:
$ sudo cat /proc/$(pidof hello_world)/maps
This gives me an output like:
[...]
7f76193d5000-
7f7619595000-
7f7619795000-
7f7619799000-
[...]
I believe that this is due to the secure execution mode mentioned in the ld.so man page, so this probably also affects set-uid binaries and possibly some other environment variables that control the linker behaviour.
I'm using Ubuntu 16.04.2 (LTS). ldd is on version "ldd (Ubuntu GLIBC 2.23-0ubuntu9) 2.23". The libc-bin package (containing ldd) has version "2.23-0ubuntu9".
Best regards!
affects: | ubuntu → glibc (Ubuntu) |
Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https:/ /wiki.ubuntu. com/Bugs/ FindRightPackag e. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.
To change the source package that this bug is filed about visit https:/ /bugs.launchpad .net/ubuntu/ +bug/1700272/ +editstatus and add the package name in the text box next to the word Package.
[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]