Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp866823pxb; Fri, 15 Oct 2021 18:36:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy08cGbV7b0K/o6pPSG5yj3aeo3WQhrG/wonHk6uf/KR8wICPv5qsMVQlab7rd0mhYQ7DSk X-Received: by 2002:a63:1125:: with SMTP id g37mr11521901pgl.403.1634348179921; Fri, 15 Oct 2021 18:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634348179; cv=none; d=google.com; s=arc-20160816; b=LjlgCH3B83Zu2RcXqX4gC93Cv/40hzJZdVix+EAXOZuLispIpB5IbhH3t+Ow43/BQY fdOBDX+WRK1FMf3T1cyTdDnKn2vygIKS0ovpsNg3Zj3MRx8yxeXt6DpsEI3q2ti3yPUU PS17bDcKQD/5wKfCJY7H//5pCDj4ZGSIJebzBvJWrklzCQEqT/bmypi3nMal43gyzL10 6q3zK78Bq1B+/14AbRgTSJQiDTWm2BfJOM/IWsrLDBiGLW56Q0eIFsE8feqssf65byj9 Wj5IZJjp+/7ybsP0K774d02wdG7HJ0euCH3uzO6jmpJq2BnQT1S1qFScJberv7xLs3hJ fVLQ== 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=hDA9KL/ITxkiWwRL+5Efa95H5OrZGZt73AEh9ROg8Aygmk5YcvXiGXfjrHGDuimERy TiG3lN3WBlsWXmUmjy4ddKD9+2i8q8wvCNJ19vF72ZjC4eW5gnOS2j6kpLcZihKsuc2V 1SlB/a4fFuXCeQZRbP4KSa4sRvuo8NUPK/gJOuaIpHKzFIEbxdK5IaZ6ZS/3FKxd3ARU plfI48LhrS1DgbkmCQrFE/jtXshK6XVqC092D/b+pM9KGeMennKBA8i3v2PB8Wym87nY /6ZJm+ojdDdl5eFQXKELEW230QLSo80Zp13eCScggpNBVqxtgSKvyxaIyRJwpPtqwENo kGqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pAPPkNGF; 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 d18si9655746plr.280.2021.10.15.18.36.07; Fri, 15 Oct 2021 18:36:19 -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=pAPPkNGF; 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 S239212AbhJOMxt (ORCPT + 99 others); Fri, 15 Oct 2021 08:53:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:53224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239263AbhJOMxa (ORCPT ); Fri, 15 Oct 2021 08:53:30 -0400 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 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;