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

[release/2.1] Fix alternate stack for Alpine docker on SELinux (#17936) #17975

Merged
merged 1 commit into from Jun 1, 2018
Merged

[release/2.1] Fix alternate stack for Alpine docker on SELinux (#17936) #17975

merged 1 commit into from Jun 1, 2018

Conversation

ghost
Copy link

@ghost ghost commented May 12, 2018

Port of #17936
Fixes #17931

@janvorli @RussKeldorph

For some reason, the Alpine docker container running on a SELinux host maps
heap as RWX. When we allocate alternate stack from the heap, we also
change the protection of the first page to PROT_NONE so that it can
serve as a guard page to catch stack overflow. And when we free the
alternate stack, we restore the protection back to PROT_READ |
PROT_WRITE. The restoration fails in Alpine docker container running on
a SELinux host with EPROT failure and the SELinux log reports that an
attempt to change heap to executable was made. So it looks like the
kernel has added the PERM_EXEC to the permissions we have passed to the
mprotect call. There is a code in the mprotect implementation that can
do that, although I don't fully understand the conditions under which it
happens. This is driven by the VM_MAYEXEC flag in the internal VMA block
structure.
To fix that, I've modified the alternate stack allocation to use mmap /
munmap instead of C heap allocation.
@danmoseley
Copy link
Member

@janvorli does this have okay from shiproom? @kasper3 this is required as we are almost in our final build for 2.1.

@janvorli
Copy link
Member

@danmosemsft @Petermarcu said we will not put it to the 2.1 release and it will go to the first servicing release for 2.1. The reason is that it is too late and there is not enough time left to make the change bake itself for sufficient amount of time.

@janvorli janvorli merged commit 13ea3c2 into dotnet:release/2.1 Jun 1, 2018
@ghost ghost deleted the alpine branch June 1, 2018 14:49
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.

2 participants