lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250425161449.7a2516b3fe0d5de3e2d2b677@linux-foundation.org>
Date: Fri, 25 Apr 2025 16:14:49 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org, Masami
 Hiramatsu <mhiramat@...nel.org>, Mark Rutland <mark.rutland@....com>,
 Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, Peter Zijlstra
 <peterz@...radead.org>, Linus Torvalds <torvalds@...ux-foundation.org>,
 Ingo Molnar <mingo@...hat.com>, x86@...nel.org, Kees Cook
 <kees@...nel.org>, bpf@...r.kernel.org, Tejun Heo <tj@...nel.org>, Julia
 Lawall <Julia.Lawall@...ia.fr>, Nicolas Palix <nicolas.palix@...g.fr>,
 cocci@...ia.fr
Subject: Re: [RFC][PATCH 0/2] Add is_user_thread() and is_kernel_thread()
 helper functions

On Fri, 25 Apr 2025 16:41:20 -0400 Steven Rostedt <rostedt@...dmis.org> wrote:

> While working on the deferred stacktrace code, Peter Zijlstra told
> me to use task->flags & PF_KTHREAD instead of checking task->mm for NULL.
> This seemed reasonable, but while working on it, as there were several
> places that check if the task is a kernel thread and other places that
> check if the task is a user space thread I found it a bit confusing
> when looking at both:
> 
> 	if (task->flags & PF_KTHREAD)
> and
> 	if (!(task->flags & PF_KTHREAD))
> 
> Where I mixed them up sometimes, and checked for a user space thread when I
> really wanted to check for a kernel thread. I found these mistakes before
> sending out my patches, but going back and reviewing the code, I always had
> to stop and spend a few unnecessary seconds making sure the check was
> testing that flag correctly.
> 
> To make this a bit more obvious, I introduced two helper functions:
> 
> 	is_user_thread(task)
> 	is_kernel_thread(task)
> 
> which simply test the flag for you. Thus, seeing:
> 
> 	if (is_user_thread(task))
> or
> 	if (is_kernel_thread(task))
> 
> it was very obvious to which test you wanted to make.

Seems sensible.  Please consider renaming PF_KTHREAD in order to break
missed conversion sites.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ