Closed
Description
rustc --version
rustc 1.19.0-nightly (fe7227f6c 2017-06-16)
cargo --version
cargo 0.20.0-nightly (bbfe9b3a9 2017-06-05)
Steps to repro:
cp
alibc.so.6
to your project directory- run
cargo test
orcargo build
This might require an older libc.so.6, or something; looks like something is trying dlopen
the version in my directory (also, why?), and the ABI is bad for whatever reason (just guessing).
m4b@efrit :: [ ~/git/panopticon ] cp libc.so.6 ~/projects/scroll
m4b@efrit :: [ ~/git/panopticon ] cd
m4b@efrit :: [ ~ ] cd projects/scroll
m4b@efrit :: [ ~/projects/scroll ] cargo test
Compiling scroll v0.6.0 (file:///home/m4b/projects/scroll)
rustc: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument
error: Could not compile `scroll`.
Build failed, waiting for other jobs to finish...
rustc: error while loading shared libraries: __vdso_time: invalid mode for dlopen(): Invalid argument
error: Could not compile `scroll`.
To learn more, run the command again with --verbose.
Original issue: das-labor/panopticon#304
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
metux commentedon Jul 12, 2017
Why does the compile dlopen() anything from the source tree ?
And why does anything dlopen() libc ?
m4b commentedon Jul 12, 2017
I had similar questions 😆
I wonder if I could ship a libc in a crates.io crate with a rewritten stub to the function it's trying to open to do random stuff on some users computer.
sfackler commentedon Jul 12, 2017
Do you have
.
in yourLD_LIBRARY_PATH
?sfackler commentedon Jul 12, 2017
It's not clear to me why the assumption is that this is coming from a
dlopen
call. Why couldn't it beld.so
? You can try settingLD_DEBUG=all
to have the dynamic linker print out info about what it's doing.m4b commentedon Jul 12, 2017
No I do not have "." in my LD_LIBRARY.
To make this even easier, please copy your libc.so.6 to some new cargo project, open this new libc in your favorite hex editor, zero out the elf header, run cargo clean followed by cargo build and it will report that libc.so.6 has an invalid header...
m4b commentedon Jul 12, 2017
I believe in this case it was assumed that dlopen was called because in the original report dlopen is explicitly mentioned as having a bad argument by rustc.
Of course it may be some side effect, etc. But on two separate machines I can repro this fairly worrisome issue (e.g. Local libc used without messing with LD env variables), which suggests that dlopen is used
sfackler commentedon Jul 12, 2017
What does the output of
cargo clean && env LD_DEBUG=libs cargo build
say?m4b commentedon Jul 12, 2017
Ah I'm pretty sure this is caused by rustc using RPATH in dynamic array.
Also I think this might be a security vulnerability
EDIT:
Actually not sure. Except that it's a problem
sfackler commentedon Jul 12, 2017
I do not see this behavior with a stock x86_64-unknown-linux-gnu 1.18 release, for reference.
m4b commentedon Jul 12, 2017
Something is setting LD path and it is not me. I believe it is cargo. Running strings on cargo shows that LD_LIB env variable is in the binary, and briefly grepping through source shows that it does collect a set of env variables, and LD_LIB is amongst them, which is even more worrisome.
Unfortunately not in front of a computer at the moment, so can't paste output but someone sets LD variable to the rustup nightly toolchain (amongst other things)
@sfackler are you not able to repro this ?
m4b commentedon Jul 12, 2017
What about nightly cargo ?
codyps commentedon Jul 12, 2017
And some output filtered to
libc.so
mentions:So it looks reproducible at least with rustup on nightly.
m4b commentedon Jul 12, 2017
@sfackler could you paste entire output of LD_DEBUG=libs with and without libc.so.6 in project root directory ?
25 remaining items