cgroup: fix psi monitor for root cgroup
authorOdin Ugedal <odin@uged.al>
Sat, 16 Jan 2021 17:36:33 +0000 (18:36 +0100)
committerTejun Heo <tj@kernel.org>
Tue, 19 Jan 2021 16:37:05 +0000 (11:37 -0500)
commit385aac1519417b89cb91b77c22e4ca21db563cd0
tree0142b2e6f7466c7f1f715e6e6c93c1ffb3559912
parentb5e56576e16236de3c035ca86cd3ef16591722fb
cgroup: fix psi monitor for root cgroup

Fix NULL pointer dereference when adding new psi monitor to the root
cgroup. PSI files for root cgroup was introduced in df5ba5be742 by using
system wide psi struct when reading, but file write/monitor was not
properly fixed. Since the PSI config for the root cgroup isn't
initialized, the current implementation tries to lock a NULL ptr,
resulting in a crash.

Can be triggered by running this as root:
$ tee /sys/fs/cgroup/cpu.pressure <<< "some 10000 1000000"

Signed-off-by: Odin Ugedal <odin@uged.al>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Dan Schatzberg <dschatzberg@fb.com>
Fixes: df5ba5be7425 ("kernel/sched/psi.c: expose pressure metrics on root cgroup")
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: stable@vger.kernel.org # 5.2+
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup/cgroup.c