Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp517670pxj; Thu, 17 Jun 2021 07:53:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkjuqFt+lvO1QUfx49eYy1JxOvCdZvGIj29OUDqqwXw4+oVlF8R/OwnWSq0tJwgmErL/Fa X-Received: by 2002:a05:6402:1ac9:: with SMTP id ba9mr7230778edb.250.1623941596441; Thu, 17 Jun 2021 07:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623941596; cv=none; d=google.com; s=arc-20160816; b=0scYRFwVnPvslcX2kaUIacHZKNuvhp4oM2151BAJ0XzEmjNSJDmfezed5qMv/v8LA5 6qrxvcx8U7QNfwpCF4fWNEnxL5Efp1BqE5YFp3adiWyVe19JDEMlcmkuFWidRDKL5z8H udwcJfN0BAyaFP6zWpQk0wBzU46yCVwX+sMXIRE5P67vKU1Sx2fy1payN/4gQHsWHEVS N6iVxNUg9g4bdKx815P/HlrsmRouRQJ3B/ClRD778pWAvZbuByoPkq+sV6hsr/OqORT2 2w8rYDEmg/ELDcD/gZ9ZUTNlZTRGbCwj2u1X7r5LQ1wlhK5SRS9942VnFd42g7hiHWFd d4xQ== 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=DVR6tBrWcQIujfHCrFo/PnsS5DbBhqklWulWCdXMMBc=; b=qT2gNPH3uBlUqdu1ujlpME5vakl4BBo2QVRdH+51ufr/utOTtDjvqU03wBmjUQQV3e Huy/huZdWhdqTn5lYV3s5bVe7wUbiIGg8+3hFseLCH5LO3bq+V25RBOW6sofDpZ6YXL5 40qT7WzNsMD6YFGk28tKLt5yplL8PjuDaon2HWoCBu93iTS01PzU9lj/nYyjWZ60UjO+ pUiQg9jTJKcWGkiHDTsComrqwzTCsFu52OZcrUxz33Ssx3whGbYICU29wsgVOXm0YjQs sEqIRFYCgAezHqeicjlkeitbbit2omK9STEGJkn7SE0nyL53LOg37fAMtFDWm5w3DzDS Bwtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=reA2Tf4N; 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 m19si6195959edd.297.2021.06.17.07.52.53; Thu, 17 Jun 2021 07:53:16 -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=reA2Tf4N; 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 S232831AbhFQOmN (ORCPT + 99 others); Thu, 17 Jun 2021 10:42:13 -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