This commit is contained in:
Ryan VanderMeulen 2018-06-06 21:08:22 -04:00
Родитель 21828f67fa 4aef6ab351
Коммит 5ace5c75d1
1 изменённых файлов: 4 добавлений и 14 удалений

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

@ -911,21 +911,11 @@ public:
page = firstPage;
int ret = mprotect(page, length, prot | PROT_WRITE);
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);
success = ret == 0;
if (!success) {
WARN("mprotect(%p, %zu, %o) returned 0 but page is not writable: %o",
page, length, prot | PROT_WRITE, newProt);
ERROR("mprotect(%p, %zu, %d) = %d (errno=%d; %s)",
page, length, prot | PROT_WRITE, ret,
errno, strerror(errno));
}
}