-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libc.so.6 in project directory causes major problems #42851
Comments
Why does the compile dlopen() anything from the source tree ? |
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. |
Do you have |
It's not clear to me why the assumption is that this is coming from a |
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... |
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 |
What does the output of |
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 |
I do not see this behavior with a stock x86_64-unknown-linux-gnu 1.18 release, for reference.
|
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 ? |
What about nightly cargo ? |
And some output filtered to
So it looks reproducible at least with rustup on nightly. |
@sfackler could you paste entire output of LD_DEBUG=libs with and without libc.so.6 in project root directory ? |
@jmesmon thank you, I was starting to think I was losing my mind ;) I'm sure it's a nightly issue now (cannot repro on stable) and that someone (cargo I'm looking at you since the variable mysteriously appears after control is transferred to the one in rustup directory) is setting the env variable |
Ok yeah it does look like nightly cargo is messing this up:
|
Sorry I don't really understand anything here, not sure how much help I'll be |
@alexcrichton the root of the issue is that cargo's started producing a weird LD_LIBRARY_PATH:
This in particular includes `` (i.e. the current directory), as well as |
In contrast, stable Cargo produces this LD_LIBRARY_PATH:
The fact that those |
I believe the tls and x86_64 |
Oh, weird! |
This is also present on beta |
@Mark-Simulacrum can you bisect cargo prs? |
I've "bisected" the change to #41978 , which did this update of cargo, which seems to confirm @mbrubeck 's suspicion. |
Note that when running without rustup, I can't reproduce the bug. |
Submitted PR rust-lang/cargo#4278. |
Should be fixed on current beta. Can anyone confirm? |
👍 Fixed for me! Great work! |
Steps to repro:
cp
alibc.so.6
to your project directorycargo 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).Original issue: das-labor/panopticon#304
The text was updated successfully, but these errors were encountered: