Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1942456ybv; Sun, 23 Feb 2020 19:01:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwQFjEI+IHQqM5uT13KJIRVS0vUEWB0uqjuyVBJnvG+j4AGS0gyIH0U2su+8iihyvAPy7J4 X-Received: by 2002:a9d:4110:: with SMTP id o16mr38815580ote.101.1582513280727; Sun, 23 Feb 2020 19:01:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582513280; cv=none; d=google.com; s=arc-20160816; b=eMbrSQj6fXW73rOrQDJp1RfuFtX5Dte+JYrcErnG/9d5oxCT57QQLx4DsZgWnkehvX nLg8zv4wF4IFwn8fX0dlw1HtsIoEZkd+bwKqye2c/6Sy5yuaNfDEH1dslH82abkntWmN r9rPPiiwGN/CBnhNseQGja9f56cR2t16fBYE4MDL/gCd7tJxSlwQJogpX0DiLQTOn9rs BcVu3GUR0tMQJvOOIGWmrW8Uuz4QoBrIsut9WemrTvd5qjFg+cPjtU8ZKdUSRsMFn7Ef AU7SzOR50xU7Se+FfbzHRaTxgHnNcH8MN0QbwtDfO9S5hb485lDr4Z7UOdm6Yh1B3ns3 atEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=axj+zYhKgui/GRpLokmGt4hkOovhk9D4qksINrRJ1Ak=; b=wBysCG/gvn2xu8MSkNmGeO5PT6xb+gHxcDKgia9Vivqj8vR40bBttrB+x1fN2IhZ6O jwffbVubbfkheRucuhcp2TYXooxNihqnDo5PgOUWjUPq5c7DWEin1WIgNcpPAT8uR6+0 27pp0hRu+YfBFjmaINCBpbzREZnwwMUZ2PcpNv+YMJytUfgip1ovkysp6EkJO4L3QEqt /fKARC+8HE75fahxff+Kg9SvtUiwe94VSSIT9hatGvPzZ8l+JcbXn16waxduY0uzSEuI 3898LaFe0jK/JfAb9zmkLFobdKEVtJLAG7jv5v1zCOrPPhovGF8zXOzrnwS2MaxUza8a xldw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=f419reAE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v22si4651307oia.30.2020.02.23.19.01.08; Sun, 23 Feb 2020 19:01:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=f419reAE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727187AbgBXDAb (ORCPT + 99 others); Sun, 23 Feb 2020 22:00:31 -0500 Received: from mail-qv1-f66.google.com ([209.85.219.66]:35933 "EHLO mail-qv1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbgBXDAb (ORCPT ); Sun, 23 Feb 2020 22:00:31 -0500 Received: by mail-qv1-f66.google.com with SMTP id ff2so3571945qvb.3 for ; Sun, 23 Feb 2020 19:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=axj+zYhKgui/GRpLokmGt4hkOovhk9D4qksINrRJ1Ak=; b=f419reAEsjTeJdGXZaoZyZpTiWQNTrZvDjlFHYNYo6hws9F1baASusMDFHpIAblfCn MDrLtDYdBa37g4PRqNh/MPFrxz5Z85DqSVa6Dzdzins0kWeNGM++kzZ0/peBTuhv9UYm aqGxFrqA+fqrkOxvGd/d+j1ZSxUtdy6ueQ5HDJ85/8FME2IJ4a9dzvWa2g8Srhpt9dSf 561JzE6H7EI7d1vJtVqCtT6ZWFOhOjkAtZhzDP0P1Qvn7+S9o3evgs8TcB+UVGHp4XcP ATkJnrGXsGL3fYd3Qd07QCnJZ7a7tiJwhOXEUedVP4rxKZTn6s6ROrRoHLSPBHZS/RnR e2mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=axj+zYhKgui/GRpLokmGt4hkOovhk9D4qksINrRJ1Ak=; b=sW7gYDuvol5HR6OUXfM59aiIh6GfK1YazJxCoeEx+AI0qtS4K6npDiWX4eZ1deKM5/ zZajcxdMJHJTG8wyJfof6nfz98my98/9scQIzGOEIkl4FC5dxHzjbY49FRPE/hOoHpo9 Mca+twtY4Ix/oHywzK7HrTx0jVdtzF8t9JzuA0qGHEZL29DUNrrT5oeRMJO6yv3jN8ZD XtBqzA3R6JEB/OMFpcBEjnw/EOty4XQJnwljA+VuqEssrZYezrrwvdmIyyta6TrSz/Gz 0P1W8EVpHZ6Rk2IUlXY7PbBUNKMBCjCxiw6YIoFkNhjCqo0cdeNAscL72eahrOuhiTh9 Twfg== X-Gm-Message-State: APjAAAUMgmOHeCeVGBajAEwzHyanGRrADClBMJvYwsq9tMTInNb8Rtew qfknVLN+MPU97ygdeRBMJYMaAA== X-Received: by 2002:a05:6214:176e:: with SMTP id et14mr40790796qvb.133.1582513230182; Sun, 23 Feb 2020 19:00:30 -0800 (PST) Received: from ovpn-120-117.rdu2.redhat.com (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id t2sm5219859qkc.62.2020.02.23.19.00.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Feb 2020 19:00:29 -0800 (PST) From: Qian Cai To: tj@kernel.org Cc: lizefan@huawei.com, hannes@cmpxchg.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Qian Cai Subject: [PATCH] cgroup: fix psi_show() crash on 32bit ino archs Date: Sun, 23 Feb 2020 22:00:07 -0500 Message-Id: <20200224030007.3990-1-cai@lca.pw> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- kernel/cgroup/cgroup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 75f687301bbf..cd5f41289f7d 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3542,21 +3542,21 @@ static int cpu_stat_show(struct seq_file *seq, void *v) static int cgroup_io_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp = seq_css(seq)->cgroup; - struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi; + struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; return psi_show(seq, psi, PSI_IO); } static int cgroup_memory_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp = seq_css(seq)->cgroup; - struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi; + struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; return psi_show(seq, psi, PSI_MEM); } static int cgroup_cpu_pressure_show(struct seq_file *seq, void *v) { struct cgroup *cgrp = seq_css(seq)->cgroup; - struct psi_group *psi = cgroup_id(cgrp) == 1 ? &psi_system : &cgrp->psi; + struct psi_group *psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; return psi_show(seq, psi, PSI_CPU); } -- 2.21.0 (Apple Git-122.2)