Commit 24dbb181 authored by Michal Koutný's avatar Michal Koutný Committed by Zhang Changzhong
Browse files

cgroup: Remove duplicates in cgroup v1 tasks file

stable inclusion
from stable-v4.19.297
commit 987fb4353c3bcfdc80e960419eee70e824cdde2c
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8MCB5
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=987fb4353c3bcfdc80e960419eee70e824cdde2c

--------------------------------

commit 1ca0b605 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: default avatarFiro Yang <firo.yang@suse.com>
Signed-off-by: default avatarMichal Koutný <mkoutny@suse.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZhang Changzhong <zhangchangzhong@huawei.com>
parent cc8c90c4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment