提交 e90edf50 编写于 作者: R Russell King 提交者: Yang Yingliang

ARM: ensure the signal page contains defined contents

stable inclusion
from linux-4.19.177
commit 80ef523d2cb719c3de66787e922a96b5099d2fbb
CVE: CVE-2021-21781

--------------------------------

[ Upstream commit 9c698bff ]

Ensure that the signal page contains our poison instruction to increase
the protection against ROP attacks and also contains well defined
contents.
Acked-by: NWill Deacon <will@kernel.org>
Signed-off-by: NRussell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 aff88a42
...@@ -697,18 +697,20 @@ struct page *get_signal_page(void) ...@@ -697,18 +697,20 @@ struct page *get_signal_page(void)
addr = page_address(page); 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 */ /* Give the signal return code some randomness */
offset = 0x200 + (get_random_int() & 0x7fc); offset = 0x200 + (get_random_int() & 0x7fc);
signal_return_offset = offset; signal_return_offset = offset;
/* /* Copy signal return handlers into the page */
* Copy signal return handlers into the vector page, and
* set sigreturn to be a pointer to these.
*/
memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes)); memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
ptr = (unsigned long)addr + offset; /* Flush out all instructions in this page */
flush_icache_range(ptr, ptr + sizeof(sigreturn_codes)); ptr = (unsigned long)addr;
flush_icache_range(ptr, ptr + PAGE_SIZE);
return page; return page;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册