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

From: Steven Rostedt
Date: Sat Apr 26 2025 - 08:36:50 EST


On Fri, 25 Apr 2025 16:03:16 -0700
Kees Cook <kees@xxxxxxxxxx> 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@xxxxxxxxxx>

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