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: <20250425100707.GA8093@redhat.com>
Date: Fri, 25 Apr 2025 12:07:07 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Jiayuan Chen <jiayuan.chen@...ux.dev>
Cc: linux-kernel@...r.kernel.org, mrpre@....com, mkoutny@...e.com,
	syzbot+adcaa842b762a1762e7d@...kaller.appspotmail.com,
	syzbot+fab52e3459fa2f95df57@...kaller.appspotmail.com,
	syzbot+0718f65353d72efaac1e@...kaller.appspotmail.com,
	Andrew Morton <akpm@...ux-foundation.org>,
	Christian Brauner <brauner@...nel.org>,
	Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
	"Liam R. Howlett" <Liam.Howlett@...cle.com>,
	Suren Baghdasaryan <surenb@...gle.com>,
	Wei Yang <richard.weiyang@...il.com>,
	David Hildenbrand <david@...hat.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Mateusz Guzik <mjguzik@...il.com>,
	Joel Granados <joel.granados@...nel.org>,
	Bill O'Donnell <bodonnel@...hat.com>,
	"Darrick J. Wong" <djwong@...nel.org>,
	Frederic Weisbecker <frederic@...nel.org>
Subject: Re: [PATCH v2] pid: annotate data-races around pid_ns->pid_allocated

On 04/25, Jiayuan Chen wrote:
>
> @@ -2584,7 +2584,7 @@ __latent_entropy struct task_struct *copy_process(
>  	rseq_fork(p, clone_flags);
>
>  	/* Don't start children in a dying pid namespace */
> -	if (unlikely(!(ns_of_pid(pid)->pid_allocated & PIDNS_ADDING))) {
> +	if (unlikely(!(data_race(ns_of_pid(pid)->pid_allocated & PIDNS_ADDING)))) {

Well. data_race() just hides the potential problem. READ_ONCE() makes more
sense imo, even if I think there are no real problems with the current code.

Either way,

> @@ -271,13 +271,13 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
>  	upid = pid->numbers + ns->level;
>  	idr_preload(GFP_KERNEL);
>  	spin_lock(&pidmap_lock);
> -	if (!(ns->pid_allocated & PIDNS_ADDING))
> +	if (!(data_race(ns->pid_allocated & PIDNS_ADDING)))

again, you do not need data_race() or READ_ONCE() if you read the
data protected by pidmap_lock. But you still need WRITE_ONCE() when
->pid_allocated is modified.

Oleg.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ