Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp679096pxb; Thu, 21 Oct 2021 07:28:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/etqpq3YjT+SdwURN7przVKXqpfcH/rdUKAygMnbxCxxCpePkHE9bvrKUvzkF8V4vlec7 X-Received: by 2002:a17:90b:1d8e:: with SMTP id pf14mr6782355pjb.125.1634826536035; Thu, 21 Oct 2021 07:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634826536; cv=none; d=google.com; s=arc-20160816; b=wFYCLWK+fEu0qvFNfZGDdKulSXYGKMNHbjDv8hFlGGU/gM3+zDM+l/pm0Z8UcOb1EP 6r/6f9AmqW3lAvvGb/NlAEyXbpR1n9SdZwdCzdqF57EOB9sF12VSgx7mQhwg9P7DKbZs +8eFWFDCMdxPkIZXBhfsHYND8MejO3HvvzZXvyrOC5+QmS/eIJ1zChP8kU8Pgrwhywjm wrHPi3BnuEi0hKwUZdusGskEZ0yMkqDW9yNlgBcjrysIB1FuNE1CNPvYvB2kQGjTzrxJ qGW0J4E1rizuYpHjdKDWZGwCF1F7v0Q5SUK5c/WaH9c/aXuWfjSZmN4e7dFSHPAcUPJ8 ESOQ== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9NLAtWp21yY0K2Sc0Dp55R5awfWVlu7T62TaW6h5wD4=; b=N748VmYrMhmxUHoXP5Vatb1Xn4LhvwRlkl3t6UnbGbK1RuznTGdTfeAH6RJqgCbO6Z 1Wo6Ghs8x/Pi5yTZ9GqGwhNZUW+cr2riHUNA23tHeSkoJ2BC4LlnHGcxJwbTl/1AtK2Y l9wyXnA1c0r7K0+SArltD6FbJrLQgbFJo2Vagfhq8JCm9HWjlAwAvtbr7Ai71YbFFgCh DiJ5i9smbFn3+lRC5sbnpdO70KdHOBhRuCfJk9zCskoWRO7kAc6Zr2DCR9ymWoMA0xG3 +qqfAEoy6i1SlS+MhpGseLSBVFZGzjSM94lkDfF5U0kt0cfMZ+bOpi9uLTfPEh7H8f5m L2xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aQz24XFq; 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 p7si9062400plf.307.2021.10.21.07.28.27; Thu, 21 Oct 2021 07:28:56 -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=aQz24XFq; 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 S231687AbhJUO3U (ORCPT + 99 others); Thu, 21 Oct 2021 10:29:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:49758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbhJUO2u (ORCPT ); Thu, 21 Oct 2021 10:28:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 78DDF6120F; Thu, 21 Oct 2021 14:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634826394; bh=jfdEw2NewFPjeRp4KTG29+/+u+3mkuWccUasLnsv9Ks=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=aQz24XFq3Wy0Wc6sePt3mOOLSc1LtLZOhlrd0Hyj2e5DET1jicrrO4d7SVxRjx8RM FDQiNoFuV9oGow5hg118avECfUIBUbYlBbmNvu1fHiY4lEXfqmI0t8jznxCuFsnC4u xXqlPW7XUAe/M2B+dt4iGU1TZAScFbke4C5KnC+RFS4KSXtp9wBbnAV+KyhHl+7ZwG 822JAWeYe6mmShnlNe+3w9a9E6zM3uNUFl3UmOfQcu9iGoarOnZK7apI/XtfbETq+t /CDQTwlqCjJFFU95yfPJmaMPAsbKfhQf7I/1N0C2wThamPXxadKR4cJ4TagwsYcwdh FiOCN6flg/crQ== Date: Thu, 21 Oct 2021 23:26:30 +0900 From: Masami Hiramatsu To: Will Deacon 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: <20211021232630.94bea4540670cdab5a7a63c5@kernel.org> In-Reply-To: <20211021101512.GA16485@willie-the-truck> References: <163477765570.264901.3851692300287671122.stgit@devnote2> <163477770935.264901.1772964361191833681.stgit@devnote2> <20211021101512.GA16485@willie-the-truck> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Oct 2021 11:15:12 +0100 Will Deacon wrote: > 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 Thank you! > > 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. Ah, good question. Since this part depends on the first 3 patches and Steve's tracing tree, these should go through the tracing tree. Is that OK for you? (Or, wait for merging the current tracing tree and merge rest of them. but this will take a long time.) Thank you, -- Masami Hiramatsu