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

!9295 Port patches from OLK-5.10

Merge Pull Request from: @ci-robot 
 
PR sync from: Zheng Yejian <zhengyejian1@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/HTWMGOVY6QJ2UVGTSCYHB6RDQ7K27IWA/ 
Zheng Yejian (2):
  livepatch: Avoid patching conflicts with kprobes
  livepatch: Enable CONFIG_LIVEPATCH_ISOLATE_KPROBE in
    openeuler_defconfig


-- 
2.25.1
 
https://gitee.com/openeuler/kernel/issues/IA76NX 
 
Link:https://gitee.com/openeuler/kernel/pulls/9295

 

Reviewed-by: default avatarXu Kuohai <xukuohai@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 3146e9c2 258c2aa1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -371,6 +371,7 @@ CONFIG_LIVEPATCH_WO_FTRACE=y
CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY=y
# CONFIG_LIVEPATCH_STACK is not set
CONFIG_LIVEPATCH_RESTRICT_KPROBE=y
CONFIG_LIVEPATCH_ISOLATE_KPROBE=y
# end of Enable Livepatch

#
+11 −0
Original line number Diff line number Diff line
@@ -288,3 +288,14 @@ void arch_klp_unpatch_func(struct klp_func *func)
		do_patch(pc, (unsigned long)next_func->new_func);
	}
}

#ifdef CONFIG_LIVEPATCH_ISOLATE_KPROBE
unsigned long arch_klp_fentry_range_size(void)
{
	/*
	 * If first instruction is not 'bti', expect fentry exists
	 * at second instruction otherwise third instruction.
	 */
	return 3 * AARCH64_INSN_SIZE;
}
#endif /* CONFIG_LIVEPATCH_ISOLATE_KPROBE */
+1 −0
Original line number Diff line number Diff line
@@ -531,6 +531,7 @@ CONFIG_LIVEPATCH_WO_FTRACE=y
CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY=y
# CONFIG_LIVEPATCH_STACK is not set
CONFIG_LIVEPATCH_RESTRICT_KPROBE=y
CONFIG_LIVEPATCH_ISOLATE_KPROBE=y
# end of Enable Livepatch
# end of Processor type and features

+18 −0
Original line number Diff line number Diff line
@@ -374,3 +374,21 @@ void arch_klp_unpatch_func(struct klp_func *func)
	/* replace the text with the new text */
	klp_patch_text((void *)ip, (const void *)new, JMP_E9_INSN_SIZE);
}

#ifdef CONFIG_LIVEPATCH_ISOLATE_KPROBE
unsigned long arch_klp_fentry_range_size(void)
{
	unsigned long size = MCOUNT_INSN_SIZE;

	/*
	 * If CONFIG_X86_KERNEL_IBT enabled, there would be an 'endbr64'
	 * at function start, then it should be consider into the range
	 * size.
	 */
#ifdef CONFIG_X86_KERNEL_IBT
	size += ENDBR_INSN_SIZE;
#endif
	/* Expect fentry exists at first instruction. */
	return size;
}
#endif /* CONFIG_LIVEPATCH_ISOLATE_KPROBE */
+8 −0
Original line number Diff line number Diff line
@@ -575,6 +575,14 @@ unsigned long kretprobe_find_ret_addr(struct task_struct *tsk, void *fp,
}
#endif

#ifdef CONFIG_LIVEPATCH_ISOLATE_KPROBE
void kprobes_lock(void);
void kprobes_unlock(void);
#else /* !CONFIG_LIVEPATCH_ISOLATE_KPROBE */
static inline void kprobes_lock(void) { }
static inline void kprobes_unlock(void) { }
#endif /* CONFIG_LIVEPATCH_ISOLATE_KPROBE */

/* Returns true if kprobes handled the fault */
static nokprobe_inline bool kprobe_page_fault(struct pt_regs *regs,
					      unsigned int trap)
Loading