Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp719117ybz; Fri, 17 Apr 2020 08:50:05 -0700 (PDT) X-Google-Smtp-Source: APiQypJAeCc38cNgQNIlzjO7n4zeUK9olkIqLR8FZ6H1cGTcdiB5g0F1DpXDhHKz+7kP3FsRZjnp X-Received: by 2002:a17:906:52c2:: with SMTP id w2mr3595755ejn.117.1587138605371; Fri, 17 Apr 2020 08:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587138605; cv=none; d=google.com; s=arc-20160816; b=ZMSJf5TRrpGLaNMqPln+cfYgY3ZgExvMRDRJCdd03jxUim3LiWOF+fW4eK9rW5G9dj SvlVKQZ2E/dlU6HxZ+M4LAeJ54IA9O4rPmmPCt1cDKQNSVxOnpn8ukv4F+EVcS93EqR6 +EqWbyKqXtk62PeU2zNU8j2uTDsJUiSHf6rvXx7JCCZdS1Zi22ev1iGoyfwfvjC1vTLk TQQxg0TKTEEMSshq9q7R1bFTOaFTiBgsZAOC7ETRebIpsUT7PuL82sIOWIjbhc/P8OSe 7vUX25kFGsbxWkCTeN7lFgSmxB7siSckIVPiwoVer1C/XkOXTkfUrrjVuXHSihcDIi25 bZqg== 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=3C/sbCCuvowD4/D5uv5E1ndFp0/rzXjXTAHK9BAaNAU=; b=RinJUXMFYcSGNtTRzLeZkOowI6j7SUv5HRwbNd5SVpgJquNyGqeeAUktrosIgprGUx hO/MSfBamqVzU9lalfbu3bIhMy/3MiKpjJ1ajEJY4R53RYOtElQYsQSRpdg/3qtNxRCe LDZn3MycvCfyALAniX8GaqQAPuA/r5gFH9EAC/9Orp0oKo2S2rnp2JuBZcScjHmSGW3p GNpA03lmick+BqxLAZJdwwXR5LfDWT9g+CVXeYvdrC8s2rRpLB6lQ1ghdmrHFJc3FsVH QMKHMH/hgh4tAebdno5EJY8L2Q7ThEyBdRTTbV+9RfW60MNl3Vflz9QlczGN+2903y26 rcSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h23si13741216ejs.491.2020.04.17.08.49.42; Fri, 17 Apr 2020 08:50:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729207AbgDQPqU (ORCPT + 99 others); Fri, 17 Apr 2020 11:46:20 -0400 Received: from foss.arm.com ([217.140.110.172]:53060 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728542AbgDQPqU (ORCPT ); Fri, 17 Apr 2020 11:46:20 -0400 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 6F0C81FB; Fri, 17 Apr 2020 08:46:19 -0700 (PDT) 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 920063F73D; Fri, 17 Apr 2020 08:46:16 -0700 (PDT) Date: Fri, 17 Apr 2020 16:46:14 +0100 From: Mark Rutland To: Peter Zijlstra Cc: Sami Tolvanen , Will Deacon , Catalin Marinas , James Morse , Steven Rostedt , Ard Biesheuvel , Masahiro Yamada , Michal Marek , Ingo Molnar , 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 04/12] scs: disable when function graph tracing is enabled Message-ID: <20200417154613.GB9529@lakrids.cambridge.arm.com> References: <20191018161033.261971-1-samitolvanen@google.com> <20200416161245.148813-1-samitolvanen@google.com> <20200416161245.148813-5-samitolvanen@google.com> <20200417100039.GS20730@hirez.programming.kicks-ass.net> <20200417144620.GA9529@lakrids.cambridge.arm.com> <20200417152645.GH20730@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200417152645.GH20730@hirez.programming.kicks-ass.net> 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 Fri, Apr 17, 2020 at 05:26:45PM +0200, Peter Zijlstra wrote: > On Fri, Apr 17, 2020 at 03:46:21PM +0100, Mark Rutland wrote: > > > > diff --git a/arch/Kconfig b/arch/Kconfig > > > > index 691a552c2cc3..c53cb9025ad2 100644 > > > > --- a/arch/Kconfig > > > > +++ b/arch/Kconfig > > > > @@ -542,6 +542,7 @@ config ARCH_SUPPORTS_SHADOW_CALL_STACK > > > > > > > > config SHADOW_CALL_STACK > > > > bool "Clang Shadow Call Stack" > > > > + depends on DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER > > > > depends on ARCH_SUPPORTS_SHADOW_CALL_STACK > > > > help > > > > This option enables Clang's Shadow Call Stack, which uses a > > > > > AFAICT you also need to kill KRETPROBES, which plays similar games. > > > > Hmm... how does KREPROBES work? If you can only mess with the return > > address when probing the first instruction in the function, it'll just > > work for SCS or pointer authentication, as the LR is used at that > > instant. If KRETPROBES tries to mess with the return address elsewhere > > it'd be broken today... > > To be fair, I've not looked at the arm64 implementation. x86 does gross > things like ftrace does. On x86 ftrace_graph and kretprobe also can't > be on at the same time for the same function, there's some yuck around > there. I can imagine the same holds true for us there. > Rostedt was recently talking about cleaning some of that up. > > But if kretprobe can work on arm64, then ftrace_graph can too, but I > think that links back to what you said earlier, you didn't want more > ftrace variants or something. I just want to avoid yet another implementation of the underlying mechanism. For DYNAMIC_FTRACE_WITH_REGS we can mess with the LR before pauth or SCS sees it, so those definitely work. If KRETPROBES works by messing with the LR at the instnat the function is entered, that should work similarly. If it works by replacing the RET it should also work out since any pauth/SCS work will have been undone by that point. If it attempts to mess with the return address in the middle of a function then it's not reliable today. I'll take a look, since > > > And doesn't BPF also do stuff like this? > > > > Can BPF mess with return addresses now!? > > At least on x86 I think it does. But what do I know, I can't operate > that stuff. Rostedt might know. Sounds like I might need to do some digging... Mark.