From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBC66C3815B for ; Mon, 20 Apr 2020 17:18:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A81BE21D79 for ; Mon, 20 Apr 2020 17:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587403085; bh=8Cti+W7qcMTc3i7ivCfS06mEpTJP5zYv2iWrbD/RTtg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=XVbgeQUaGE5CEAbxU5Yevlh2V0iNe3zdrYI3F5Ny1M+C7b7gRt536Mm8ilAtHHCb6 fK0xKy5aXc4wzU1M652DvB29phfsh2nvOK2JAipWE+UrDWL7hize1gH+7Wp4uvcUP4 4KS+xGxos9SNG/FrBtms6/OshWDGg3zyOW6jh3ak= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726743AbgDTRSE (ORCPT ); Mon, 20 Apr 2020 13:18:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:44862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726724AbgDTRSC (ORCPT ); Mon, 20 Apr 2020 13:18:02 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EEDC02145D; Mon, 20 Apr 2020 17:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587403081; bh=8Cti+W7qcMTc3i7ivCfS06mEpTJP5zYv2iWrbD/RTtg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n8kgySIFfBQIcj6Ia2jB/kXabMFi8z3ZnfxRD6sXtUSU5WkP7GyhdFFnNX9oGyhnV mhWjwdOQ+04RDru0OIhK+bLIVHdU0fkAMOot1o2sNYiPhmoqv95P7YoCTgT0+QheZR P5uQTK0OZzAOJTiqi4PCUeQwAx7St1L9HyeIHsPI= Date: Mon, 20 Apr 2020 18:17:55 +0100 From: Will Deacon To: Sami Tolvanen Cc: Catalin Marinas , James Morse , Steven Rostedt , Ard Biesheuvel , Mark Rutland , Masahiro Yamada , Michal Marek , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dave Martin , Kees Cook , Laura Abbott , Marc Zyngier , Masami Hiramatsu , Nick Desaulniers , Jann Horn , Miguel Ojeda , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v11 02/12] scs: add accounting Message-ID: <20200420171753.GD24386@willie-the-truck> References: <20191018161033.261971-1-samitolvanen@google.com> <20200416161245.148813-1-samitolvanen@google.com> <20200416161245.148813-3-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200416161245.148813-3-samitolvanen@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 16, 2020 at 09:12:35AM -0700, Sami Tolvanen wrote: > This change adds accounting for the memory allocated for shadow stacks. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Kees Cook > --- > drivers/base/node.c | 6 ++++++ > fs/proc/meminfo.c | 4 ++++ > include/linux/mmzone.h | 3 +++ > kernel/scs.c | 20 ++++++++++++++++++++ > mm/page_alloc.c | 6 ++++++ > mm/vmstat.c | 3 +++ > 6 files changed, 42 insertions(+) > > diff --git a/drivers/base/node.c b/drivers/base/node.c > index 10d7e818e118..502ab5447c8d 100644 > --- a/drivers/base/node.c > +++ b/drivers/base/node.c > @@ -415,6 +415,9 @@ static ssize_t node_read_meminfo(struct device *dev, > "Node %d AnonPages: %8lu kB\n" > "Node %d Shmem: %8lu kB\n" > "Node %d KernelStack: %8lu kB\n" > +#ifdef CONFIG_SHADOW_CALL_STACK > + "Node %d ShadowCallStack:%8lu kB\n" > +#endif > "Node %d PageTables: %8lu kB\n" > "Node %d NFS_Unstable: %8lu kB\n" > "Node %d Bounce: %8lu kB\n" > @@ -438,6 +441,9 @@ static ssize_t node_read_meminfo(struct device *dev, > nid, K(node_page_state(pgdat, NR_ANON_MAPPED)), > nid, K(i.sharedram), > nid, sum_zone_node_page_state(nid, NR_KERNEL_STACK_KB), > +#ifdef CONFIG_SHADOW_CALL_STACK > + nid, sum_zone_node_page_state(nid, NR_KERNEL_SCS_BYTES) / 1024, > +#endif Why not just use KB everywhere instead of repeated division by 1024? Will