cgroup: fix psi_show() crash on 32bit ino archs
authorQian Cai <cai@lca.pw>
Mon, 24 Feb 2020 03:00:07 +0000 (22:00 -0500)
committerTejun Heo <tj@kernel.org>
Wed, 4 Mar 2020 16:15:58 +0000 (11:15 -0500)
commit190ecb190a9cd8c0599d8499b901e3c32e87966a
tree2893bb1920caa0d2912bc1bdc415333f4ce3aad0
parent9c974c77246460fa6a92c18554c3311c8c83c160
cgroup: fix psi_show() crash on 32bit ino archs

Similar to the commit d7495343228f ("cgroup: fix incorrect
WARN_ON_ONCE() in cgroup_setup_root()"), cgroup_id(root_cgrp) does not
equal to 1 on 32bit ino archs which triggers all sorts of issues with
psi_show() on s390x. For example,

 BUG: KASAN: slab-out-of-bounds in collect_percpu_times+0x2d0/
 Read of size 4 at addr 000000001e0ce000 by task read_all/3667
 collect_percpu_times+0x2d0/0x798
 psi_show+0x7c/0x2a8
 seq_read+0x2ac/0x830
 vfs_read+0x92/0x150
 ksys_read+0xe2/0x188
 system_call+0xd8/0x2b4

Fix it by using cgroup_ino().

Fixes: 743210386c03 ("cgroup: use cgrp->kn->id as the cgroup ID")
Signed-off-by: Qian Cai <cai@lca.pw>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org # v5.5
kernel/cgroup/cgroup.c