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: <20230605161052.033ebe4cecc0a9c879d43f56@linux-foundation.org>
Date:   Mon, 5 Jun 2023 16:10:52 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Huacai Chen <chenhuacai@...ngson.cn>
Cc:     Luis Chamberlain <mcgrof@...nel.org>,
        "Eric W . Biederman" <ebiederm@...ssion.com>,
        Kees Cook <keescook@...omium.org>, chenhuacai@...nel.org,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH V1] kthread: Unify kernel_thread() and
 user_mode_thread()

On Sat,  3 Jun 2023 09:53:02 +0800 Huacai Chen <chenhuacai@...ngson.cn> wrote:

> Commit 343f4c49f2438d8 ("kthread: Don't allocate kthread_struct for init
> and umh") introduces a new function user_mode_thread() for init and umh.
> 
> init and umh are different from typical kernel threads since the don't
> need a "kthread" struct and they will finally become user processes by
> calling kernel_execve(), but on the other hand, they are also different
> from typical user mode threads (they have no "mm" structs at creation
> time, which is traditionally used to distinguish a user thread and a
> kernel thread).
> 
> So I think it is reasonable to treat init and umh as "special kernel
> threads". Then let's unify the kernel_thread() and user_mode_thread()
> to kernel_thread() again, and add a new 'user' parameter for init and
> umh.
> 
> This also makes code simpler. 

Seems fair enough.

If we're attached to the naming then we could do

static inline pid_t user_mode_thread(int (*fn)(void *), void *arg,
				     unsigned long flags)
{
	return __kernel_thread(fn, arg, flags, 0);
}

static inline pid_t kernel_thread(int (*fn)(void *), void *arg,
				     unsigned long flags)
{
	return __kernel_thread(fn, arg, flags, 1);
}

(and pass the 4th arg straight into .kthread to avoid the !user thing)


But the naming isn't very good anyway.  Should have been
usermode_thread/kernel_thread or user_thread/kernel_thread.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ