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

Enable -pie and -z,relro,-z,now for NativeAOT binaries #1739

Merged
merged 1 commit into from
Nov 20, 2021

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Nov 20, 2021

Fixes binskim warning BA3001 and BA3011

Contributes to dotnet/runtime#96848

@jkotas jkotas changed the title Enable -z,relro,-z,now for NativeAOT binaries Enable -pie and -z,relro,-z,now for NativeAOT binaries Nov 20, 2021
Fixes binskim warning BA3001 and BA3011

Contributes to #1738
Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

Thank you!

@MichalStrehovsky MichalStrehovsky merged commit 96b0d17 into dotnet:feature/NativeAOT Nov 20, 2021
@StephanDollberg
Copy link

Hi, any way to disable these options?

Other things might not work with pie binaries so wondering whether I can disable those linker options?

@jkotas jkotas deleted the relro branch January 30, 2022 18:41
@jkotas
Copy link
Member Author

jkotas commented Jan 30, 2022

I do think there is an easy way to suppress this option today. We would be happy to accept a PR to add PositionIndependentExecutable msbuild property that you can set to false to suppress this option. (This PR should be submitted to dotnet/runtime repo.)

@StephanDollberg
Copy link

I do think there

I assume you are missing a "not" there?

@jkotas
Copy link
Member Author

jkotas commented Jan 30, 2022

Yes, of course...

@StephanDollberg
Copy link

https://github.com/dotnet/runtime/compare/main...StephanDollberg:stephandollberg/PositionIndependentExecutable-flag?expand=1

Does this match what you were thinking of?

Unfortunately I am failing to make my project work with the local build of nativeaot so can't really test it.

@jkotas
Copy link
Member Author

jkotas commented Jan 31, 2022

I think this can be just one-line change for the -pie command line option, like:

<LinkerArg Include="-pie" Condition="'$(TargetOS)' != 'OSX' and '$(NativeLib)' == '' and '$(PositionIndependentExecutable)' != 'false'" />

Do you really need to control the other command line options too? If yes, the msbuild property should have different name.

@StephanDollberg
Copy link

I guess not but I feel like they all belong together hence why I included them all.

Happy to only do pie if you prefer that.

@jkotas
Copy link
Member Author

jkotas commented Jan 31, 2022

All of these options are related to security hardening of the final binary. We strongly prefer .NET (and NativeAOT in particular) to have security hardening enabled if possible. So it is preferable to just omit the one option that is causing problems.

@StephanDollberg
Copy link

Yeah sure, have created dotnet/runtime#64580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants