]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf: Have get_perf_callchain() return NULL if crosstask and user are set
authorJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 20 Aug 2025 18:03:40 +0000 (14:03 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 2 Nov 2025 13:18:03 +0000 (22:18 +0900)
[ Upstream commit 153f9e74dec230f2e070e16fa061bc7adfd2c450 ]

get_perf_callchain() doesn't support cross-task unwinding for user space
stacks, have it return NULL if both the crosstask and user arguments are
set.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250820180428.426423415@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/events/callchain.c

index decff7266cfbd6b6aced1ecd701119abe2772022..2609998ca07f1f7ff3d48c3c87800677dcdf0c2d 100644 (file)
@@ -224,6 +224,10 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
        struct perf_callchain_entry_ctx ctx;
        int rctx, start_entry_idx;
 
+       /* crosstask is not supported for user stacks */
+       if (crosstask && user && !kernel)
+               return NULL;
+
        entry = get_callchain_entry(&rctx);
        if (!entry)
                return NULL;
@@ -240,7 +244,7 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
                perf_callchain_kernel(&ctx, regs);
        }
 
-       if (user) {
+       if (user && !crosstask) {
                if (!user_mode(regs)) {
                        if (current->flags & (PF_KTHREAD | PF_USER_WORKER))
                                regs = NULL;
@@ -249,9 +253,6 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
                }
 
                if (regs) {
-                       if (crosstask)
-                               goto exit_put;
-
                        if (add_mark)
                                perf_callchain_store_context(&ctx, PERF_CONTEXT_USER);
 
@@ -261,7 +262,6 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, bool kernel, bool user,
                }
        }
 
-exit_put:
        put_callchain_entry(rctx);
 
        return entry;