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 D0311C32774 for ; Tue, 23 Aug 2022 12:18:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245312AbiHWMRz (ORCPT ); Tue, 23 Aug 2022 08:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376322AbiHWMQv (ORCPT ); Tue, 23 Aug 2022 08:16:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2829ED001; Tue, 23 Aug 2022 02:41:58 -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 C0AD86138B; Tue, 23 Aug 2022 09:41:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B46B1C433C1; Tue, 23 Aug 2022 09:41:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661247717; bh=5dBZbZXQNfVHSjI8nHnSrIYAGDA/pPykGZHL7T7DMKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JRt1cvGBT6DcYRPK2PQKP7Ibg6wI7BsaDSY3xfUub163rMAFNPzzlnAtukJq/NBIU w53I52HC1CdO4/BCAqYaHibpzWzkXSs94ltfKQnSvB1bE1FZHLHCGd59lSYir7Abox +Ff8DhQlh2DTynbPw4Vc9Cz2NEEP8H+SFKr6EWlI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen Guokai , "Masami Hiramatsu (Google)" , Liao Chang , Guo Ren , Sasha Levin Subject: [PATCH 5.10 124/158] csky/kprobe: reclaim insn_slot on kprobe unregistration Date: Tue, 23 Aug 2022 10:27:36 +0200 Message-Id: <20220823080050.907178186@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080046.056825146@linuxfoundation.org> References: <20220823080046.056825146@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Liao Chang [ Upstream commit a2310c74d418deca0f1d749c45f1f43162510f51 ] 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 Reviewed-by: Masami Hiramatsu (Google) Signed-off-by: Liao Chang Signed-off-by: Guo Ren Signed-off-by: Sasha Levin --- 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 556b9ba61ec0..79272dde72db 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.35.1