Skip to content

Commit

Permalink
igvmbld: Zero stage2 stack page before populating it
Browse files Browse the repository at this point in the history
The stage2 stack page memory is allocated with a call to
construct_mem_data_object(). This function zeros any padding outside of
the requested data size but does not zero the memory where the data
resides.

The stage2 stack is allocated as a full page, meaning the stack is not
initialised to zero. This results in uninitialised data being present
below the populated stack frame and in the _reserved part of the stack.

This commit zeroes the entire stack page to ensure it is initialised.

Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
  • Loading branch information
roy-hopkins committed Jan 17, 2024
1 parent 78c0c39 commit 2856e6a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions igvmbld/igvmbld.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ int main(int argc, const char *argv[])
}

// Construct the initial stack contents.
memset(initial_stack->data, 0, PAGE_SIZE);
stage2_stack = (Stage2Stack *)((uint8_t *)initial_stack->data + PAGE_SIZE) - 1;
stage2_stack->kernel_start = (uint32_t)kernel_data->address;
stage2_stack->kernel_end = (uint32_t)kernel_data->address + kernel_data->size;
Expand Down

0 comments on commit 2856e6a

Please sign in to comment.