Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3413854rwa; Tue, 23 Aug 2022 04:30:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR5iTAQ/jOSrrLYZOQ2tXRYOF0DgeozWM3qZzIVaEnRfGCdD/yD32Iah8RvexR+F2auFyPJr X-Received: by 2002:a65:688f:0:b0:41d:e38a:e8c4 with SMTP id e15-20020a65688f000000b0041de38ae8c4mr20637857pgt.437.1661254205018; Tue, 23 Aug 2022 04:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254205; cv=none; d=google.com; s=arc-20160816; b=0Hi9ujONtHg3s9jZsvx1rl44mhU322HcxwJgOPX5FjFQIzlTvGDx8YV+ldq5q1QirJ i0ddQCQLlpRP1M01tRrScOZ1mil4xQIei0It1jNe+ExSA4driU/fH6jBWBUGyA3FGJL/ 84c/rKYvNXP7eJw4/nytD/UmWYsqAKZyNQylx0bWhVbrmxfC9cpgj+oZYm89ri+wEV0P so/0z/+pDB7XLPmRZommgJdv3bRZPByoEWgFS0mJYWp20fMWDKF6F5O8qVSo85rNx1C4 xBpnenjyvCNmawRqvTcA2OhW3OqwWO6iXVdarX+lJLLyPJGWLuTdPfmL29sLnoVpD1aR c/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tyaua6rgDvUCfU0UYY6ek8r8XDrbFjYqs7LGx+Lk7F0=; b=U8eK+FyzO8HKHYzucocfz5c/KqOQJU5sEJ2MSiRSZ0cVbDkJ41ns5O5ridLeNPZcFU M6xC1a2Xr27LMCOhbjcfx1cEoTSKuxhnYYKgfhcfcnofFofhkK5fZNC33VgaUsrIybj3 Bc03kuQnkKezUF1ral1wkxoUrLvxMfC54UGUnbcES9QH6IEned8q7PXaSasxWnBc4kOM VnMsnp2r35CZoS5G3L1obKWXuzb36xdNMulJT+7ifPfpEaZM/fFCOBnXtpyaZHHNfU4G l4TxiA1AaGgwgUnQbxJ9DzC7h8AcuokOXz0QD3fPJ0kperUd0BfgAfRA/jciQxM2wZfC uhFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Am/b8KOj"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k63-20020a638442000000b00429fab244e1si8554253pgd.11.2022.08.23.04.29.54; Tue, 23 Aug 2022 04:30:05 -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=@linuxfoundation.org header.s=korg header.b="Am/b8KOj"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354190AbiHWKYe (ORCPT + 99 others); Tue, 23 Aug 2022 06:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353574AbiHWKLj (ORCPT ); Tue, 23 Aug 2022 06:11:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC269CDC; Tue, 23 Aug 2022 01:57:22 -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 58A646153F; Tue, 23 Aug 2022 08:57:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21E98C433D6; Tue, 23 Aug 2022 08:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245041; bh=lY8Vu6e1a86oTT8LLYHfgkFVDDyf4+IO166QYIoKdS4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Am/b8KOjI2gKTCsOy4hiqOBN3oYXCUAFZ/MSc6J68ejPL8mCWII3h3MVWbJhgwQM0 VdRt9wxepU5P2LG1riDiq6hToigPJv2gXT8Sn1hAlyRy1Wi1XZJV5QjdNmGbdv+yGz tiPJ7B07oFFgP1NwLDStOR5srB0Dv4/jji7mJBrU= 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.15 196/244] csky/kprobe: reclaim insn_slot on kprobe unregistration Date: Tue, 23 Aug 2022 10:25:55 +0200 Message-Id: <20220823080105.970987809@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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 4045894d9280..584ed9f36290 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