Files
twx-linux/include/linux
Oleg Nesterov d0bc74c563 cgroup/pids: turn cgroup_subsys->free() into cgroup_subsys->release() to fix the accounting
[ Upstream commit 51bee5abea ]

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@redhat.com>
Reported-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-04-05 22:33:13 +02:00
..
2018-05-26 09:16:44 +02:00
2011-03-11 14:25:50 +00:00
2018-07-24 14:43:26 -06:00
2018-05-09 17:25:13 +02:00
2018-06-19 10:06:29 -07:00
2018-03-26 15:09:38 +02:00
2018-08-22 10:52:48 -07:00
2019-03-23 20:10:09 +01:00
2012-02-20 19:46:36 +11:00
2016-10-28 08:48:16 -06:00
2018-07-22 14:13:43 +02:00
2012-10-16 18:49:15 -07:00
2018-01-01 12:40:27 -07:00
2018-07-24 19:11:26 +02:00
2017-08-07 17:22:14 +02:00
2014-12-31 13:06:50 -05:00
2018-07-12 10:04:29 -04:00
2019-04-05 22:33:12 +02:00
2014-10-09 11:35:48 +03:00
2017-11-13 01:41:20 +01:00
2018-11-13 11:08:50 -08:00
2018-07-27 09:57:23 +10:00
2018-06-28 20:32:51 +09:00
2018-09-04 21:31:43 +02:00
2010-02-09 11:13:56 +01:00
2018-03-26 08:53:43 -06:00
2018-08-08 11:06:20 +02:00
2018-06-22 13:43:27 +09:00
2014-03-13 12:11:00 +10:30
2016-01-28 14:19:12 -08:00
2018-04-11 10:28:38 -07:00
2018-06-21 12:33:21 +02:00
2018-07-12 21:35:28 +02:00
2017-12-01 13:09:40 -08:00
2018-04-12 09:41:19 -07:00
2017-02-24 17:46:57 -08:00
2017-08-28 20:51:22 +02:00
2018-06-05 08:50:16 -04:00
2018-06-07 17:34:35 -07:00
2018-04-11 10:28:32 -07:00
2018-06-07 17:34:39 -07:00
2018-03-26 13:14:43 -04:00
2018-03-26 13:14:43 -04:00
2016-04-25 15:09:11 -04:00
2018-08-22 10:52:45 -07:00
2018-01-28 22:17:24 -05:00
2018-01-31 17:18:37 -08:00
2018-07-25 13:41:22 -07:00
2018-07-21 10:43:12 -05:00
2017-12-16 02:05:48 +01:00
2018-07-20 01:11:45 +02:00
2018-08-02 17:33:06 -04:00
2018-08-02 17:16:05 +02:00
2018-07-07 17:25:23 +02:00
2018-07-03 09:20:44 +02:00
2018-05-03 15:55:23 -07:00
2018-08-16 12:14:42 -07:00
2018-01-15 12:07:46 -08:00
2013-04-30 15:50:12 +05:30
2018-06-20 11:35:56 +02:00
2018-11-13 11:08:51 -08:00
2015-10-01 09:57:59 -07:00
2018-02-06 18:32:44 -08:00
2014-11-28 16:08:16 +01:00
2017-12-20 09:53:54 -07:00
2018-05-14 09:51:34 -04:00
2017-08-15 09:02:07 -07:00
2011-01-13 08:03:24 -08:00
2013-10-17 15:53:09 -04:00
2017-08-15 09:02:08 -07:00