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]
Date:   Thu, 31 Jan 2019 06:56:20 -0800
From:   Tejun Heo <tj@...nel.org>
To:     Oleg Nesterov <oleg@...hat.com>
Cc:     Johannes Weiner <hannes@...xchg.org>,
        Li Zefan <lizefan@...wei.com>,
        Herton Krzesinski <hkrzesin@...hat.com>,
        Jan Stancek <jstancek@...hat.com>, cgroups@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cgroup/pids: turn cgroup_subsys->free() into
 cgroup_subsys->release() to fix the accounting

On Mon, Jan 28, 2019 at 05:00:13PM +0100, Oleg Nesterov wrote:
> The only user of cgroup_subsys->free() callback is pids_cgrp_subsys which
> needs pids_free() to uncharge the pid.
> 
> However, ->free() is called from __put_task_struct()->cgroup_free() and this
> is too late. Even the trivial program which does
> 
> 	for (;;) {
> 		int pid = fork();
> 		assert(pid >= 0);
> 		if (pid)
> 			wait(NULL);
> 		else
> 			exit(0);
> 	}
> 
> can run out of limits because release_task()->call_rcu(delayed_put_task_struct)
> implies an RCU gp after the task/pid goes away and before the final put().
> 
> Test-case:
> 
> 	mkdir -p /tmp/CG
> 	mount -t cgroup2 none /tmp/CG
> 	echo '+pids' > /tmp/CG/cgroup.subtree_control
> 
> 	mkdir /tmp/CG/PID
> 	echo 2 > /tmp/CG/PID/pids.max
> 
> 	perl -e 'while ($p = fork) { wait; } $p // die "fork failed: $!\n"' &
> 	echo $! > /tmp/CG/PID/cgroup.procs
> 
> Without this patch the forking process fails soon after migration.
> 
> Rename cgroup_subsys->free() to cgroup_subsys->release() and move the callsite
> into the new helper, cgroup_release(), called by release_task() which actually
> frees the pid(s).
> 
> Reported-by: Herton R. Krzesinski <hkrzesin@...hat.com>
> Reported-by: Jan Stancek <jstancek@...hat.com>
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>

Applied to cgroup/for-5.0.

Thanks, Oleg.

-- 
tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ