This is an archive of the discontinued LLVM Phabricator instance.

Correct mprotect page boundries to round up end page. Fixes PR30905.
ClosedPublic

Authored by asbirlea on Nov 4 2016, 3:09 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

asbirlea updated this revision to Diff 76949.Nov 4 2016, 3:09 PM
asbirlea retitled this revision from to Correct mprotect page boundries to round up end page. Fixes PR30905..
asbirlea updated this object.
asbirlea added subscribers: llvm-commits, abadams.
loladiro accepted this revision.Nov 4 2016, 3:36 PM
loladiro edited edge metadata.

Yes, this is clearly a bug. LGTM. Though looking back at it, perhaps the rounding to page size should happen in the caller of protectMappedMemory rather than in that function itself, but that's independent of the bug fix.

This revision is now accepted and ready to land.Nov 4 2016, 3:36 PM
chandlerc edited edge metadata.Nov 4 2016, 3:45 PM

Slight tweak here...

lib/Support/Unix/Memory.inc
158–161 ↗(On Diff #76949)

Instead of this, I would use alignAddr. It seems much easier to get correct:

void *Start = alignAddr(M.Address - PageSize + 1, PageSize);
void *End = alignAddr(M.Address + M.Size, PageSize);
asbirlea updated this revision to Diff 76958.Nov 4 2016, 5:47 PM
asbirlea edited edge metadata.

Address comment.

Tested. I'll land in a couple of hours if there are no additional comments. Thanks Keno, Chandler and Andrew.

This revision was automatically updated to reflect the committed changes.