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 X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E67F8C43463 for ; Mon, 21 Sep 2020 12:24:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 907C020EDD for ; Mon, 21 Sep 2020 12:24:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600691098; bh=zgQXxeXXMRrxMKzuzEJjE8QBiMmVVjIizWNnPJNYjjU=; h=Subject:To:Cc:From:Date:List-ID:From; b=IUW0erNCFNR0wUAJFVCjE8j/SEWq2NqXqXVnteJNEzFz9JrIHXNTrLPq9GRm+V91T gFl7Adk3CU9agBwpxcwVGuouDSiPTXnOijUqC8trWBk0ZtdtFbnpqoLjnY6PEx7dyG M/GEdzXpWBweSCNFApJlV7+Mb9yd8DQPC3ce8TsY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726375AbgIUMY6 (ORCPT ); Mon, 21 Sep 2020 08:24:58 -0400 Received: from forward3-smtp.messagingengine.com ([66.111.4.237]:37749 "EHLO forward3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbgIUMY5 (ORCPT ); Mon, 21 Sep 2020 08:24:57 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailforward.nyi.internal (Postfix) with ESMTP id A8FD81941774; Mon, 21 Sep 2020 08:24:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 21 Sep 2020 08:24:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=nkp2yy 7hSeOywTq1lbKDaTNIV1xnI5f1jiPsA4OE/yg=; b=iZj9pbfZ0PcCRiE1L7kCQ3 /t2TXxwz1u53cM0ahKekX3HllztUkM884YaTYRLlKhAG5/2lO+f/SHTBjqgJUIXS Fnn9Li58bzAmuCAdAybG0pjI0xch0XnNP2wGOVetlcCNHtRtIEDGLuLhZr2JD1r0 S/UUHmbVm3ZIgT7UF9zFcHjrLN2zaY9sqwp24taBBWo2A46mRyTRKI2FJI5/tWgO vsY0wDa2vtHH94IF9ZBr0lBSHXKhIcTNCZoqIjXT+bL2OKE6+ft9teipBMsZKssV qvsnFYYcQ547A2l4I84C6R8Pl4gO1AUB+Hz6tUvC5OtQHWPomO4Sv0dnC6dlWQWw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddvgdehfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepuffvhfffkfggtgfgsehtkeertddttd flnecuhfhrohhmpeeoghhrvghgkhhhsehlihhnuhigfhhouhhnuggrthhiohhnrdhorhhg qeenucggtffrrghtthgvrhhnpeelleelvdegfeelledtteegudegfffghfduffduudekge efleegieegkeejhfelveenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecukfhppeek fedrkeeirdejgedrieegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm X-ME-Proxy: Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) by mail.messagingengine.com (Postfix) with ESMTPA id CFB5A328005D; Mon, 21 Sep 2020 08:24:55 -0400 (EDT) Subject: FAILED: patch "[PATCH] kprobes: fix kill kprobe which has been marked as gone" failed to apply to 5.4-stable tree To: songmuchun@bytedance.com, akpm@linux-foundation.org, anil.s.keshavamurthy@intel.com, davem@davemloft.net, mhiramat@kernel.org, naveen.n.rao@linux.ibm.com, rostedt@goodmis.org, songliubraving@fb.com, stable@vger.kernel.org, torvalds@linux-foundation.org, zhouchengming@bytedance.com Cc: From: Date: Mon, 21 Sep 2020 14:25:19 +0200 Message-ID: <1600691119190189@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From b0399092ccebd9feef68d4ceb8d6219a8c0caa05 Mon Sep 17 00:00:00 2001 From: Muchun Song Date: Fri, 18 Sep 2020 21:20:21 -0700 Subject: [PATCH] kprobes: fix kill kprobe which has been marked as gone If a kprobe is marked as gone, we should not kill it again. Otherwise, we can disarm the kprobe more than once. In that case, the statistics of kprobe_ftrace_enabled can unbalance which can lead to that kprobe do not work. Fixes: e8386a0cb22f ("kprobes: support probing module __exit function") Co-developed-by: Chengming Zhou Signed-off-by: Muchun Song Signed-off-by: Chengming Zhou Signed-off-by: Andrew Morton Acked-by: Masami Hiramatsu Cc: "Naveen N . Rao" Cc: Anil S Keshavamurthy Cc: David S. Miller Cc: Song Liu Cc: Steven Rostedt Cc: Link: https://lkml.kernel.org/r/20200822030055.32383-1-songmuchun@bytedance.com Signed-off-by: Linus Torvalds diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 287b263c9cb9..049da84e1952 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -2140,6 +2140,9 @@ static void kill_kprobe(struct kprobe *p) lockdep_assert_held(&kprobe_mutex); + if (WARN_ON_ONCE(kprobe_gone(p))) + return; + p->flags |= KPROBE_FLAG_GONE; if (kprobe_aggrprobe(p)) { /* @@ -2419,7 +2422,10 @@ static int kprobes_module_callback(struct notifier_block *nb, mutex_lock(&kprobe_mutex); for (i = 0; i < KPROBE_TABLE_SIZE; i++) { head = &kprobe_table[i]; - hlist_for_each_entry(p, head, hlist) + hlist_for_each_entry(p, head, hlist) { + if (kprobe_gone(p)) + continue; + if (within_module_init((unsigned long)p->addr, mod) || (checkcore && within_module_core((unsigned long)p->addr, mod))) { @@ -2436,6 +2442,7 @@ static int kprobes_module_callback(struct notifier_block *nb, */ kill_kprobe(p); } + } } if (val == MODULE_STATE_GOING) remove_module_kprobe_blacklist(mod);