Bug 1460989 - Check page protection flags again after mprotect(); r=glandium

We are apparently still crashing even after mprotect() with write flag
returns successfully. This patch reads the flags again after mprotect()
returns, and hopefully the flags will tell the truth of whether the page
is truly writable or not after calling mprotect().

MozReview-Commit-ID: Jsg8vHKFEvJ

--HG--
extra : rebase_source : b028aa0d5cefd50302bfc2502292d9129d202e09
This commit is contained in:
Jim Chen 2018-05-30 11:47:07 -04:00
Родитель e20d6e1da2
Коммит 32c922179c
1 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -911,11 +911,21 @@ public:
page = firstPage;
int ret = mprotect(page, length, prot | PROT_WRITE);
success = ret == 0;
if (ret != 0) {
success = false;
WARN("mprotect(%p, %zu, %o) = %d (errno=%d; %s)",
page, length, prot | PROT_WRITE, ret, errno, strerror(errno));
return;
}
// XXX bug 1460989: on some devices, mprotect appears to return 0 for
// success even after _failing_ to make the page writable. Therefore, check
// for write access again instead of relying on the mprotect return value.
int newProt = getProt(start, &end);
success = (newProt != -1) && (newProt & PROT_WRITE);
if (!success) {
ERROR("mprotect(%p, %zu, %d) = %d (errno=%d; %s)",
page, length, prot | PROT_WRITE, ret,
errno, strerror(errno));
WARN("mprotect(%p, %zu, %o) returned 0 but page is not writable: %o",
page, length, prot | PROT_WRITE, newProt);
}
}