Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp487009ybv; Wed, 19 Feb 2020 03:35:49 -0800 (PST) X-Google-Smtp-Source: APXvYqwlAxsA8ITNwSOeGApc4qFwCRHYlAv0u7ACKRnCupzPUIBxtn1rqPBA3OaNfOaWysbUYBGl X-Received: by 2002:a05:6830:16d0:: with SMTP id l16mr19723992otr.83.1582112148911; Wed, 19 Feb 2020 03:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582112148; cv=none; d=google.com; s=arc-20160816; b=o0o3s7Pl0QKx/G+Hprp9LTagKznEpVzeIDhU5pJa01QkWxlinuhotqD6/hKpNvVEXA 9g4XB/6P6qG1A+qEii9aS2zwMfLxJMib0VysfFVexXtp0vvcw0v5TvI0RkjU13PzYDiS mZyEyLwGjPSySanDaSSUmky2a/ojnXG3+NVmWa4PfJT6OStSh6Bj4iGmYi1nGYDencjN u7ZDd0HIBZ5FMeTn/cCz1TxQyJESBQ2Yjr+ciQkdoRJHVMGub4coQIrt4oJGQjEhEylt YRzSnDEhaCzlZMGgayJOLBEve8qeYx2bO3Ye9cbjwG0Q1vbDfP3kfJebO1ujQpF83mWX lqmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ut/0EMjOR/6U6ZnSunp5g3bA54seIRMbAc7PD2SvjwE=; b=BrVGDO45jqbxyJZHZTYXls40XOHkMdnQUnyVQey/VtqPsc3csVfOISjH0UoKuWAWfh LAbl92hxO77vU85quumD9j8cNB/ng1Yebr/bhm/2GP1iwPJDgwbmrZPjExOQlSsf0SlC YFONIWn7ad6EkrcCntY/zU8XZkTGXNGDv0iTGp8umE7MYUrWV3R/zFE0+gxDyrW9GJy3 LrYzeQlqmsYZPqLhsZXR6UVu+0DhvcaHpigVXTnq8tf9VMZjIZsQII2ZAm2Leb5bn2QL lzPAzBrJJB/+raRAtWnElTu2ESAAl+S05ci/+uCMIQu64Zym2RjiNgUP3iZr50l3e42U jrWw== ARC-Authentication-Results: i=1; mx.google.com; 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 w7si9354193oie.196.2020.02.19.03.35.37; Wed, 19 Feb 2020 03:35:48 -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; 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 S1727135AbgBSLeE (ORCPT + 99 others); Wed, 19 Feb 2020 06:34:04 -0500 Received: from foss.arm.com ([217.140.110.172]:46970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbgBSLeE (ORCPT ); Wed, 19 Feb 2020 06:34:04 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D7CD631B; Wed, 19 Feb 2020 03:34:03 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8AF023F6CF; Wed, 19 Feb 2020 03:34:01 -0800 (PST) Date: Wed, 19 Feb 2020 11:33:52 +0000 From: Mark Rutland To: Sami Tolvanen Cc: Will Deacon , Catalin Marinas , Steven Rostedt , Masami Hiramatsu , Ard Biesheuvel , james.morse@arm.com, Dave Martin , Kees Cook , Laura Abbott , Marc Zyngier , Nick Desaulniers , Jann Horn , Miguel Ojeda , Masahiro Yamada , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 04/12] scs: disable when function graph tracing is enabled Message-ID: <20200219113351.GA14462@lakrids.cambridge.arm.com> References: <20191018161033.261971-1-samitolvanen@google.com> <20200219000817.195049-1-samitolvanen@google.com> <20200219000817.195049-5-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200219000817.195049-5-samitolvanen@google.com> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 18, 2020 at 04:08:09PM -0800, Sami Tolvanen wrote: > The graph tracer hooks returns by modifying frame records on the > (regular) stack, but with SCS the return address is taken from the > shadow stack, and the value in the frame record has no effect. As we > don't currently have a mechanism to determine the corresponding slot > on the shadow stack (and to pass this through the ftrace > infrastructure), for now let's disable SCS when the graph tracer is > enabled. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Kees Cook > --- > arch/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/Kconfig b/arch/Kconfig > index 66b34fd0df54..4102b8e0eea9 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -535,6 +535,7 @@ config ARCH_SUPPORTS_SHADOW_CALL_STACK > > config SHADOW_CALL_STACK > bool "Clang Shadow Call Stack" > + depends on !FUNCTION_GRAPH_TRACER Fangrui Song has implemented `-fpatchable-function-entry` in LLVM (for 10.x onwards), so we can support this when DYNAMIC_FTRACE_WITH_REGS is selected. This can be: depends on DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER ... and we can update the commit message to something like: | With SCS the return address is taken from the shadow stack and the | value in the frame record has no effect. The mcount based graph tracer | hooks returns by modifying frame records on the (regular) stack, and | thus is not compatible. The patchable-function-entry graph tracer | used for DYNAMIC_FTRACE_WITH_REGS modifies the LR before it is saved | to the shadow stack, and is compatible. | | Modifying the mcount based graph tracer to work with SCS would require | a mechanism to determine the corresponding slot on the shadow stack | (and to pass this through the ftrace infrastructure), and we expect | that everyone will eventually move to the patchable-function-entry | based graph tracer anyway, so for now let's disable SCS when the | mcount-based graph tracer is enabled. | | SCS and patchable-function-entry are both supported from LLVM 10.x. Assuming you're happy with that: Reviewed-by: Mark Rutland Thanks, Mark.