From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB34C48BE5 for ; Thu, 17 Jun 2021 14:40:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDBDD610A1 for ; Thu, 17 Jun 2021 14:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232925AbhFQOmO (ORCPT ); Thu, 17 Jun 2021 10:42:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:44556 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230299AbhFQOmN (ORCPT ); Thu, 17 Jun 2021 10:42:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6AB90610EA; Thu, 17 Jun 2021 14:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623940805; bh=DuloBXiAXa8E55JQLkThi/HShz77I2A5WiXoBs7eIts=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=reA2Tf4N+00RWrxP7K1Q4/OHaaHuX8gp/oRgzh+Q90SVGjmeA2p/cwTddYQBlrDg/ jmlIhElcOCMAF3VlJdjNDiplBTT6Rp0tNRyWnzZAOI5MmiZ36MK9auTnu75mH1j/L4 IlqpAmMVb5Auy9BTgAdrrrxC683MaZBaDA+T/EddXaSNURctc8JA+kGU67zzMpQ6lj +//AcQ4z2CrSWDCub/3TAHX1goo4BztgflPeW4Iiky6b80cf7afLcTt8wbqDNXvUHb OVRxPdrbPC6YgQk9wW/IwhcVQgT0ZtcxiWEmTUyiZmipWM3x+G2eWFYxkQ0PMtTxnu FaCMmWryIp+2w== Date: Thu, 17 Jun 2021 23:40:01 +0900 From: Masami Hiramatsu To: Josh Poimboeuf Cc: Steven Rostedt , Ingo Molnar , X86 ML , Daniel Xu , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kuba@kernel.org, mingo@redhat.com, ast@kernel.org, tglx@linutronix.de, kernel-team@fb.com, yhs@fb.com, linux-ia64@vger.kernel.org, Abhishek Sagar , Andrii Nakryiko Subject: Re: [PATCH -tip v7 09/13] kprobes: Setup instruction pointer in __kretprobe_trampoline_handler Message-Id: <20210617234001.54cd2ff60410ff82a39a2020@kernel.org> In-Reply-To: <20210617044032.txng4enhiduacvt6@treble> References: <162209754288.436794.3904335049560916855.stgit@devnote2> <162209762943.436794.874947392889792501.stgit@devnote2> <20210617043909.fgu2lhnkxflmy5mk@treble> <20210617044032.txng4enhiduacvt6@treble> 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 Wed, 16 Jun 2021 23:40:32 -0500 Josh Poimboeuf wrote: > On Wed, Jun 16, 2021 at 11:39:11PM -0500, Josh Poimboeuf wrote: > > On Thu, May 27, 2021 at 03:40:29PM +0900, Masami Hiramatsu wrote: > > > To simplify the stacktrace with pt_regs from kretprobe handler, > > > set the correct return address to the instruction pointer in > > > the pt_regs before calling kretprobe handlers. > > > > > > Suggested-by: Josh Poimboeuf > > > Signed-off-by: Masami Hiramatsu > > > Tested-by: Andrii Nakryik > > > --- > > > Changes in v3: > > > - Cast the correct_ret_addr to unsigned long. > > > --- > > > kernel/kprobes.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > > > index 54e5b89aad67..1598aca375c9 100644 > > > --- a/kernel/kprobes.c > > > +++ b/kernel/kprobes.c > > > @@ -1914,6 +1914,9 @@ unsigned long __kretprobe_trampoline_handler(struct pt_regs *regs, > > > BUG_ON(1); > > > } > > > > > > + /* Set the instruction pointer to the correct address */ > > > + instruction_pointer_set(regs, (unsigned long)correct_ret_addr); > > > + > > > /* Run them. */ > > > first = current->kretprobe_instances.first; > > > while (first) { > > > > > > > Hi Masami, > > > > I know I suggested this patch, but I believe it would only be useful in > > combination with the use of UNWIND_HINT_REGS in SAVE_REGS_STRING. But I > > think that would be tricky to pull off correctly. Instead, we have > > UNWIND_HINT_FUNC, which is working fine. > > > > So I'd suggest dropping this patch, as the unwinder isn't actually > > reading regs->ip after all. > > ... and I guess this means patches 6-8 are no longer necessary. OK, I also confirmed that dropping those patche does not make any change on the stacktrace. Let me update the series without those. Thank you, > > -- > Josh > -- Masami Hiramatsu From mboxrd@z Thu Jan 1 00:00:00 1970 From: Masami Hiramatsu Date: Thu, 17 Jun 2021 14:40:01 +0000 Subject: Re: [PATCH -tip v7 09/13] kprobes: Setup instruction pointer in __kretprobe_trampoline_handler Message-Id: <20210617234001.54cd2ff60410ff82a39a2020@kernel.org> List-Id: References: <162209754288.436794.3904335049560916855.stgit@devnote2> <162209762943.436794.874947392889792501.stgit@devnote2> <20210617043909.fgu2lhnkxflmy5mk@treble> <20210617044032.txng4enhiduacvt6@treble> In-Reply-To: <20210617044032.txng4enhiduacvt6@treble> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Josh Poimboeuf Cc: Steven Rostedt , Ingo Molnar , X86 ML , Daniel Xu , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, kuba@kernel.org, mingo@redhat.com, ast@kernel.org, tglx@linutronix.de, kernel-team@fb.com, yhs@fb.com, linux-ia64@vger.kernel.org, Abhishek Sagar , Andrii Nakryiko On Wed, 16 Jun 2021 23:40:32 -0500 Josh Poimboeuf wrote: > On Wed, Jun 16, 2021 at 11:39:11PM -0500, Josh Poimboeuf wrote: > > On Thu, May 27, 2021 at 03:40:29PM +0900, Masami Hiramatsu wrote: > > > To simplify the stacktrace with pt_regs from kretprobe handler, > > > set the correct return address to the instruction pointer in > > > the pt_regs before calling kretprobe handlers. > > > > > > Suggested-by: Josh Poimboeuf > > > Signed-off-by: Masami Hiramatsu > > > Tested-by: Andrii Nakryik > > > --- > > > Changes in v3: > > > - Cast the correct_ret_addr to unsigned long. > > > --- > > > kernel/kprobes.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > > > index 54e5b89aad67..1598aca375c9 100644 > > > --- a/kernel/kprobes.c > > > +++ b/kernel/kprobes.c > > > @@ -1914,6 +1914,9 @@ unsigned long __kretprobe_trampoline_handler(struct pt_regs *regs, > > > BUG_ON(1); > > > } > > > > > > + /* Set the instruction pointer to the correct address */ > > > + instruction_pointer_set(regs, (unsigned long)correct_ret_addr); > > > + > > > /* Run them. */ > > > first = current->kretprobe_instances.first; > > > while (first) { > > > > > > > Hi Masami, > > > > I know I suggested this patch, but I believe it would only be useful in > > combination with the use of UNWIND_HINT_REGS in SAVE_REGS_STRING. But I > > think that would be tricky to pull off correctly. Instead, we have > > UNWIND_HINT_FUNC, which is working fine. > > > > So I'd suggest dropping this patch, as the unwinder isn't actually > > reading regs->ip after all. > > ... and I guess this means patches 6-8 are no longer necessary. OK, I also confirmed that dropping those patche does not make any change on the stacktrace. Let me update the series without those. Thank you, > > -- > Josh > -- Masami Hiramatsu