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] [day] [month] [year] [list]
Message-ID: <Zn0ZcZRqejmSRqsZ@tiehlicka>
Date: Thu, 27 Jun 2024 09:49:05 +0200
From: Michal Hocko <mhocko@...e.com>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] get_task_mm: check PF_KTHREAD lockless

On Wed 26-06-24 21:10:17, Oleg Nesterov wrote:
> Nowadays PF_KTHREAD is sticky and it was never protected by ->alloc_lock.
> Move the PF_KTHREAD check outside of task_lock() section to make this code
> more understandable.
> 
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>

Acked-by: Michal Hocko <mhocko@...e.com>
Thanks!

> ---
>  kernel/fork.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 4c361d2bdc12..d3dc623a1247 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -1536,14 +1536,13 @@ struct mm_struct *get_task_mm(struct task_struct *task)
>  {
>  	struct mm_struct *mm;
>  
> +	if (task->flags & PF_KTHREAD)
> +		return NULL;
> +
>  	task_lock(task);
>  	mm = task->mm;
> -	if (mm) {
> -		if (task->flags & PF_KTHREAD)
> -			mm = NULL;
> -		else
> -			mmget(mm);
> -	}
> +	if (mm)
> +		mmget(mm);
>  	task_unlock(task);
>  	return mm;
>  }
> -- 
> 2.25.1.362.g51ebf55
> 

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ