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=-15.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 9C233C433ED for ; Fri, 9 Apr 2021 17:25:37 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29EA7610CA for ; Fri, 9 Apr 2021 17:25:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29EA7610CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VYmVP4ktUkeYitXPlDyF9lhzbRxyDWqx9Ffjz8CJ5jE=; b=BH+MYbqWaU75jOK5fj9fPJ4OL sTlhnvjHeHwZFClSjWEE+k7xiWs6xwyTVO+q+oylEI7TZsOr4wsEos0N7GSN178/s9Z0wgC5Cravj ieS8TbfvLA2a+yp/aiXhHc32A+roLJjV0PHZ2SkMFxs8dEhiGFjY0gv72RWmLj40qXqnfm8dCca2a 01QhpTX6nJymaUPKziOTzfrarS6V6BbupthGVJM0udCGSVeMDnrqTgTytxWE56tkIy+qW9mLH8HAe fxe74r6g+w6h/MB7RNvV5hOP1QZfGqoeOopFSwptMWYokzIus7MCxEgUW7IOFdFdFVfU4AWTtFi7X c+VxAcfNw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUurK-001Bj7-BP; Fri, 09 Apr 2021 17:23:54 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lUurI-001Bix-Ao for linux-arm-kernel@desiato.infradead.org; Fri, 09 Apr 2021 17:23:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description; bh=qvStcHhWNQyPu4lxLei70jzOhwMqE5A023taZCYpoDo=; b=tHV/Hk6PmKjiCuVxrIQgwjC9WO hbwW5KxHAOouBBvEo7Ut6xvTn2aYGyev7+gTmXLSB847AH7wNcjHGgUzu3MAvt9CpIuf9jplriwUH qu+ZhzndnfFBMZnYyVnl0br40W78Dg7ch5+J8JlyrNlzpQKb16fzpEoW4sV5OD7qt9FipTYl2pP5p fjzdl7WN8ZU81KfmmjrpR3FLZMxAW1ko8gXGQyQpip1T0WY5X1Mm15zOKN8LiyZHvGO5xNw5AsKiX 6J7XnFmoWJqyB/dGZZ9LUxb7p8gQw6ZO0HkqFoB6JyUB/87E4/fS2nRLAVw9aqBUQghVZBcBgHwEV /WcaJutQ==; Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lUurF-004gkm-My for linux-arm-kernel@lists.infradead.org; Fri, 09 Apr 2021 17:23:50 +0000 Received: from [192.168.254.32] (unknown [47.187.194.202]) by linux.microsoft.com (Postfix) with ESMTPSA id 2863C20B491D; Fri, 9 Apr 2021 10:23:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2863C20B491D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1617989028; bh=qvStcHhWNQyPu4lxLei70jzOhwMqE5A023taZCYpoDo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=T4ImmqdXLAGJIvFYxTu6SgsdlwBWas9eh+eh3cLJxK21QXqL/KbwsO5vwym7fg+FF Ws95uagmaWDAPdWI2ljUAGgx1vmeWWoSOgCBwK3fSRGXJEmfBmGruOmpNqf8ohL+CM RWNNgL9fBV9bvzRuRlmRcZuSJf9I+JGpYtr5TMLw= Subject: Re: [RFC PATCH v2 3/4] arm64: Detect FTRACE cases that make the stack trace unreliable To: Mark Rutland Cc: broonie@kernel.org, jpoimboe@redhat.com, jthierry@redhat.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org References: <705993ccb34a611c75cdae0a8cb1b40f9b218ebd> <20210405204313.21346-1-madvenka@linux.microsoft.com> <20210405204313.21346-4-madvenka@linux.microsoft.com> <20210409122701.GB51636@C02TD0UTHF1T.local> From: "Madhavan T. Venkataraman" Message-ID: Date: Fri, 9 Apr 2021 12:23:47 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210409122701.GB51636@C02TD0UTHF1T.local> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210409_102349_804281_496ECCAE X-CRM114-Status: GOOD ( 19.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org >> Also, the Function Graph Tracer modifies the return address of a traced >> function to a return trampoline to gather tracing data on function return. >> Stack traces taken from that trampoline and functions it calls are >> unreliable as the original return address may not be available in >> that context. Mark the stack trace unreliable accordingly. >> >> Signed-off-by: Madhavan T. Venkataraman >> --- >> arch/arm64/kernel/entry-ftrace.S | 12 +++++++ >> arch/arm64/kernel/stacktrace.c | 61 ++++++++++++++++++++++++++++++++ >> 2 files changed, 73 insertions(+) >> >> diff --git a/arch/arm64/kernel/entry-ftrace.S b/arch/arm64/kernel/entry-ftrace.S >> index b3e4f9a088b1..1f0714a50c71 100644 >> --- a/arch/arm64/kernel/entry-ftrace.S >> +++ b/arch/arm64/kernel/entry-ftrace.S >> @@ -86,6 +86,18 @@ SYM_CODE_START(ftrace_caller) >> b ftrace_common >> SYM_CODE_END(ftrace_caller) >> >> +/* >> + * A stack trace taken from anywhere in the FTRACE trampoline code should be >> + * considered unreliable as a tracer function (patched at ftrace_call) could >> + * potentially set pt_regs->pc and redirect execution to a function different >> + * than the traced function. E.g., livepatch. > > IIUC the issue here that we have two copies of the pc: one in the regs, > and one in a frame record, and so after the update to the regs, the > frame record is stale. > > This is something that we could fix by having > ftrace_instruction_pointer_set() set both. > Yes. I will look at this. > However, as noted elsewhere there are other issues which mean we'd still > need special unwinding code for this. > The only other cases we have discussed are EL1 exceptions in the ftrace code and the return trampoline for function graph tracing. Is there any other case? Thanks. Madhavan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel