Skip to content
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

Parts of libcompiler-rt are compiled as WX #34482

Closed
djc opened this issue Jun 26, 2016 · 6 comments
Closed

Parts of libcompiler-rt are compiled as WX #34482

djc opened this issue Jun 26, 2016 · 6 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@djc
Copy link
Contributor

djc commented Jun 26, 2016

The following parts have WX sections (that is, memory that is writable and executable at the same time):

 * !WX --- --- usr/lib64/rust-1.9.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler-rt.a:chkstk.o
 * !WX --- --- usr/lib64/rust-1.9.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler-rt.a:chkstk2.o
 * !WX --- --- usr/lib64/rust-1.9.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler-rt.a:floatundidf.o
 * !WX --- --- usr/lib64/rust-1.9.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler-rt.a:floatundisf.o
 * !WX --- --- usr/lib64/rust-1.9.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler-rt.a:floatundixf.o

From a security point of view, this is probably bad.

@trofi
Copy link

trofi commented Jun 26, 2016

llikley proper upstream is llvm:
https://github.com/llvm-mirror/compiler-rt/blob/master/lib/builtins/x86_64/chkstk2.S

I suspect it lacks GNU stack marking. Example marking from libffi:
https://github.com/libffi/libffi/blob/master/src/x86/sysv.S#L1038

@Aatch
Copy link
Contributor

Aatch commented Jun 27, 2016

Hard to tell if it's an oversight or not from the code. There's a macro that outputs the stack marking if needed, which is used in other files. Either way, this is an upstream issue as it's in compiler-rt.

@Amanieu
Copy link
Member

Amanieu commented Jun 27, 2016

This seems to have been fixed upstream very recently: llvm-mirror/compiler-rt@4c71a47

@brson brson added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-wrong labels Jun 27, 2016
@alexcrichton
Copy link
Member

If this has been fixed upstream, then that's great! The steps for fixing this would then look like:

  • Check out the most recent branch of compiler-rt that we're using, which I believe is rust-lang/compiler-rt at the branch rust-2016-06-16
  • Cherry-pick the relevant commit to the branch
  • Send a PR to the rust-lang/compiler-rt repo on the rust-2016-06-16 branch
  • Once merged, send a PR to rust-lang/rust updating the compiler-rt repo
  • Ideally write a test as well, but may be somewhat difficult to do that for this...

I'm gonna tag this as E-easy and I'm certainly willing to mentor, if anyone needs any help just let me know!

@alexcrichton alexcrichton added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Jul 1, 2016
@apasel422
Copy link
Contributor

Closed in #34647.

@djc
Copy link
Contributor Author

djc commented Dec 27, 2016

It seems like this has regressed in 1.14.0:

 * !WX --- --- usr/lib64/rust-1.14.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f5a209a9.rlib:chkstk.o
 * !WX --- --- usr/lib64/rust-1.14.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f5a209a9.rlib:chkstk2.o
 * !WX --- --- usr/lib64/rust-1.14.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f5a209a9.rlib:floatundidf.o
 * !WX --- --- usr/lib64/rust-1.14.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f5a209a9.rlib:floatundisf.o
 * !WX --- --- usr/lib64/rust-1.14.0/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-f5a209a9.rlib:floatundixf.o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

No branches or pull requests

7 participants