Thread (2 messages) 2 messages, 2 authors, 2023-02-03

[PATCH] kprobes: Replace memcpy() with direct assignment

From: Tiezhu Yang <yangtiezhu@loongson.cn>
Date: 2023-01-31 12:02:03
Also in: lkml
Subsystem: kprobes, the rest · Maintainers: Naveen N Rao, "David S. Miller", Masami Hiramatsu, Linus Torvalds

Just do a direct assignment, then give a chance to probe memcpy()
for some archs or kernel versions which do not blacklist memcpy().

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 kernel/kprobes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 1c18ecf..5a3cf9f 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -407,8 +407,8 @@ static inline bool kprobe_unused(struct kprobe *p)
 /* Keep all fields in the kprobe consistent. */
 static inline void copy_kprobe(struct kprobe *ap, struct kprobe *p)
 {
-	memcpy(&p->opcode, &ap->opcode, sizeof(kprobe_opcode_t));
-	memcpy(&p->ainsn, &ap->ainsn, sizeof(struct arch_specific_insn));
+	p->opcode = ap->opcode;
+	p->ainsn = ap->ainsn;
 }
 
 #ifdef CONFIG_OPTPROBES
-- 
2.1.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help