Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3505987ioo; Wed, 25 May 2022 02:03:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlUwvO5pxNQoEkBQFngokDuNwn5uZD6BWjNRrx/EL1jR/b5yMx1NSm5n1vEesU2omNzchU X-Received: by 2002:a05:6402:17db:b0:42a:cd7c:c486 with SMTP id s27-20020a05640217db00b0042acd7cc486mr33248517edy.267.1653469425935; Wed, 25 May 2022 02:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653469425; cv=none; d=google.com; s=arc-20160816; b=aBC8LsQ/VA2lqt+KeE+cIP2UL4BZrZR0+CJGu9e8GYkS7xj5TCQko+2+iuUPqaMGp8 im2ZeDH3Y0OlQkDi4tUKxiNr478CVM0u+ZXfABo37SqppSeC82OAhw//3/ldA9R4Ddnl uXPV4f4Z2+x+wpgLiBFdsyXlRoRHT3J8DS//5l1cLI+f/1oLK3zEhKXELyq53f/m8XvX YHqAcLkmQj5dvqABu5ZvYO7spIVcCYEZm58HgFXpicS6sLEOxVTd7ok9AFKNncuNexoG pGM9BV8Vatf2cJZcSpOyRRkoheCQmQySMuMC2M3O+xJbFZOj6VF+nr+174RCOkKQp4jk f9cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nhWqtexnJM/cmVM4lAuxcxeMCuTKLpr7dCXqk4Nf0i0=; b=nRevwanhCe7Vh/nRikW8SYgmEOg2XHh1bjY0j+r8xB/eSWmYklYsiVpDs76BGs6ty6 xMNHEmvFg5idJU0pNx6D00lRgRXLERjgvnFL+ffMQXF2uXPXh62k+dZcuftIuSw5PyZd d47VvZ+r0ZMgc/SfF/AxDPZ+BPqHjR6x4hm7/eLuM3l/kjKM15Ff3S4FDeUnQzU5lHv5 zwk43uSjrt4Pgk1FYOvdqeCKXK8yOKT+frRlTlH7xRGTguyFhcxa6dNgH+xhEM2Wxy4D FMB41cSiENHoqMW9hOV5c5QwpTJfW1nhZelNTDk2wqgiIsE0t3uTp0EeAtVd5hGOgW4B GEwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vQaqWjmb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a056402281300b0042b732c9bfdsi9064759ede.534.2022.05.25.02.03.18; Wed, 25 May 2022 02:03:45 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vQaqWjmb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238820AbiEXPV3 (ORCPT + 99 others); Tue, 24 May 2022 11:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238797AbiEXPVW (ORCPT ); Tue, 24 May 2022 11:21:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 480431AD99 for ; Tue, 24 May 2022 08:21:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D838F61709 for ; Tue, 24 May 2022 15:21:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E198C34115; Tue, 24 May 2022 15:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653405680; bh=wbKQ2m0zStxrwKVrhRcUOORtvQoLUD745FXYrf3v+NU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vQaqWjmbvwgE/Olkgr9/EUuu7JXEZRDNPCDc0u6VgAvSy5+DGzFLL2zWWZFPNxDVe YIEVZ8jH9ZZBli2pZZJTCLfVsXb5vw+mlCuXHE3PX6qqrzM6A2Phlynuaryr1nS3nO t//i9rRGFPNJ1M/XLlDrrVP+2jM9vJqBHI9xVRBN3Vr3Y03x322QQFUvTHxa18TR49 EPRQsF0s5mI14wedeKtXtSr8pd7DjIgn+Xa7E7+Uvm78lHYBJcfczMaEeP5hbXjnhM KJdb38SniAPvPyRoO9pNyHFm6BaqGjkr4sJmETdDNw/mS6KHAJ5A+B/VNHmipFdI/J zvpXsHA/jN7Dg== Date: Tue, 24 May 2022 23:12:41 +0800 From: Jisheng Zhang To: Liao Chang , Guo Ren Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, mhiramat@kernel.org, rostedt@goodmis.org, peterz@infradead.org, naveen.n.rao@linux.vnet.ibm.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv/kprobe: reclaim insn_slot on kprobe unregistration Message-ID: References: <20220523015124.98743-1-liaochang1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220523015124.98743-1-liaochang1@huawei.com> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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 > > 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