diff mbox series

kprobes: Replace memcpy() with direct assignment

Message ID 1675166510-7798-1-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State Rejected
Headers show
Series kprobes: Replace memcpy() with direct assignment | expand

Commit Message

Tiezhu Yang Jan. 31, 2023, 12:01 p.m. UTC
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(-)

Comments

Masami Hiramatsu (Google) Feb. 3, 2023, 1:05 p.m. UTC | #1
On Tue, 31 Jan 2023 20:01:50 +0800
Tiezhu Yang <yangtiezhu@loongson.cn> wrote:

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

NACK, because this is not invoked from kprobe int3 handling code.

Thank you,

> 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
>
diff mbox series

Patch

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