Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1680763rwb; Sun, 14 Aug 2022 09:23:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR7oPcl1HjYZFaXwShKItnpir+jbqpFoMBqjXtUnwTcJrnU71SZHdSbk6ZY5oGVxlM3LOizR X-Received: by 2002:a63:e016:0:b0:427:e7f2:32b3 with SMTP id e22-20020a63e016000000b00427e7f232b3mr3555739pgh.194.1660494186010; Sun, 14 Aug 2022 09:23:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660494186; cv=none; d=google.com; s=arc-20160816; b=dQpTDtNgpuZY0VGH0m05O63JiNx56isZeygs40rNPLdZjwInrDE9hq/Ym4aFuwKlh5 EsQzHkohFl3if9XezV4Y8ccJdmmmsiivu40FgtyREhOQ+IJDetPLgfmhBxgSY600H8o7 gcGpEH0KsDfrrGHVovlkCYOQBqF8oLHsCP0JdK4P9RYlNTdtJPf2X+shSbmPqa/4nO1B J5EnCWVEhzR6g1BUvC0n/J+xzmwqTmRRPf4K+dwZDBIRPPP+9MTWjcunvId1bTY2Gsm5 WcHkHXs6/AO1wR/TJGUz5IVM4lG3llcUSIMfedMVl/uE1Z6CoCoG0wnX+jPXG/eu7tYP i+ew== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IHaZuWoae7ZpHIxJdMk8Y9L5Qs77gkfFs3vDnXT/ddE=; b=hwVtVb4lbNJv35GXu5oR4l/fi4O3rY1EmXP1jBcz8Uv5njT2626tHVxJhqkPkT39yY WWJ3cCvLsqJ/RjNY9ZzcMXhG+VzKS62AeWjSVsGpSg4VcWdsvKz0+jqczI/uzouqJ2I3 I8atECyNTpdmr+xHxNaaPfAWA3S69CJvitHvOLscqJwt/yuOig5bHsGwSf7XfGc1KdzG xViu+N24qAOMflIVgx5d4+s116qKYUj0IOZJfWCx5clgGJUCXubw7+R2kWeUKCw3GIyz 657b5xCPXZa65TqQOnPz3FkdQ0zODRKYtufwpSn7lJvsgudflq+BmzFVdjY7Tw/YxZ6/ U7jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VK5reFUE; 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 u16-20020a056a00125000b00527e02658ffsi8459164pfi.379.2022.08.14.09.22.55; Sun, 14 Aug 2022 09:23: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=@kernel.org header.s=k20201202 header.b=VK5reFUE; 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 S240537AbiHNPco (ORCPT + 99 others); Sun, 14 Aug 2022 11:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240524AbiHNPcC (ORCPT ); Sun, 14 Aug 2022 11:32:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F8BE1B791; Sun, 14 Aug 2022 08:29:52 -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 ams.source.kernel.org (Postfix) with ESMTPS id 17B24B80B7F; Sun, 14 Aug 2022 15:29:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1068C433C1; Sun, 14 Aug 2022 15:29:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660490989; bh=wx7auUZauTUrHSIJMex3tejmGanZog/dMv720xCvWTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VK5reFUEzrt93F0C2zMvvnRUy3VBwc/z3EHp+4dKbc3qu44AwKO+DlQCSzMaBJCCA eq0MNoZO8b8tPVEA5UdcrHSlM374VmWC0WGOqhEn63wxmm5NWfx9HejA2eAKsPUHXX gjjyFmYdP+IxtZHz0Kcvy2f2f5smvM2zPWb1bJFNjzdM5lHb2FX/47o8nbiv4Z8/LA 2iOeu4+p6vwi3Ig3EQxYzfCvVYcL4LiQialfgQsFFKENteKrAn2EgMySrwrfRNtaRO hNxP+dtNY54eFy/4pj3Xw/MautGg1lzNr2zHaPW0z7c3PcTNnB/kjJ4BmErX/QIKSw B9/TP1H0msJPw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Liao Chang , Chen Guokai , Masami Hiramatsu , Guo Ren , Sasha Levin , rostedt@goodmis.org, julia.lawall@inria.fr, akpm@linux-foundation.org, lkp@intel.com, linux-csky@vger.kernel.org Subject: [PATCH AUTOSEL 5.19 49/64] csky/kprobe: reclaim insn_slot on kprobe unregistration Date: Sun, 14 Aug 2022 11:24:22 -0400 Message-Id: <20220814152437.2374207-49-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814152437.2374207-1-sashal@kernel.org> References: <20220814152437.2374207-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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