mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/2] kprobes: modify the copy_kprobe to make more clearly
@ 2022-07-28 12:45 zhangduo
  2022-07-31 14:41 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: zhangduo @ 2022-07-28 12:45 UTC (permalink / raw)
  To: zduo006
  Cc: anil.s.keshavamurthy, davem, linux-kernel, mhiramat,
	naveen.n.rao, zhangduo

From: zhangduo <zhangduo@kylinos.cn>

  copy_kprobe() are called in init_aggr_kprobe() to copy opcode
  and insn from 'p' to 'ap',but in copy_kprobe(p,ap) implemtation
  'p' pass to 'struct kprobe *ap' , 'ap' pass to 'struct kprobe *p',
  it looks strange, because p means orig kprobe instance, ap
  means aggregator kprobe, not the same.  and before the add_new_kprobe()
  calling used the opposite copy from 'ap' to 'p', so modify copy_kprobe's
  parameter name as 'p_src' and 'p_dst' to fit all.

Signed-off-by: zhangduo <zhangduo@kylinos.cn>
---
 kernel/kprobes.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 4f3e84343..8bcef7d3c 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -405,10 +405,10 @@ 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)
+static inline void copy_kprobe(struct kprobe *p_dst, struct kprobe *p_src)
 {
-	memcpy(&p->opcode, &ap->opcode, sizeof(kprobe_opcode_t));
-	memcpy(&p->ainsn, &ap->ainsn, sizeof(struct arch_specific_insn));
+	memcpy(&p_dst->opcode, &p_src->opcode, sizeof(kprobe_opcode_t));
+	memcpy(&p_dst->ainsn, &p_src->ainsn, sizeof(struct arch_specific_insn));
 }
 
 #ifdef CONFIG_OPTPROBES
@@ -1277,7 +1277,7 @@ static int add_new_kprobe(struct kprobe *ap, struct kprobe *p)
 static void init_aggr_kprobe(struct kprobe *ap, struct kprobe *p)
 {
 	/* Copy the insn slot of 'p' to 'ap'. */
-	copy_kprobe(p, ap);
+	copy_kprobe(ap, p);
 	flush_insn_slot(ap);
 	ap->addr = p->addr;
 	ap->flags = p->flags & ~KPROBE_FLAG_OPTIMIZED;
@@ -1350,7 +1350,7 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p)
 	}
 
 	/* Copy the insn slot of 'ap' to 'p'. */
-	copy_kprobe(ap, p);
+	copy_kprobe(p, ap);
 	ret = add_new_kprobe(ap, p);
 
 out:
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-31 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-28 12:45 [PATCH 2/2] kprobes: modify the copy_kprobe to make more clearly zhangduo
2022-07-31 14:41 ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®