Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3464480rwa; Tue, 23 Aug 2022 05:19:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR4EtMm+fB2lTEdeRRjfzUu5mTPROtMULwTGmwtSz2dh2sqosn69VKVkzoHb8AOljcTtxYko X-Received: by 2002:a05:6a00:1808:b0:536:88c5:a34c with SMTP id y8-20020a056a00180800b0053688c5a34cmr10530549pfa.54.1661257158976; Tue, 23 Aug 2022 05:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257158; cv=none; d=google.com; s=arc-20160816; b=oaZ1ENS6jSxeSOmRnhud2HUEPATrdqwZiTJUqOdzUzVJmTGlG81060ZH5QFU7uNP/h K+3Bx5puPd0OOxkf6xQJRQb1T9BqK1LihMMpgfJNrKedYsoySH+24+gMujBXW1Cy1exp HOIlTmor4dH9Eynsv5trwqcieJDjUvh6RD1cN14l0HiomZrJK5LcxRof5Z4WoZYy6THA GlJcfa7zJgfouFtf148m+cM5XkpUI4a01AtL9cJpAf0bpjDdqlnPmc/yf0cAwphFuqDX swG7zg7VNTjTKqDJId2IFi3oqJJ3ml//RFHyCWh7xAy41aVjPdAz0h1+u0cAFmH3Y/dN SP7w== 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=IHaZuWoae7ZpHIxJdMk8Y9L5Qs77gkfFs3vDnXT/ddE=; b=0O9TCn8wBGWDatCZeHi2m0mX/F2dhSXOCb4K+LngxwoBe0lAxIFv8qoVprkx3+/TTA udgy9G4qPNTqQRlxZAVLKA7UpSQIra08XRHIgf0oRu5ULCKzVsrbc9Aa/DCX73BAJxaL /sktqxQbgdDNLj9YKlChpe9io4ZJBTt3L28uSlgdy9E1Jg/uOj0PyoLlHBsmX3tx6+Dp a7UuU+icf3MwYFWOhznYe68i89AQiY2Y/9U7Ja5n/Dlm1ayKXZY/i5qrTNXvNIt7U7U7 W2N/XmzdizVDBJ34oiMmq4rrhzoWLLAq/iupnkk8ltfXcF8NtD3fKzvXIwq8dKoWBFyp hg2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uraBdw8z; 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 u20-20020a056a00159400b0052b8da96658si16336384pfk.26.2022.08.23.05.19.07; Tue, 23 Aug 2022 05:19:18 -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=uraBdw8z; 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 S1351340AbiHWJpZ (ORCPT + 99 others); Tue, 23 Aug 2022 05:45:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351941AbiHWJkm (ORCPT ); Tue, 23 Aug 2022 05:40:42 -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 512AE792D8; Tue, 23 Aug 2022 01:41:45 -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 F1CC66123D; Tue, 23 Aug 2022 08:33:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E02A6C433D6; Tue, 23 Aug 2022 08:33:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243617; bh=wx7auUZauTUrHSIJMex3tejmGanZog/dMv720xCvWTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uraBdw8zS8OsMI46LCIh7tzxYAof5f57jmzEIFxgwOTqk3SzPqWL+apN/qz+WTXrj h+db5lDAMFhJweYlVn9hy1yr9riy4ZDX9//J6ZKDqehd9IWGufpn6kNFUJg1/h01yI 76ZRNyIkHAJu23+M9OTVXXPUDi7joURehgNbAwxE= 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.19 304/365] csky/kprobe: reclaim insn_slot on kprobe unregistration Date: Tue, 23 Aug 2022 10:03:25 +0200 Message-Id: <20220823080130.903891051@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@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 34ba684d5962..3c6e5c725d81 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