Re: [RFC][PATCH 1/2] kthread: Add is_user_thread() and is_kernel_thread() helper functions

Steven Rostedt
2025-04-26T12:36:38Z

On Fri, 25 Apr 2025 16:03:16 -0700
Kees Cook <kees@kernel.org> wrote:

> > +static __always_inline bool is_kernel_thread(struct task_struct *task)
> > +{
> > + return task->flags & PF_KTHREAD;
>
> nit: maybe do explicit type conversion:
>
> return !!(task->flags & PF_KTHREAD);
>
> but that's just a style issue, really.

I may use Boris's suggestion (which I thought of doing originally too)
and have this return:

return !is_user_thread(task);

>
> Reviewed-by: Kees Cook <kees@kernel.org>

Thanks.

>
> Thank you for not using current->mm -- KUnit, live patching, etc, all
> use current->mm but are kthreads. :)

Yeah, Peter was stressing this.

-- Steve