From mboxrd@z Thu Jan 1 00:00:00 1970 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 40D75C433EF for ; Thu, 26 May 2022 15:30:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347465AbiEZPaS (ORCPT ); Thu, 26 May 2022 11:30:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230033AbiEZPaO (ORCPT ); Thu, 26 May 2022 11:30:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA13A88A8; Thu, 26 May 2022 08:30:13 -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 8660D61C60; Thu, 26 May 2022 15:30:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B831C385A9; Thu, 26 May 2022 15:30:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653579011; bh=tBqMjxQfiqyy++8lkfm5frnJ0t6bX2bWy4cnjC3WRKs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Lpzi0lR+TZcBjYGzFG2bLZAxTYjJPsJgKkXGMzictbTGhDgDZneeWcQzVbHENp4TH EZuOYaPHFnR9qVXrBfxHZg3CvJV6EmmWTt2KqOO4KZd/pJGAjtk6XNg3LAdmAJR+Dz iWGhOfv5iEIqS3+JFrSZKdkxkubUlYdIVRc1zwfhoYELU5r2czTM9dIQ5iWC8WISE5 mS8GP8y3FWrVD7XLxIKF15ispI2+NFAMIKypYJFGCBbc5JkgWZUKWOVCTZ9iQOI4cs 1UMRoc5CXCzl8vaFwp1N7W/LMLaIU5VDoC9d0SrXY0c6QQldBg2Byi/uzDiIHYFzvZ FwAJWURevjang== Date: Fri, 27 May 2022 00:30:06 +0900 From: Masami Hiramatsu (Google) To: Guo Ren , Liao Chang Cc: , , , , , , , Subject: Re: [PATCH] csky/kprobe: reclaim insn_slot on kprobe unregistration Message-Id: <20220527003006.76a52390841f7fba9680d636@kernel.org> In-Reply-To: <20220525080241.117084-1-liaochang1@huawei.com> References: <20220525080241.117084-1-liaochang1@huawei.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 25 May 2022 16:02:41 +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. > > Reported-by: Chen Guokai > Signed-off-by: Liao Chang This looks good to me too. I think this should go through csky tree. Reviewed-by: Masami Hiramatsu (Google) Thank you, > --- > arch/csky/kernel/probes/kprobes.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/csky/kernel/probes/kprobes.c b/arch/csky/kernel/probes/kprobes.c > index 42920f25e73c..661da54b418f 100644 > --- a/arch/csky/kernel/probes/kprobes.c > +++ b/arch/csky/kernel/probes/kprobes.c > @@ -124,6 +124,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 > -- Masami Hiramatsu (Google)