linux-stable/kernel/cgroup
Michal Koutný 987fb4353c cgroup: Remove duplicates in cgroup v1 tasks file
commit 1ca0b60515 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>
2023-10-25 11:16:34 +02:00
..
cgroup-internal.h memcg: fix possible use-after-free in memcg_write_event_control() 2022-12-14 11:28:27 +01:00
cgroup-v1.c cgroup: Remove duplicates in cgroup v1 tasks file 2023-10-25 11:16:34 +02:00
cgroup.c cgroup: Do not corrupt task iteration when rebinding subsystem 2023-06-28 10:15:28 +02:00
cpuset.c cgroup/cpuset: Wake up cpuset_attach_wq tasks in cpuset_cancel_attach() 2023-04-20 12:04:40 +02:00
debug.c debug cgroup: use task_css_set instead of rcu_dereference 2017-11-27 11:37:33 -08:00
freezer.c cgroup: add @flags to css_task_iter_start() and implement CSS_TASK_ITER_PROCS 2017-07-21 11:14:51 -04:00
Makefile cgroup: Rename kernel/cgroup/stat.c to kernel/cgroup/rstat.c 2018-04-26 14:29:04 -07:00
namespace.c cgroup:namespace: Remove unused cgroup_namespaces_init() 2023-09-23 10:48:08 +02:00
pids.c cgroup: pids: use atomic64_t for pids->limit 2019-12-17 20:34:56 +01:00
rdma.c rdmacg: Convert to use match_string() helper 2018-05-07 09:27:26 -07:00
rstat.c Revert "cgroup: Add memory barriers to plug cgroup_rstat_updated() race window" 2020-06-07 13:17:53 +02:00