From patchwork Tue Jan 31 12:01:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 13122940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9131BC636CC for ; Tue, 31 Jan 2023 12:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbjAaMCB (ORCPT ); Tue, 31 Jan 2023 07:02:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjAaMCA (ORCPT ); Tue, 31 Jan 2023 07:02:00 -0500 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 43E07193D7; Tue, 31 Jan 2023 04:01:57 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8CxIfA0A9ljG4UKAA--.22086S3; Tue, 31 Jan 2023 20:01:56 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxK74zA9ljNHklAA--.8415S2; Tue, 31 Jan 2023 20:01:56 +0800 (CST) From: Tiezhu Yang To: Steven Rostedt , Masami Hiramatsu , naveen.n.rao@linux.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] kprobes: Replace memcpy() with direct assignment Date: Tue, 31 Jan 2023 20:01:50 +0800 Message-Id: <1675166510-7798-1-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf8DxK74zA9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Y6I8E87Iv67AKxV WUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU 2G-eUUUUU Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org 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 --- 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