Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp469902pxb; Thu, 21 Oct 2021 03:18:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBQs1nF49LARjn+4T6rBBGBvJQ+vgKCWyFZDHorQXkpo2Qpk8DT4tck5qdOr0BTi6/am+i X-Received: by 2002:a05:6402:354a:: with SMTP id f10mr6327860edd.365.1634811490839; Thu, 21 Oct 2021 03:18:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634811490; cv=none; d=google.com; s=arc-20160816; b=CkCJgWOgqCBmLSvVLQX26Z7Mtvi/E4Zykl3Fsgw0QCiTQT+IP7mKxVmGKeZDjVjM33 4iVQJOKXSzUSSCYEZxiUOjCq68mGtjpQ/YmKhfd9ROgHmH7OajNATuGMuHoX2CTFNI0L yWOHEPv+iCpV5vUeuTMGws9ezkBG5nBnzQmZt9IGiC6FhK7w6VpEjzQH4tqbNJ4gF+oc 9uZiFLagObgMK/1Q9+ubQYc0K34iK/80MTGsS46+UWw1pJyvBUozkTKgYAN8EGd0Z1wp 98U8FZQe/dEkkjCnLzSA5Q8CLwLEwa3lTralQxKN5IAIHtElv5gB4JqvVayfjzjc1GIw 8tSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=i5ulB0RsJ45xtYprwvNglZuQ5UQ+Lnl8Nmavf2c+IHo=; b=Qp52OLKB9SofCv0clVI4t4/TQNxhfM9eeEsVlLl4rJ18/nNYaYibrtwGRcNjoBKB4e tx8sJ5SXKaN3aGd3Zi/IXdzJlsAMwfuC9n7o2G7vM3WJrU+ZmP7T4jhZInpL2VIx/8yX rP1jrve9RNY3Lnua/FZgfMHxbIeV8FSldf6xU372UWTg/Y+997E/TC/RCiKeN+dldw3h ix/nsENnFdMbirBDHZvneoK3RX/AiNHNIde/lCjGWvarXZ9ZcxnHTjuFV7Q7T2IG4TJ9 asrhHcNJmAp4MRahJ9R7McDYExxf3ChvSBuWtSvOS8i1OwGQIf9kcCGEtwlE1aTlPhR3 ajcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UAuJ1gP7; 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 ds7si11539082ejc.362.2021.10.21.03.17.47; Thu, 21 Oct 2021 03:18:10 -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=UAuJ1gP7; 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 S230244AbhJUKRf (ORCPT + 99 others); Thu, 21 Oct 2021 06:17:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:50664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbhJUKRe (ORCPT ); Thu, 21 Oct 2021 06:17:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 337EA60F5D; Thu, 21 Oct 2021 10:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634811318; bh=3KefFL9wea8DymntAjOwwZ1IuPc4DgkYtD4ihJq/Jg4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UAuJ1gP781Re1GFx0uf+8Six0abPXdp+RqIPiZT4Fp4TTOW+do9UYc9J+0eDBoWc/ r7K2iFyLkcQjqurZnrX8meqfVLV0YjbTi3JQyKUfBmYyaN+UMHDH7o3w+HhhSsRkJL EcJdrgy5kpWIPgUGK2I+49v6f84EJoQ6VdBUgSKJ/3SdY3uZGej/3Yjk1+aExRzf07 MREitKO4Ez+0MhENJ7+W6vK/LkSFRGlwOd7pIbsvHUZqr1duatR4NIzMvcOsowfppE FyL2Z179gYlqHPk4X/vQmbiy+FL2JHgC/Npzv30jkZJEYlMRnv54E/55UQvS/41GSK Ur3Yo0plHKhQQ== Date: Thu, 21 Oct 2021 11:15:12 +0100 From: Will Deacon To: Masami Hiramatsu Cc: Steven Rostedt , "Naveen N . Rao" , Ananth N Mavinakayanahalli , Ingo Molnar , linux-kernel@vger.kernel.org, Sven Schnelle , Catalin Marinas , Russell King , Nathan Chancellor , Nick Desaulniers , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 6/9] arm64: Recover kretprobe modified return address in stacktrace Message-ID: <20211021101512.GA16485@willie-the-truck> References: <163477765570.264901.3851692300287671122.stgit@devnote2> <163477770935.264901.1772964361191833681.stgit@devnote2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <163477770935.264901.1772964361191833681.stgit@devnote2> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 21, 2021 at 09:55:09AM +0900, Masami Hiramatsu wrote: > Since the kretprobe replaces the function return address with > the kretprobe_trampoline on the stack, stack unwinder shows it > instead of the correct return address. > > This checks whether the next return address is the > __kretprobe_trampoline(), and if so, try to find the correct > return address from the kretprobe instance list. For this purpose > this adds 'kr_cur' loop cursor to memorize the current kretprobe > instance. > > With this fix, now arm64 can enable > CONFIG_ARCH_CORRECT_STACKTRACE_ON_KRETPROBE, and pass the > kprobe self tests. > > Signed-off-by: Masami Hiramatsu > --- > Changes in v2: > - Add comment for kr_cur. > - Make the kretprobe related code depends on CONFIG_KRETPROBES. > - Initialize "kr_cur" directly in start_backtrace() instead > of clearing "frame" data structure by memset(). > --- > arch/arm64/Kconfig | 1 + > arch/arm64/include/asm/stacktrace.h | 4 ++++ > arch/arm64/kernel/stacktrace.c | 7 +++++++ > 3 files changed, 12 insertions(+) Acked-by: Will Deacon I'm not sure how you're planning to merge this, so please let me know if you want me to queue any of the arm64 bits. Will