From patchwork Fri Oct 15 12:51:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 12561449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71F8BC433F5 for ; Fri, 15 Oct 2021 12:56:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3076A60F56 for ; Fri, 15 Oct 2021 12:56:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3076A60F56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=McJNLkIySxMjXiQI+CnK6wF0N7fLq5vASRWNlu0Gnx0=; b=GOocO5gWjCj9+B c6XDBGu1cR6AwfozCOCh7OTPcNfyeO+JH479Dj46gkWovqj1LL9Q3CQVo9MVuzNeLLTaRnQl7qdFB ZuZLJAbaEFBSTYmMRS6vD4357b4qCoCqanmV9yrY8sKINfOttdfdvf5cvrQg45ud5ndLf36FQEB29 RNPbIZ8Dn4fkg/54MPTQngQh1NnP8vl4RVZ039TfmxribFzBO85z0oNeKHGgqKTQCvRV9sQsDyxCl EcsIt7qS3IzJKa9t+HsE11qdOz7eZctSd1fCXcwzPQpg4AoR78KEPh0HVtTUET5nzUKDXVW0xYvZ+ u467jz7MKTsPMQb2ACjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbMjB-0072xL-A2; Fri, 15 Oct 2021 12:54:26 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbMgG-0071Bt-3Y for linux-arm-kernel@lists.infradead.org; Fri, 15 Oct 2021 12:51:25 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4DF116101E; Fri, 15 Oct 2021 12:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634302283; bh=EmhCA26E8wn4zdfBxKo6rHymp3Y5IgKibhi1RWKA/b4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pAPPkNGFdFCe5qUiVmxBp7YRi8CoeGwrGAqJ37ZOojicAKBUvLg0ddaMH96u8lzSN DPFDCctw8fwrLeuMtP7Gu23bKNhH1A4Z3W2TgEEfTjhOeAl7uitfFPmSQu1DrdnQLH kIOV1YBR7On3Wh8XyesbQve4ACDwIvQdfSTX451gLNaNzP2cXMHpySAUU++LGu2ny/ tu1GCVhsnLo0r56zFGjK2JCbMlHX2dx2klko36zYxOnrWQpdf5ZBK4Y80q3s96/0TF Ri1o5J15QcCpOzTeqvFsp7od/YvOOnT/VQXLrCELBrM9kPFMgNsr5g2zWilQ/YrVQM RqvZnMwNzYRbA== From: Masami Hiramatsu To: Steven Rostedt Cc: "Naveen N . Rao" , Ananth N Mavinakayanahalli , Ingo Molnar , linux-kernel@vger.kernel.org, mhiramat@kernel.org, Sven Schnelle , Catalin Marinas , Will Deacon , Russell King , Nathan Chancellor , Nick Desaulniers , linux-arm-kernel@lists.infradead.org Subject: [PATCH 04/10] arm64: kprobes: Record frame pointer with kretprobe instance Date: Fri, 15 Oct 2021 21:51:19 +0900 Message-Id: <163430227946.459050.807047989088672925.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163430224341.459050.2369208860773018092.stgit@devnote2> References: <163430224341.459050.2369208860773018092.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211015_055124_209292_09CBB861 X-CRM114-Status: GOOD ( 12.88 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Record the frame pointer instead of stack address with kretprobe instance as the identifier on the instance list. Since arm64 always enable CONFIG_FRAME_POINTER, we can use the actual frame pointer (x29). This will allow the stacktrace code to find the original return address from the FP alone. Signed-off-by: Masami Hiramatsu Acked-by: Will Deacon Acked-by: Mark Rutland --- Changes in v2: - Update changelog according to Mark's comment. --- arch/arm64/kernel/probes/kprobes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/probes/kprobes.c b/arch/arm64/kernel/probes/kprobes.c index e7ad6da980e8..d9dfa82c1f18 100644 --- a/arch/arm64/kernel/probes/kprobes.c +++ b/arch/arm64/kernel/probes/kprobes.c @@ -401,14 +401,14 @@ int __init arch_populate_kprobe_blacklist(void) void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs) { - return (void *)kretprobe_trampoline_handler(regs, (void *)kernel_stack_pointer(regs)); + return (void *)kretprobe_trampoline_handler(regs, (void *)regs->regs[29]); } void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, struct pt_regs *regs) { ri->ret_addr = (kprobe_opcode_t *)regs->regs[30]; - ri->fp = (void *)kernel_stack_pointer(regs); + ri->fp = (void *)regs->regs[29]; /* replace return addr (x30) with trampoline */ regs->regs[30] = (long)&__kretprobe_trampoline;