Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp118102pxb; Wed, 20 Oct 2021 17:57:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF9Dv26kJV/2Lcj0qPsdBP1dCZoRL6lf+aZ76V9ZgarZo6Y2QNjCbmvBTBsmUsC/z/4wp3 X-Received: by 2002:a05:6402:1c94:: with SMTP id cy20mr3294911edb.144.1634777855575; Wed, 20 Oct 2021 17:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634777855; cv=none; d=google.com; s=arc-20160816; b=Z61QX46qAIEj4Al06mTwybdnwSv0AVsYx4EJU7Sn5QOBTu0Uo/X7Mnd76Xhe06yVQT whj32we0Vy/TFtK523of7Z18wzynAMnTHxmwHio7wcmn5brO33pY7gzOxoFex3X9lSJs YWX5mQ+QfBMH60OBXDqnrKZBw3RdjB7Vd+gu+DSkUU56JY4qeE6r2EN3YavCoyUYznR0 Aa976oB5wbfXVDoSj0yZCrVEdF0DRiBw14lcoUcphPgDCjyuzvFJAczbdXer9NGO3GLm DuVU6l9qYLOLs7MN2j3Bb8RzHUg0j0AuR+jDEc/qWtOky5adSz24fzWfu8lR0IpHm4Mn QTQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sO/tbwzppYjoDiz8F4CfbeiISLfgQq0+orF+3cKj8sw=; b=qbLO7njAJpq6efPE+natQ+xw8PIV71Vg2Inxu0jshiZX6ZGNV0Hn6YlR8X0oIJsRq9 XABTjdMbpWC9Y9JSOoWek7HLnvWUOPvGO7ooEvcBriFLOAE4gCdzap8EhWw5dUC7kSk+ oJDWM0A+gGOrVw7o4rjidZXTCk34tfVqUw66TbEqtVAnO1HNGNCRn7H9JYVpvRWy5NYK ugNd2uIJ0S/Bp2d3s7b1OYfzbxWhZvxoOsKixFnrTGdCndY58a8EQ1cFGFw7jLB3oyAk UPfvSopHBVdOG5XCDlIy6hmJZ16wiKHGn2nAG5Onx4uhA2cVYAVgopRIJ+bVeCWil+AL rVqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W4eAlkXL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g5si4753682ejx.317.2021.10.20.17.57.12; Wed, 20 Oct 2021 17:57:35 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=W4eAlkXL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231496AbhJUA5M (ORCPT + 99 others); Wed, 20 Oct 2021 20:57:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:51402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbhJUA5K (ORCPT ); Wed, 20 Oct 2021 20:57:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4944611C7; Thu, 21 Oct 2021 00:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634777695; bh=EmhCA26E8wn4zdfBxKo6rHymp3Y5IgKibhi1RWKA/b4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W4eAlkXLYOF18YQ+vsSWYEFjnf2IBvP6jsNj78FwSMqbFHjpQf/seFu7gVgOyyhc1 eueoOkuJg1dfKs9fQ+O0riQtDDP1At2LaDkx+li5/HZ+kWRDAvVKV+mTSUMPcZWvo4 6kZ7UQ7RIZd9C8eyoV5NQqWbjQk286TyyL31QS3r8jXZcJUjF274x/060IQt6JgaQx XTLcD67/nunuG612knMSr1Z0xwSjwOzPbPvoLBKSSDiiV3n+bJ4nMspMdG8DVmWm63 FzSenH7+D+LKTy92gCexmVshITAQDKHjHXbZsI09cZ1Hp+uNTqmF5syXWJDi04Amnf 5lKdC5HGNraqw== 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 v3 4/9] arm64: kprobes: Record frame pointer with kretprobe instance Date: Thu, 21 Oct 2021 09:54:51 +0900 Message-Id: <163477769080.264901.17354945239446513633.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <163477765570.264901.3851692300287671122.stgit@devnote2> References: <163477765570.264901.3851692300287671122.stgit@devnote2> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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;