Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1013797pxj; Thu, 17 Jun 2021 20:11:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNMeZ1XBSkJ4MvIy7GPMf0hReK+ekUPoRzyZVYXSQpuryhkJlpIkWcdMlEBcDvISXTMBQL X-Received: by 2002:aa7:c70d:: with SMTP id i13mr1971605edq.249.1623985884588; Thu, 17 Jun 2021 20:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623985884; cv=none; d=google.com; s=arc-20160816; b=azI3LEHLXHTSx0B0jeVGiqtxYvOEl5Rm+Py0pe3W4OyRbaz+fsznJINxvDE0sbA8DK K4EE/Y9k7gfD7YuUcyrV2PCMgI5Jyp6dpzuUBmqYdIYKeSJEYHq3Ve6ASxbb703ZYnk4 pWVW0DetYXQN3ycA9HRw7QI5eV0jb+Ec9fLt9U7ngzLuiTbTT7xopaQogqDdiIhIbK2J 3e7NVKH/Kfashk/WQdc7lh0SZTUm65ekZMnFKiAMWp+AOIijHkMIfFoFxccrBCVRKeDe Cvrz0sxf8c0EX/LZmlHgVeV3XbI7hXjjAFvk0LAxSqlHOh0RVtFu1F/S0xMDKpZhwl9a IAYg== 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=tPhZBlFMd3JK1vFxuSth830Nn5sV8FMlW+QlWdYvdAk=; b=gZRtr+FxjFYbt+Ly6yItS4gjfEk3FGUEkI4e9WBP/+XuzOdZ2xo1XPicAkMudjQqmu ehoyaHjehge1MAX1303tTEyVUdugda2dFflqmIfeAdftjMNdWd9TGHpWoc1STWyq3r+0 8tAgEDIPf1EwwUvEQbZgxFrk/jvbtq/+lCZMEYgbiVFrMShSod+n9vBXJjlws6RnZbat Wn25LTF/buvMzN7cjO5dSfYbS7b0pt77mRe0Er+orqeSzBU8rhtPtQ/Hpz6CZtiePMK1 hRKi3wWf6zyzRZmr2FMG/UydHKCRK7xlFygWaR6M78PKLxcYF7iaKcHi7XGIH8NCYMQF OCSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RzImgnSt; 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 d23si7220216ede.200.2021.06.17.20.11.02; Thu, 17 Jun 2021 20:11:24 -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=RzImgnSt; 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 S233203AbhFRAf0 (ORCPT + 99 others); Thu, 17 Jun 2021 20:35:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:40388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232683AbhFRAfZ (ORCPT ); Thu, 17 Jun 2021 20:35:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6576610EA; Fri, 18 Jun 2021 00:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623976397; bh=CMcK2YQApJFBvI9v9Q2bNfCCJpxv0tzXnN3JkJqHUm8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RzImgnStN51RG+afGKhMJFcTXX+LE1P0LbTGy5RPifvhxZogkpNUpD5LnV7MP60iJ GM4bQz1t6lbQF+TukUORUS5F4RAY9LOO3FT/POcFLOafFiIsG7LLe5Oozh31s2J6oQ w7G8DVaMycy7bZ9+KLDBBeayhDs9qDCdjHt8eBHQNO7Vo9kvaJPHi42aAiSyYDkKEn l3KZWpVS5BDKLQalCHQXPF/+XdRw5Sy3BA4Bc8bmSYL3D4v87loDLebRMmnWxoAxLH mWAEyYbIfFMkq+4VK/hMZaLCmsTuBpnv/4V/aCPL1P/c2+sJfNDtBw0OIMve9osC5i AligLYAk8pIcA== Date: Fri, 18 Jun 2021 09:33:13 +0900 From: Masami Hiramatsu To: Andrii Nakryiko Cc: Josh Poimboeuf , Masami Hiramatsu , Steven Rostedt , Ingo Molnar , X86 ML , Daniel Xu , open list , bpf , Jakub Kicinski , Ingo Molnar , Alexei Starovoitov , Thomas Gleixner , Kernel Team , Yonghong Song , linux-ia64@vger.kernel.org, Abhishek Sagar Subject: Re: [PATCH -tip v7 09/13] kprobes: Setup instruction pointer in __kretprobe_trampoline_handler Message-Id: <20210618093313.de8528635c61880cccf743d7@kernel.org> In-Reply-To: References: <162209754288.436794.3904335049560916855.stgit@devnote2> <162209762943.436794.874947392889792501.stgit@devnote2> <20210617043909.fgu2lhnkxflmy5mk@treble> <20210617044032.txng4enhiduacvt6@treble> <20210617234001.54cd2ff60410ff82a39a2020@kernel.org> <20210618000239.f95de17418beae6d84ce783d@kernel.org> <20210617182159.ka227nkmhe4yu2de@treble> <20210617192608.4nt6sdass6gw5ehl@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 Thu, 17 Jun 2021 12:46:19 -0700 Andrii Nakryiko wrote: > On Thu, Jun 17, 2021 at 12:26 PM Josh Poimboeuf wrote: > > > > On Thu, Jun 17, 2021 at 11:31:03AM -0700, Andrii Nakryiko wrote: > > > On Thu, Jun 17, 2021 at 11:22 AM Josh Poimboeuf wrote: > > > > > > > > On Thu, Jun 17, 2021 at 10:45:41AM -0700, Andrii Nakryiko wrote: > > > > > > > > > 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. > > > > > > > > > > > > Oops, Andrii, can you also test the kernel without this patch? > > > > > > (you don't need to drop patch 6-8) > > > > > > > > > > Hi Masami, > > > > > > > > > > Dropping this patch and leaving all the other in place breaks stack > > > > > traces from kretprobes for BPF. I double checked with and without this > > > > > patch. Without this patch we are back to having broken stack traces. I > > > > > see either > > > > > > > > > > kretprobe_trampoline+0x0 > > > > > > > > > > or > > > > > > > > > > ftrace_trampoline+0xc8 > > > > > kretprobe_trampoline+0x0 > > > > Do the stack traces end there? Or do they continue normally after that? > > That's the entire stack trace. So, there are 2 cases of the stacktrace from inside the kretprobe handler. 1) Call stack_trace_save() in the handler. This will unwind stack from the handler's context. This is the case of the ftrace dynamic events. 2) Call stack_trace_save_regs(regs) in the handler with the pt_regs passed by the kretprobe. This is the case of ebpf. For the case 1, these patches can be dropped because ORC can unwind the stack with UNWIND_HINT_FUNC. For the case 2, regs->ip must be set to the correct (return) address so that ORC can find the correct entry from that ip. Thank you, -- Masami Hiramatsu