Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/coreclr/minipal/Unix/doublemapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ bool VMToOSInterface::CreateDoubleMemoryMapper(void** pHandle, size_t *pMaxExecu
}
#endif // RLIMIT_FSIZE

// The clipping above can leave nothing to map - RLIMIT_FSIZE of zero is the plain case,
// and it is a realistic one for a process that is not allowed to create files at all.
// A zero sized mapper cannot back a single executable allocation, so reporting success
// here only hides the problem from ExecutableAllocator::Initialize(), which already knows
// how to continue with W^X disabled when this function fails. Failing here instead lets
// the process run single mapped rather than fail to start.
if (maxDoubleMappedMemorySize == 0)
{
close(fd);
return false;
}

if (ftruncate(fd, maxDoubleMappedMemorySize) == -1)
{
close(fd);
Expand Down
Loading