Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3490350ioo; Wed, 25 May 2022 01:37:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmJP9WQQDvWiUjRkwIayOz5qoLe9vwIjt4bapLOC3o+wXRHp1h5bsT+F57Ve5WxivFoZdU X-Received: by 2002:a17:907:7ba1:b0:6fe:e18a:dc89 with SMTP id ne33-20020a1709077ba100b006fee18adc89mr13111613ejc.392.1653467867237; Wed, 25 May 2022 01:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653467867; cv=none; d=google.com; s=arc-20160816; b=wr2jB/GvhioQduBdV4kchPk4l/2Wc6CoTG+S3+gP/dF5wr2xZiW5aNxUZVRQ2rYj9m gta5t3+KBrdLzECglqHzMC0ZyiQCjdfsFW9LhWMgGcnxj5LGn2S3RlNd2g58Ey082aOs Ul4Rug5Uz4FEmrdbhI35G9fwIeJeDuaTfuHbUznmKvIrqRDCanq0T2MP40W6UQIfK2pr Iqrvr6Md37jqb0Vnf0d5fug0w0AzH2PQCAwHWWg0uYbU+s+N56pVJEbNBHhywhj5k5hH Jd27VkuZi55LrzTO8Z+JRQsXCNGSKpP4f6MFS+uBktulmtp0zQY5PKUBJmEuU3a4v0+x 8tjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=nZeQq9ijftW8sEFF9uZ2NAUSB3DMJUPXxm8Pcq3Mve8=; b=ja7IGw2uZykd9tsQciN9Jl7CzjOeRgpE3OzRWwaqyH70ucZlsKv14QUUhJtPzNdQYg NNIloHn0FLg38rPWly2b9qaIKhmKWYoIngy/y1ES+ZWA5m54oC0vc87vtAO44m7Qd94X NQyY9jQVcA5U5B0pysJUleTXgpspKBz6SJtFNJZNSwk5rARrYd9kVNZ1GYiGG2cR+UPw 49aH40U2iYR53FDf0eJHBIpj+wR65Z06mSaXlftRqnmI6kynta8dnqfZJPQc6TsNpL8E r7kTdp5/ivvEXVH2+QKrS5A1bOWxZnlwAydiIT2wSn6pvlJNt+j8DXf4pt83mjRY7N89 vohw== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp8-20020a1709073e0800b006fe1bddf1e4si1258296ejc.988.2022.05.25.01.37.19; Wed, 25 May 2022 01:37:47 -0700 (PDT) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243153AbiEYBYj (ORCPT + 99 others); Tue, 24 May 2022 21:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235409AbiEYBYi (ORCPT ); Tue, 24 May 2022 21:24:38 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8D8A6A071 for ; Tue, 24 May 2022 18:24:37 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4L7Cvg4y4WzQkDn; Wed, 25 May 2022 09:21:35 +0800 (CST) Received: from [10.67.110.108] (10.67.110.108) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 25 May 2022 09:24:35 +0800 Message-ID: <6c692ace-9902-e11f-21c2-ef464be4d3c6@huawei.com> Date: Wed, 25 May 2022 09:24:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration To: Jisheng Zhang , Guo Ren CC: , , , , , , , , References: <20220523015124.98743-1-liaochang1@huawei.com> From: "liaochang (A)" In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.108] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 在 2022/5/24 23:12, Jisheng Zhang 写道: > On Mon, May 23, 2022 at 09:51:24AM +0800, Liao Chang wrote: >> On kprobe registration kernel allocate one insn_slot for new kprobe, >> but it forget to reclaim the insn_slot on unregistration, leading to a >> potential leakage. > > + Guo Ren > > Nice catch! I think csky needs the fix as well. > >> >> This bug reported by Chen Guokai . > > This needs a "Reported-by: ..." tag Thanks for comment. > >> >> Signed-off-by: Liao Chang >> --- >> arch/riscv/kernel/probes/kprobes.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c >> index e6e950b7cf32..f12eb1fbb52c 100644 >> --- a/arch/riscv/kernel/probes/kprobes.c >> +++ b/arch/riscv/kernel/probes/kprobes.c >> @@ -110,6 +110,10 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p) >> >> void __kprobes arch_remove_kprobe(struct kprobe *p) >> { >> + if (p->ainsn.api.insn) { >> + free_insn_slot(p->ainsn.api.insn, 0); >> + p->ainsn.api.insn = NULL; >> + } >> } >> >> static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb) >> -- >> 2.17.1 >> >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv > . -- BR, Liao, Chang