Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Port from 5.0: Fix Position Independent Code in CMake files #28143

Merged
merged 2 commits into from
Jun 5, 2021
Merged

Port from 5.0: Fix Position Independent Code in CMake files #28143

merged 2 commits into from
Jun 5, 2021

Conversation

ivdiazsa
Copy link

@ivdiazsa ivdiazsa commented Feb 11, 2021

Port Description

This is a direct port from PR #26323 in this same repo. This one was added during .NET Core 5.0 development but there is a customer need to also have it in the .NET Core 3.1 release.

In summary, the -pie linker option was missing and while the code was being compiled as Position Independent, the executables weren't, and therefore ASLR was not applied to them. This resulted in them being loaded to fixed addresses, which might potentially open vulnerabilities.

This port also automates the appliance of the -fPIC/-fPIE settings to all targets from a single centralized setting called CMAKE_POSITION_INDEPENDENT_CODE, which allows CMake to apply the appropriate compiler options without further need of manual specification.

Customer Impact

Having these flags enabled provides the built binaries with an additional layer of security, which has become a necessary requirement for some compliance checks, as well as safer applications overall. This port was requested by teams in Azure.

Regression

This was not a regression.

Testing

The checksec tool was used to verify the executables and shared objects had been indeed built with PIE and Full RELRO enabled.

Risk

The risk of this is pretty low, since it's been well tested in the current main branch, as well as .NET 5.0 releases.

@ivdiazsa ivdiazsa requested review from janvorli and mangod9 February 11, 2021 01:02
Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@aik-jahoda
Copy link

@janvorli, @ivdiazsa can we consider it as infrastructure PR or it affect product? If it is infra, feel free to merge it - I will not be available today to do it. If it is product change we need Servicing-approved from tactic and then we can merge.

@mangod9
Copy link
Member

mangod9 commented Feb 12, 2021

Yeah this will need Tactics approval, we will work on that once we have a similar change done in corefx. Thanks

@aik-jahoda
Copy link

Yeah this will need Tactics approval, we will work on that once we have a similar change done in corefx. Thanks

Is there any progress? The branch is open.

@janvorli janvorli added the Servicing-consider Issue for next servicing release review label May 6, 2021
@janvorli janvorli added this to the 3.1.x milestone May 6, 2021
Copy link
Member

@jeffschwMSFT jeffschwMSFT left a comment

Choose a reason for hiding this comment

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

Approved. I will take for consideration in 3.1.x

cc @blowdart and @GrabYourPitchforks

@mangod9
Copy link
Member

mangod9 commented May 6, 2021

FYI, this is fixing this issue: dotnet/runtime#45862

@leecow leecow modified the milestones: 3.1.x, 3.1.17 May 11, 2021
@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels May 11, 2021
@Anipik Anipik merged commit 3d4e15b into dotnet:release/3.1 Jun 5, 2021
hoyosjs pushed a commit to hoyosjs/coreclr that referenced this pull request Jul 14, 2021
…e files (dotnet#28143)

Port from 5.0: Fix Position Independent Code in CMake files (dotnet#28143)

* CoreCLR PR26323 Port: Fix PIE options

* Added missing PIE and RELRO compilation flags.
hoyosjs added a commit that referenced this pull request Jul 14, 2021
* Update branding to 3.1.17 (#28173)

* Port from 5.0: Fix Position Independent Code in CMake files (#28143)

* CoreCLR PR26323 Port: Fix PIE options

* Added missing PIE and RELRO compilation flags.

* Merged PR 15832: Port from 5.0: Fix Position Independent Code in CMake files (#28143)

Port from 5.0: Fix Position Independent Code in CMake files (#28143)

* CoreCLR PR26323 Port: Fix PIE options

* Added missing PIE and RELRO compilation flags.

* Fix System.Globalization.Native build on Big Sur (#28181)

* Fix System.Globalization.Native build on Big Sur

* Fix build

* Add flags for Linux

* [release/3.1] Handle Counter Polling Interval of 0 (#28180)

* Backport  dotnet/runtime#53836

* Fix test build

* update test

Co-authored-by: Jan Jahoda <jajahoda@microsoft.com>
Co-authored-by: Ivan Diaz Sanchez <ivdiazsa@microsoft.com>
Co-authored-by: Will Godbe <wigodbe@microsoft.com>
Co-authored-by: Santiago Fernandez Madero <safern@microsoft.com>
Co-authored-by: John Salem <josalem@microsoft.com>
hoyosjs added a commit that referenced this pull request Aug 11, 2021
* Update branding to 3.1.17 (#28173)

* Port from 5.0: Fix Position Independent Code in CMake files (#28143)

* CoreCLR PR26323 Port: Fix PIE options

* Added missing PIE and RELRO compilation flags.

* Merged PR 15832: Port from 5.0: Fix Position Independent Code in CMake files (#28143)

Port from 5.0: Fix Position Independent Code in CMake files (#28143)

* CoreCLR PR26323 Port: Fix PIE options

* Added missing PIE and RELRO compilation flags.

* Fix System.Globalization.Native build on Big Sur (#28181)

* Fix System.Globalization.Native build on Big Sur

* Fix build

* Add flags for Linux

* [release/3.1] Handle Counter Polling Interval of 0 (#28180)

* Backport  dotnet/runtime#53836

* Fix test build

* update test

* update branding to 3.1.18 (#28182)

* Update dependencies from https://github.com/dotnet/core-setup build 20210609.1 (#28178)

Microsoft.NETCore.App
 From Version 3.1.9-servicing.20459.3 -> To Version 3.1.17-servicing.21309.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Merged PR 15716: [release/3.1] Use user read+write access for coredump file descriptor open

* [release/3.1] #28183 Fix OSX native dependency installation

* Avoid upgrading packages that are explicitly installed.
* Use a brewfile
* Change shebang to use bash and directly execute.

* [release/3.1] Update dependencies from dotnet/corefx (#28179)

[release/3.1] Update dependencies from dotnet/corefx


 - Add 3.1 AzDO feeds to the test build to ensure that the test build can correctly restore the CoreFX build.

It seems that the new CoreFX build isn't on the old blob feeds, so without this fix, we end up restoring the first 5.0.0-alpha.1 build instead of the build we want.

 - Exclude tests that depend on OOB assemblies.

 - Turn off CoreFX test legs in CI.

Now that the branch is on servicing, and the churn is low, exclude these as they
break far more often than they detect issues. These already run in CoreFX CI on release bits.
In case we want to bring them back for checked testing, we need to fix CoreFX.depproj.
It has a package - Microsoft.Private.CoreFx.OOB - that's supposed to bring in all deps
that are out of box. These are currently not getting restored and this ends up causing
File not found issues in the binder when compiling tests, making test exclusions impossible.
Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.

Co-authored-by: Jan Jahoda <jajahoda@microsoft.com>
Co-authored-by: Ivan Diaz Sanchez <ivdiazsa@microsoft.com>
Co-authored-by: Will Godbe <wigodbe@microsoft.com>
Co-authored-by: Santiago Fernandez Madero <safern@microsoft.com>
Co-authored-by: John Salem <josalem@microsoft.com>
Co-authored-by: Anirudh Agnihotry <anirudhagnihotry098@gmail.com>
Co-authored-by: dotnet-bot <dotnet-bot@microsoft.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants