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: 50788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2714506wrn; Tue, 31 Jan 2023 04:12:33 -0800 (PST) X-Google-Smtp-Source: AK7set86T7RFkhGueKAL8BRnDv8EoZ4KczT8cQ9KU9tvm5kWM2JDMRr5G7A9tttHNKQySuPXgfTE X-Received: by 2002:a17:906:a1c6:b0:878:80f1:ada1 with SMTP id bx6-20020a170906a1c600b0087880f1ada1mr3140760ejb.30.1675167153619; Tue, 31 Jan 2023 04:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675167153; cv=none; d=google.com; s=arc-20160816; b=TuTrKLxFTZ0pmsTOA5bww6ZzXUcRu5RLx7u1gpRXztbTtq5XdLBJXXSvHAIJBIGPB+ q/LqvxtzzDktvqKDSuiwOG3+sdckSc3CSQEju23Vnbi6Uud/TZw+YtzX/QqIi9zVnIFg Ewj9M9fkMnQtzevl+JhkoId2hc3lSTY98jcu7K4RKdhm+ggyKIXsR/v0jjU9SeQCUQMS JAvjoBG5EjSs8iqmE39TF7SlO5Xa1ZaOxkjTJ4Cc+MLyZtFmEUvYGo0Px5LJ3FvhnYHC V+LSxGsplgcQ9PROHFdo+6SUgNAzkjLNZxD6E8BsaPDxGnFCIB2PBWlDdvGdkHUewmxh DCAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=TjiEDwVOUwZypsBEvKPgD6jPejCy8CEIG1UocTx2TPk=; b=ELr77zw7iGFd0zx4pgMNH+qqW54TCyrUpTo9KL9kypdBZtOELhgis2pScmklCugGfQ XNbjxOcXPG/pxqG75dD1VV6rOCYoxCeoz0cymd8ykRQyC75ZKIGiDpHa+vSS+vCE1mrR Wg6YixTr3sBM+ZAg81YLAmckXUbZZgzVuT7Bsba9dubC5r5QokYNC0jWdfaKmAMdA/0K BpRnoUES3G0q+Q1EIZBGcFA0aHZY93lNiswdolzvPYMpxOe3E059rjO0Cz2tRE4/u/Mf CiFIF4JvuNUCUxPNLlN6L5gIOLkRomJghSZdHl7z8PJkh3J8Wh2Wzdn7I+tzZpuWB0g3 ZqUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a05640234c800b0049e2f51f81asi20728727edc.621.2023.01.31.04.12.10; Tue, 31 Jan 2023 04:12:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229930AbjAaMCB (ORCPT + 99 others); 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: AQAAf8DxK74zA9ljNHklAA--.8415S2 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvdXoWruFWDKr17trWxZF4UGr13twb_yoW3twc_Aw 1jvryDGw4jkrW5Zwn8tw4fXFZFq3yqvF48ur9rKrWUJ34Utw15XFWkWFy3u395Kan7GFWD Ar4Dur9Fga1xujkaLaAFLSUrUUUU1b8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY q7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3w AFIxvE14AKwVWUGVWUXwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK 6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r1j6r4UM28EF7 xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVWxJr0_GcWln4kS 14v26r1Y6r17M2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2IqxVAq x4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r 1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF 7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxV WUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU 2G-eUUUUU X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756540073288356797?= X-GMAIL-MSGID: =?utf-8?q?1756540073288356797?= 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