]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
cgroup: Remove duplicates in cgroup v1 tasks file
authorMichal Koutný <mkoutny@suse.com>
Mon, 9 Oct 2023 13:58:11 +0000 (15:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Oct 2023 09:13:30 +0000 (11:13 +0200)
commit96f0bf8abaec0511ced9d619b33db12b3cfc1ba3
tree632c491d0bd7bfc7f2b2e98be3c1708a54e74080
parentfe1d40fa6d8d75af3ce441cb70b8ef9eb0fc6cf1
cgroup: Remove duplicates in cgroup v1 tasks file

commit 1ca0b605150501b7dc59f3016271da4eb3e96fce upstream.

One PID may appear multiple times in a preloaded pidlist.
(Possibly due to PID recycling but we have reports of the same
task_struct appearing with different PIDs, thus possibly involving
transfer of PID via de_thread().)

Because v1 seq_file iterator uses PIDs as position, it leads to
a message:
> seq_file: buggy .next function kernfs_seq_next did not update position index

Conservative and quick fix consists of removing duplicates from `tasks`
file (as opposed to removing pidlists altogether). It doesn't affect
correctness (it's sufficient to show a PID once), performance impact
would be hidden by unconditional sorting of the pidlist already in place
(asymptotically).

Link: https://lore.kernel.org/r/20230823174804.23632-1-mkoutny@suse.com/
Suggested-by: Firo Yang <firo.yang@suse.com>
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/cgroup/cgroup-v1.c