Skip to content

Commit

Permalink
ARM: ensure the signal page contains defined contents
Browse files Browse the repository at this point in the history
Ensure that the signal page contains our poison instruction to increase
the protection against ROP attacks and also contains well defined
contents.

Acked-by: Will Deacon <[email protected]>
Signed-off-by: Russell King <[email protected]>
  • Loading branch information
Russell King committed Feb 5, 2021
1 parent 538eea5 commit 9c698bf
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions arch/arm/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,18 +693,20 @@ struct page *get_signal_page(void)

addr = page_address(page);

/* Poison the entire page */
memset32(addr, __opcode_to_mem_arm(0xe7fddef1),
PAGE_SIZE / sizeof(u32));

/* Give the signal return code some randomness */
offset = 0x200 + (get_random_int() & 0x7fc);
signal_return_offset = offset;

/*
* Copy signal return handlers into the vector page, and
* set sigreturn to be a pointer to these.
*/
/* Copy signal return handlers into the page */
memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));

ptr = (unsigned long)addr + offset;
flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
/* Flush out all instructions in this page */
ptr = (unsigned long)addr;
flush_icache_range(ptr, ptr + PAGE_SIZE);

return page;
}
Expand Down

0 comments on commit 9c698bf

Please sign in to comment.