All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>,
	Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Max Filippov <jcmvbkbc@gmail.com>
Subject: [PATCH] kprobes: fix build with CONFIG_KRETPROBES=n
Date: Mon,  2 May 2022 11:40:50 -0700	[thread overview]
Message-ID: <20220502184050.1792743-1-jcmvbkbc@gmail.com> (raw)

When building kernel with CONFIG_KRETPROBES=n kernel/kprobes.c
compilation fails with the following messages:

  kernel/kprobes.c: In function ‘recycle_rp_inst’:
  kernel/kprobes.c:1273:32: error: implicit declaration of function
                                   ‘get_kretprobe’

  kernel/kprobes.c: In function ‘kprobe_flush_task’:
  kernel/kprobes.c:1299:35: error: ‘struct task_struct’ has no member
                                   named ‘kretprobe_instances’

Make references to kretprobe-specific structures and functions
conditional.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 kernel/kprobes.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index dd58c0be9ce2..95ce4d16e63e 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1258,6 +1258,7 @@ void kprobe_busy_end(void)
 }
 
 #if !defined(CONFIG_KRETPROBE_ON_RETHOOK)
+#ifdef CONFIG_KRETPROBES
 static void free_rp_inst_rcu(struct rcu_head *head)
 {
 	struct kretprobe_instance *ri = container_of(head, struct kretprobe_instance, rcu);
@@ -1279,21 +1280,11 @@ static void recycle_rp_inst(struct kretprobe_instance *ri)
 }
 NOKPROBE_SYMBOL(recycle_rp_inst);
 
-/*
- * This function is called from delayed_put_task_struct() when a task is
- * dead and cleaned up to recycle any kretprobe instances associated with
- * this task. These left over instances represent probed functions that
- * have been called but will never return.
- */
-void kprobe_flush_task(struct task_struct *tk)
+static void kretprobe_flush_task(struct task_struct *tk)
 {
 	struct kretprobe_instance *ri;
 	struct llist_node *node;
 
-	/* Early boot, not yet initialized. */
-	if (unlikely(!kprobes_initialized))
-		return;
-
 	kprobe_busy_begin();
 
 	node = __llist_del_all(&tk->kretprobe_instances);
@@ -1306,6 +1297,25 @@ void kprobe_flush_task(struct task_struct *tk)
 
 	kprobe_busy_end();
 }
+NOKPROBE_SYMBOL(kretprobe_flush_task);
+#endif
+
+/*
+ * This function is called from delayed_put_task_struct() when a task is
+ * dead and cleaned up to recycle any kretprobe instances associated with
+ * this task. These left over instances represent probed functions that
+ * have been called but will never return.
+ */
+void kprobe_flush_task(struct task_struct *tk)
+{
+	/* Early boot, not yet initialized. */
+	if (unlikely(!kprobes_initialized))
+		return;
+
+#ifdef CONFIG_KRETPROBES
+	kretprobe_flush_task(tk);
+#endif
+}
 NOKPROBE_SYMBOL(kprobe_flush_task);
 
 static inline void free_rp_inst(struct kretprobe *rp)
-- 
2.30.2


             reply	other threads:[~2022-05-02 18:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 18:40 Max Filippov [this message]
2022-05-04  2:21 ` [PATCH] kprobes: fix build with CONFIG_KRETPROBES=n Masami Hiramatsu
2022-05-04  3:36 ` [PATCH] kprobes: Fix build errors " Masami Hiramatsu
2022-05-04  4:28   ` Masami Hiramatsu
2022-05-04 17:53   ` Max Filippov
2022-05-05  0:31     ` Masami Hiramatsu
2022-05-07 13:57       ` Steven Rostedt
2022-05-24 20:30         ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220502184050.1792743-1-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.