Skip to content

Commit

Permalink
setup: change init code sanitize pattern to 0xcc
Browse files Browse the repository at this point in the history
Don't sanitize the init code region with zeros as these decode to valid
instructions if %rax points to mapped memory. Instead use 0xcc which
would trap if we ever would return to an address in that range.

Signed-off-by: Mathias Krause <[email protected]>
  • Loading branch information
minipli-oss committed Oct 14, 2021
1 parent b802348 commit 1d88eff
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void zap_boot_mappings(void) {
for_each_memory_range (r) {
if (r->base == VIRT_IDENT_BASE && IS_INIT_SECTION(r->name)) {
if (strcmp(r->name, ".text.init"))
memset(r->start, 0, r->end - r->start);
memset(r->start, 0xcc, r->end - r->start);

for (mfn_t mfn = virt_to_mfn(r->start); mfn < virt_to_mfn(r->end); mfn++) {
vunmap(mfn_to_virt(mfn), PAGE_ORDER_4K);
Expand Down

0 comments on commit 1d88eff

Please sign in to comment.