From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CAD14A02; Sat, 26 Apr 2025 12:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745670998; cv=none; b=XJQaXYrs41rGIaeexkN6CKEofyTvnJ755kxqd/Xv3clT9jcJZn8RP653ytexf7UI5UZPT2IfokzBmuXd1BxB/fKzXyMf0x0OwtcwSGX2wGESieEf9MgNjyzM7aiXxe5/QW8svsrUMSwlQk/UkssQp8MwcH/KKLaHl+Ob06k78TQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745670998; c=relaxed/simple; bh=c1/6bhetYzynX5wt9IYS4FQqt0Cw7IxKGHtBcV9vP/c=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=udvaH+2x1jchdh30mDoC/uxzEHtxWkelM/i/iOFhqgnoS7p1kR80klcqoCtbapmRJoShubEuAIPgBEwgsKb+feKBhuxeOxUdLT7UXvBzNCLjXPxi3y3ETWU/lnvNFjcP1QF6Of1yFFBjiHaz6hGPKXczThUdAk+lKAYzIsJvxOM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29D9CC4CEE2; Sat, 26 Apr 2025 12:36:36 +0000 (UTC) Date: Sat, 26 Apr 2025 08:36:34 -0400 From: Steven Rostedt To: Kees Cook Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Peter Zijlstra , Linus Torvalds , Ingo Molnar , x86@kernel.org, bpf@vger.kernel.org, Tejun Heo , Julia Lawall , Nicolas Palix , cocci@inria.fr Subject: Re: [RFC][PATCH 1/2] kthread: Add is_user_thread() and is_kernel_thread() helper functions Message-ID: <20250426083634.25897a33@batman.local.home> In-Reply-To: <202504251601.5D29BF8F01@keescook> References: <20250425204120.639530125@goodmis.org> <20250425204313.616425861@goodmis.org> <202504251601.5D29BF8F01@keescook> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 25 Apr 2025 16:03:16 -0700 Kees Cook 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 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