On 2025-04-24 13:28, Steven Rostedt wrote:
On Thu, 24 Apr 2025 18:36:07 +0200
Peter Zijlstra <[email protected]> wrote:

+++ b/kernel/events/callchain.c
@@ -246,22 +246,20 @@ get_perf_callchain(struct pt_regs *regs, bool kernel, 
bool user,
if (user) {
                if (!user_mode(regs)) {
-                       if  (current->mm)
-                               regs = task_pt_regs(current);
-                       else
-                               regs = NULL;
+                       if (!current->mm)
+                               goto exit_put;
+                       regs = task_pt_regs(current);

I'm thinking this might be one of those is-kthread test written as
has-mm, and they're broken.

Notably things like the io-uring kthreads do have mm.

Can a kthread such as io-uring have user_mode(regs) == true ?


Would there ever be a case where:

        current->mm == NULL && !(current->flags & PF_KTHREAD)

?

That is, do we still need to check for current->mm if it's not a kernel
thread, or can we assume it exists?

The case I'd be careful about is if the code can nest over exit_mm()
(e.g. interrupt) after it sets current->mm = NULL.

Thanks,

Mathieu


--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

Reply via email to