Unverified Commit 3fa49824 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!8425 CVE-2023-52677

Merge Pull Request from: @ci-robot 
 
PR sync from: Yuntao Liu <liuyuntao12@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/ZSHR47ASBCHK5HNB3324HZEUMHBDAXQI/ 
CVE-2023-52677

Alexandre Ghiti (1):
  riscv: Check if the code to patch lies in the exit section


-- 
2.34.1
 
https://gitee.com/src-openeuler/kernel/issues/I9Q9F3 
 
Link:https://gitee.com/openeuler/kernel/pulls/8425

 

Reviewed-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 02c5f381 56753852
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,5 +9,6 @@

extern char _start[];
extern char _start_kernel[];
extern char __exittext_begin[], __exittext_end[];

#endif /* __ASM_SECTIONS_H */
+10 −1
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include <asm/fixmap.h>
#include <asm/ftrace.h>
#include <asm/patch.h>
#include <asm/sections.h>

struct patch_insn {
	void *addr;
@@ -23,12 +24,20 @@ struct patch_insn {
int riscv_patch_in_stop_machine = false;

#ifdef CONFIG_MMU

static inline bool is_kernel_exittext(uintptr_t addr)
{
	return system_state < SYSTEM_RUNNING &&
		addr >= (uintptr_t)__exittext_begin &&
		addr < (uintptr_t)__exittext_end;
}

static void *patch_map(void *addr, int fixmap)
{
	uintptr_t uintaddr = (uintptr_t) addr;
	struct page *page;

	if (core_kernel_text(uintaddr))
	if (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr))
		page = phys_to_page(__pa_symbol(addr));
	else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX))
		page = vmalloc_to_page(addr);
+3 −0
Original line number Diff line number Diff line
@@ -43,10 +43,13 @@ SECTIONS
		__soc_builtin_dtb_table_end = .;
	}
	/* we have to discard exit text and such at runtime, not link time */
	__exittext_begin = .;
	.exit.text :
	{
		EXIT_TEXT
	}
	__exittext_end = .;

	.exit.data :
	{
		EXIT_DATA