From patchwork Thu Oct 21 00:54:51 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: 12573581 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 50B2FC433EF for ; Thu, 21 Oct 2021 00:56:38 +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 19C0F610A1 for ; Thu, 21 Oct 2021 00:56:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 19C0F610A1 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=tnR9SfXBz3N4yc SyKQ26sTtvLG/SqCkqylVO4R0fLUSVF6cfIZvkpEg5nAFNw46VjfAwOALaZqgkuot8GPpYev5xQg2 JyowjNSUENSqwDxtVxihzli2kpLqmmmJgjeZdOdbqj5rGoT05zekHKBBHd7G0qBlhnq5fD44Ju+op QWvEmPSs4PXyDgH3wAPDK5KTmBJ9hOtJe5vncoufN5BNjG+KTboIerIduyHepkm4hTRwDFwNjNqDd iNaWuIGfQT+z84uXQGLJu88oH/xu10r4yH2qmMWEMPBewtrU/morIPoEhGFET+pUln8eLh7WZ4oJq EkA632CQCP1UFufTj2kw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdMMQ-0067mI-1u; Thu, 21 Oct 2021 00:55:10 +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 1mdMMB-0067gO-Pi for linux-arm-kernel@lists.infradead.org; Thu, 21 Oct 2021 00:54:57 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211020_175455_877601_978D405E X-CRM114-Status: GOOD ( 13.00 ) 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;