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

Mark stack as non-executable #43481

Merged
merged 1 commit into from
Feb 22, 2022
Merged

Mark stack as non-executable #43481

merged 1 commit into from
Feb 22, 2022

Conversation

nalimilan
Copy link
Member

The linker is unable to detect that executable stack is not required and so marks libjulia.so as requiring it
Pass -Wl,-z,noexecstack to ensure that the stack is marked as not executable.
This improves security and allows Julia to run on systems where SELinux has been configured to disallow executable stacks.

AFAIK no change is needed on OSes other than Linux as they do not allow executable stacks by default.

Tests will fail until JuliaLinearAlgebra/libblastrampoline#51 is merged and libblatrampoline is updated, as libblastrampoline.so is also affected by the same problem.

@nalimilan nalimilan added building Build system, or building Julia or its dependencies security System security concerns and vulnerabilities labels Dec 19, 2021
Comment on lines +63 to +65
for f in intersect(dllist(),
[readdir(joinpath(Sys.BINDIR, Base.LIBDIR), join=true);
readdir(joinpath(Sys.BINDIR, Base.LIBDIR, "julia"), join=true)])
Copy link
Member Author

@nalimilan nalimilan Dec 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this check is too cautious as it shouldn't have passed on 64-bit Linux until the blastrampoline PR is merged. Maybe the paths are different so the intersection ends up being empty?

We could just use dllist(), the risk that a system library we link to would have executable stack enabled is quite low. The other approach would be to just keep the readdir part, but I figured it could be annoying as unused outdated libjulia.so.1.X can be in these directories (I had some), which would make tests fail and require manual removal (which is hard to find out).

@inkydragon
Copy link
Member

By default, many dependencies are built by directly downloading the compiled binaries of BinaryBuilder.jl.

When compiled the first time, the build will automatically download pre-built external dependencies.

—— julia/build.md at master · JuliaLang/julia

For example: All dependencies in the deps\checksums folder

Should we update the BinaryBuilder build settings for julia-related dependencies?
e.g: SuiteSparse · JuliaPackaging/Yggdrasil

Is this link parameter necessary as a default setting for the global build of BinaryBuilder?

@nalimilan
Copy link
Member Author

No it shouldn't be needed in general, it's only for some libraries (here libjulia.so and libblastrampoline.so) for which the linker wasn't able to detect that they don't need an executable stack.

@ViralBShah
Copy link
Member

The LBT PR referred to is merged and pulled in here. Just wondering if the next step is to revive this.

@nalimilan
Copy link
Member Author

Julia is still using an old libblastrampoline AFAICT, while we need at least version 4.

@staticfloat Is there any reason not to update it?

@ViralBShah
Copy link
Member

We are on version 5 of LBT. blastrampoline.version was behind and that was just fixed in #44258

@nalimilan nalimilan closed this Feb 20, 2022
@nalimilan nalimilan reopened this Feb 20, 2022
@nalimilan nalimilan marked this pull request as ready for review February 20, 2022 10:17
@nalimilan
Copy link
Member Author

OK, should be good to merge now.

@nalimilan nalimilan requested a review from ViralBShah February 21, 2022 08:15
@ViralBShah
Copy link
Member

ViralBShah commented Feb 21, 2022

I don't have much experience with this linker flag, but it seems that tests are passing everywhere. Maybe good to see if @staticfloat and/or @giordano can take a look.

Copy link
Contributor

@giordano giordano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not very expert on this flag, but the change looks good as far as I can tell.

test/osutils.jl Show resolved Hide resolved
The linker is unable to detect that executable stack is not required
and so marks libjulia.so as requiring it
Pass `-Wl,-z,noexecstack` to ensure that the stack is marked as not executable.
This improves security and allows Julia to run on systems where SELinux has been
configured to disallow executable stacks.

AFAIK no change is needed on OSes other than Linux as they do not allow executable stacks
by default.
@ViralBShah ViralBShah merged commit 01855a7 into master Feb 22, 2022
@ViralBShah ViralBShah deleted the nl/execstack branch February 22, 2022 03:35
staticfloat pushed a commit to JuliaCI/julia-buildkite-testing that referenced this pull request Mar 2, 2022
The linker is unable to detect that executable stack is not required
and so marks libjulia.so as requiring it
Pass `-Wl,-z,noexecstack` to ensure that the stack is marked as not executable.
This improves security and allows Julia to run on systems where SELinux has been
configured to disallow executable stacks.

AFAIK no change is needed on OSes other than Linux as they do not allow executable stacks
by default.
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
The linker is unable to detect that executable stack is not required
and so marks libjulia.so as requiring it
Pass `-Wl,-z,noexecstack` to ensure that the stack is marked as not executable.
This improves security and allows Julia to run on systems where SELinux has been
configured to disallow executable stacks.

AFAIK no change is needed on OSes other than Linux as they do not allow executable stacks
by default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
building Build system, or building Julia or its dependencies security System security concerns and vulnerabilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants