Skip to content

Commit

Permalink
x86, realmode: Set permission for real mode pages
Browse files Browse the repository at this point in the history
Set proper permissions for rodata, text and data, removing the
realmode trampoline area as a remaining RWX memory mapping in the
kernel.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@intel.com>
Link: http://lkml.kernel.org/r/1336501366-28617-8-git-send-email-jarkko.sakkinen@intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Jarkko Sakkinen authored and H. Peter Anvin committed May 8, 2012
1 parent c9b77cc commit f156ffc
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion arch/x86/kernel/realmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,21 @@ static int __init set_real_mode_permissions(void)
PAGE_ALIGN(real_mode_header.end) -
__pa(real_mode_base);

set_memory_x((unsigned long) real_mode_base, all_size >> PAGE_SHIFT);
size_t ro_size =
PAGE_ALIGN(real_mode_header.ro_end) -
__pa(real_mode_base);

size_t text_size =
PAGE_ALIGN(real_mode_header.ro_end) -
real_mode_header.text_start;

unsigned long text_start =
(unsigned long) __va(real_mode_header.text_start);

set_memory_nx((unsigned long) real_mode_base, all_size >> PAGE_SHIFT);
set_memory_ro((unsigned long) real_mode_base, ro_size >> PAGE_SHIFT);
set_memory_x((unsigned long) text_start, text_size >> PAGE_SHIFT);

return 0;
}

Expand Down

0 comments on commit f156ffc

Please sign in to comment.