Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1017391pxj; Thu, 17 Jun 2021 20:17:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoo4HK3pKjJXmlX7thdXpEamDP2JsCjOASxKV/EL8W+QodgTAClnx44/uD0YBFnVsRhuQX X-Received: by 2002:a05:6402:1510:: with SMTP id f16mr1973726edw.377.1623986263220; Thu, 17 Jun 2021 20:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623986263; cv=none; d=google.com; s=arc-20160816; b=N82qOdOVOTlQNtJV21WYogRgznehTgXA4VPD+JY5y1pkHPL+C7KU11f5wAZYlc7iQx wcKutvNHheJrM3NLQjGvigO1kNp786lQGCXckC/LbqNUJfNC4fEjyPZfn7e06pGJeAvC uRhjSuzK3URh1nlUjc+lytSogxqHJ4UCosG+UiPep8cB8uG2LErFt3fagnUWPflBiXu3 DzanSfeBlwoKjxEOu2T+hTwf0NFRNgkDT6+Wv1Z9LsLbAgtkfA2fiAVG8LtkHWRPIbTr LwNwudJ6z44E8q84ERGN57TjwBL+GeXPwXrMLwvXyUfEYQjoT4nYTqSviaaBAAu50kvX Volg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=mjShbIWKCZQVRmdNqhrQzmVe9lJ6ZH5t7Eg4I15LJXU=; b=Udykbtomm2uSpTQPJSArD5DcCPjaOMNcXL7r68jEuw/0hctaRb8+k6Gy21h+Ft9UtL iJdO/gAeAEccXnLpDJanwvYb0l4hpfvhNzG+osWf869AEnWMJFCDjB8h8dYm61Oh4W2L RgAPj4OYtLphaaCfjuuuNi7+zWXqRJNIFu56G3K8GR6V3AGSfWdPz1sxrmyp2ZWBkxVF MlfZ3QnayI1P4v5EIo3OUwFphOO85VKJQo3j3WHz9ReieQsuHjNB47jJPaMwcS/cCgD/ XNips1g5ofdx1+6piZ2lGjMrHwDVtGyJLF+pL1XGKxcN16BARBYic2ymOLWzwX53GEKx O/bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U+UES6kq; 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=redhat.com 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.17.19; Thu, 17 Jun 2021 20:17:43 -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=@redhat.com header.s=mimecast20190719 header.b=U+UES6kq; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233398AbhFRBFe (ORCPT + 99 others); Thu, 17 Jun 2021 21:05:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60917 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233389AbhFRBFd (ORCPT ); Thu, 17 Jun 2021 21:05:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623978205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mjShbIWKCZQVRmdNqhrQzmVe9lJ6ZH5t7Eg4I15LJXU=; b=U+UES6kqpscHicsKcr5OYPCoYDqcLev2sppf3FH1gHVoZB+rU6gu5dfADUK+uIGitUEUJi +64QzOqmlPXczTCSvevvXGm9SvvSa1wHMvaaqrUnEG5QzaxSIPWlXvF2Ip/5t/9lGWhP7S iDXFheOzdbcganwtVe9zPX3Dp3DOE5E= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-6xNCQnpLOHONpBeSs4qQqQ-1; Thu, 17 Jun 2021 21:03:23 -0400 X-MC-Unique: 6xNCQnpLOHONpBeSs4qQqQ-1 Received: by mail-qk1-f198.google.com with SMTP id 142-20020a370d940000b02903b12767b75aso47165qkn.6 for ; Thu, 17 Jun 2021 18:03:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mjShbIWKCZQVRmdNqhrQzmVe9lJ6ZH5t7Eg4I15LJXU=; b=kuz28Ck0d14G+bgsI2EFQ6kt+uB4hfn+khnaivjuobjsB5xYXHmvGgVYjPocAcGI9t HRP/IMGvt1VDSfAsqW5PpfJRK0ScdAHz2OBeoQlxyqntQRCoGmnbKPcanU6CTr6VXIbG 8iUHgHSl8w5xyOI8Ejo6WGGhr1pH6+eqbAuerK+Y/vjqdoq0qCJShFOjhze35N7q6wGi YiIY1+q50Q5gBjBJ5sAVb4VEGBhiIGEh1UMIHabSq4g3Oa2lk0/qFqERqDFE4rwUTTRJ /pFUa2bEbMDoSWk91JU4yW31krRePczfVJxpThZRpiaEOhk0zc41vFIJmZPg+1YINGWD ZrAA== X-Gm-Message-State: AOAM530DLgNpqU3rvB+TbUodNKuzgcZ18Oo/P/H5oz9n7sTEZAPLz3KA wdcMcMFzrYtWPVreQDexdB9aD85JPzcO6XZll2Ygek07eQtdfbjEFRE8UdQ6Edw8IvG8SP2zjyd +d3VJXLD31aWCPaR1jZZ3dyNC X-Received: by 2002:a37:7485:: with SMTP id p127mr6756484qkc.323.1623978203261; Thu, 17 Jun 2021 18:03:23 -0700 (PDT) X-Received: by 2002:a37:7485:: with SMTP id p127mr6756461qkc.323.1623978203061; Thu, 17 Jun 2021 18:03:23 -0700 (PDT) Received: from treble ([68.52.236.68]) by smtp.gmail.com with ESMTPSA id m199sm3032018qke.71.2021.06.17.18.03.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 18:03:22 -0700 (PDT) Date: Thu, 17 Jun 2021 20:03:20 -0500 From: Josh Poimboeuf To: Masami Hiramatsu Cc: Andrii Nakryiko , 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: <20210618010320.5pjpmq5dillhlube@treble> References: <20210617043909.fgu2lhnkxflmy5mk@treble> <20210617044032.txng4enhiduacvt6@treble> <20210617234001.54cd2ff60410ff82a39a2020@kernel.org> <20210618000239.f95de17418beae6d84ce783d@kernel.org> <20210617182159.ka227nkmhe4yu2de@treble> <20210617192608.4nt6sdass6gw5ehl@treble> <20210618093313.de8528635c61880cccf743d7@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210618093313.de8528635c61880cccf743d7@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 18, 2021 at 09:33:13AM +0900, Masami Hiramatsu wrote: > 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. Agreed! I get it now. Thanks :-) -- Josh