cgroup/cpuset: Fix partition root's cpuset.cpus update bug
authorWaiman Long <longman@redhat.com>
Fri, 17 Mar 2023 15:15:05 +0000 (11:15 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Apr 2023 10:35:13 +0000 (12:35 +0200)
commitf06c9b01540c3bf7340d8bb80ce852056933006a
tree4b20b8ffb02cb60d886cb8f4e9cd95756ea6b03e
parent53244494bfcb9612b660f84c8c4f9b2282a766cd
cgroup/cpuset: Fix partition root's cpuset.cpus update bug

commit 292fd843de26c551856e66faf134512c52dd78b4 upstream.

It was found that commit 7a2127e66a00 ("cpuset: Call
set_cpus_allowed_ptr() with appropriate mask for task") introduced a bug
that corrupted "cpuset.cpus" of a partition root when it was updated.

It is because the tmp->new_cpus field of the passed tmp parameter
of update_parent_subparts_cpumask() should not be used at all as
it contains important cpumask data that should not be overwritten.
Fix it by using tmp->addmask instead.

Also update update_cpumask() to make sure that trialcs->cpu_allowed
will not be corrupted until it is no longer needed.

Fixes: 7a2127e66a00 ("cpuset: Call set_cpus_allowed_ptr() with appropriate mask for task")
Signed-off-by: Waiman Long <longman@redhat.com>
Cc: stable@vger.kernel.org # v6.2+
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/cgroup/cpuset.c