Skip to content

Commit 9c698bf

Browse files
author
Russell King
committed
ARM: ensure the signal page contains defined contents
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 <will@kernel.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent 538eea5 commit 9c698bf

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

arch/arm/kernel/signal.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,18 +693,20 @@ struct page *get_signal_page(void)
693693

694694
addr = page_address(page);
695695

696+
/* Poison the entire page */
697+
memset32(addr, __opcode_to_mem_arm(0xe7fddef1),
698+
PAGE_SIZE / sizeof(u32));
699+
696700
/* Give the signal return code some randomness */
697701
offset = 0x200 + (get_random_int() & 0x7fc);
698702
signal_return_offset = offset;
699703

700-
/*
701-
* Copy signal return handlers into the vector page, and
702-
* set sigreturn to be a pointer to these.
703-
*/
704+
/* Copy signal return handlers into the page */
704705
memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
705706

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

709711
return page;
710712
}

0 commit comments

Comments
 (0)