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

Fix loading of NI images on SELinux #4604

Merged
merged 1 commit into from
Apr 27, 2016

Conversation

janvorli
Copy link
Member

This change fixes a problem that prevents us to load crossgen-ed managed
assemblies on SELinux when running in confined mode.
The problem was that when we load these images, we also apply relocations
to their sections and so we temporarily switch section protection from
RX to RW and then back. And the switching back (RW -> RX) is something
that SELinux doesn't allow.
The fix is to switch to RWX before applying to relocations for sections
that are RX, since it is allowed then to switch them back to RX.
One more change was needed to get the original protection of the section
before relocation so that we can set it back later. The PE files are
not mapped using VirtualXXXX functions in the PAL and so VirtualProtect
doesn't return the proper original protection, but a fixed value instead.
So for PAL, we derive the original protection from the section attributes.

This change fixes a problem that prevents us to load crossgen-ed managed
assemblies on SELinux when running in confined mode.
The problem was that when we load these images, we also apply relocations
to their sections and so we temporarily switch section protection from
RX to RW and then back. And the switching back (RW -> RX) is something
that SELinux doesn't allow.
The fix is to switch to RWX before applying to relocations for sections
that are RX, since it is allowed then to switch them back to RX.
One more change was needed to get the original protection of the section
before relocation so that we can set it back later. The PE files are
not mapped using VirtualXXXX functions in the PAL and so VirtualProtect
doesn't return the proper original protection, but a fixed value instead.
So for PAL, we derive the original protection from the section attributes.
@joshfree joshfree merged commit c6de64f into dotnet:release/1.0.0-rc2 Apr 27, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants