]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit9e789451540c7f241dac230a9730eb2885eacc4c
tree0142b2e6f7466c7f1f715e6e6c93c1ffb3559912
parentf98cf4e3f3227001ae37f96d9b407a5a821bc2bb
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 12d1d2163e3 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: 12d1d2163e38 ("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