Merge pull request #6127 from urbit/jb/guard-always-again

u3: re-enforce guard page invariants.
This commit is contained in:
Joe Bryan 2022-12-02 16:42:11 -05:00 committed by GitHub
commit 867f0621a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -860,6 +860,19 @@ _ce_loom_protect_north(c3_w pgs_w, c3_w old_w)
c3_assert(0); c3_assert(0);
} }
// protect guard page if clobbered
//
// NB: < pgs_w is precluded by assertion in _ce_patch_compose()
//
if ( (gar_pag_p >> u3a_page) < old_w ) {
fprintf(stderr, "loom: guard on reprotect\r\n");
if ( 0 != mprotect(u3a_into(gar_pag_p), pag_siz_i, PROT_NONE) ) {
fprintf(stderr, "loom: failed to protect guard page: %s\r\n",
strerror(errno));
c3_assert(0);
}
}
_ce_loom_track_north(pgs_w, dif_w); _ce_loom_track_north(pgs_w, dif_w);
} }
else { else {
@ -895,6 +908,19 @@ _ce_loom_protect_south(c3_w pgs_w, c3_w old_w)
c3_assert(0); c3_assert(0);
} }
// protect guard page if clobbered
//
// NB: > pgs_w is precluded by assertion in _ce_patch_compose()
//
if ( (gar_pag_p >> u3a_page) >= (u3a_pages - (old_w + 1)) ) {
fprintf(stderr, "loom: guard on reprotect\r\n");
if ( 0 != mprotect(u3a_into(gar_pag_p), pag_siz_i, PROT_NONE) ) {
fprintf(stderr, "loom: failed to protect guard page: %s\r\n",
strerror(errno));
c3_assert(0);
}
}
_ce_loom_track_south(pgs_w, dif_w); _ce_loom_track_south(pgs_w, dif_w);
} }
else { else {
@ -943,6 +969,19 @@ _ce_loom_mapf_north(c3_i fid_i, c3_w pgs_w, c3_w old_w)
c3_assert(0); c3_assert(0);
} }
// protect guard page if clobbered
//
// NB: < pgs_w is precluded by assertion in _ce_patch_compose()
//
if ( (gar_pag_p >> u3a_page) < old_w ) {
fprintf(stderr, "loom: guard on remap\r\n");
if ( 0 != mprotect(u3a_into(gar_pag_p), pag_siz_i, PROT_NONE) ) {
fprintf(stderr, "loom: failed to protect guard page: %s\r\n",
strerror(errno));
c3_assert(0);
}
}
_ce_loom_track_north(pgs_w, dif_w); _ce_loom_track_north(pgs_w, dif_w);
} }
else { else {