Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1347452imd; Thu, 1 Nov 2018 14:14:45 -0700 (PDT) X-Google-Smtp-Source: AJdET5eTzzSzBZadmiQi2XNUEv1JOVSyFCfMO+RK5Y3bB7QPufOSN9/EKY/465iU+x/X7c/HSQD2 X-Received: by 2002:a62:e10c:: with SMTP id q12-v6mr9018282pfh.75.1541106884990; Thu, 01 Nov 2018 14:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541106884; cv=none; d=google.com; s=arc-20160816; b=VzhPejqyF8kREF+j/WmMh/3CTd0LbSElz3XZ2g1cz6QU4s0gyh4efmuG6K+OQe84iP nHy95Gu4Xi0y4ozN3oLrlDGksF0xnl02bumCjIng7eEM1TDQW/pdgm1WBmYcdoXWN+2l yFSPC/jIdNTulR3NSW+0RHMyePmlPZxvG1IjIzLOR0O/1XYpysle1KqwGbK9PxZ4S75r i8GhlOMu32uARo31R235rzEyowV5Dh96Wwppmaim+LkMgxtiJPXRB47C5FHtjHFJ8/pH Waemr6EpgBGQR23m09Ox96fZFA4pm7kumF0lyaTpaFFyTYSxnwVvnGn9P4gEajdtpfi7 HZ1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9Yb7uEBoZpfrHPvoYM34HbHzP4HmiPMbjPYiosxYEIQ=; b=LiHcjA9V0r1IITZQp3/GCabhVYLEBWL1bHk8DZ0iMYFPd6zR7oVswUEkrHYZjHuGMf r+2MDqFNdf/cWAcloRsFPRikwHtu6aBvQ+cEme99D/FY+jMLn2AnfPNzYNqDzBcDTPXe xRK11iA0J8bmaNvrY/N1iyZmJOdtKsrGhXm8ewX0x1U1jK4Yf4daxZuwDtLz7uD0wHWN 6WXt9oEyhNi4bC0qwB7yh5FeTMx1yaVtp0nO9GII0mEk95Vh70B3y5euymKdxdlXiQvP 20GaeLmT2XH8eRazaloDgDN4zsridm3lWG3rXMP5mlRid3bluRYW4NF6rzd1JNzfo1nN phgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3-v6si30392908plz.68.2018.11.01.14.14.29; Thu, 01 Nov 2018 14:14:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726750AbeKBGSl (ORCPT + 99 others); Fri, 2 Nov 2018 02:18:41 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:24558 "EHLO mx2.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726343AbeKBGSl (ORCPT ); Fri, 2 Nov 2018 02:18:41 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 30ECBA115B; Thu, 1 Nov 2018 22:13:59 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter04.heinlein-hosting.de (spamfilter04.heinlein-hosting.de [80.241.56.122]) (amavisd-new, port 10030) with ESMTP id iRXQw8hSIF5u; Thu, 1 Nov 2018 22:13:56 +0100 (CET) Date: Fri, 2 Nov 2018 08:13:43 +1100 From: Aleksa Sarai To: Masami Hiramatsu Cc: "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Jonathan Corbet , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Steven Rostedt , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Brendan Gregg , Christian Brauner , Aleksa Sarai , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v3 1/2] kretprobe: produce sane stack traces Message-ID: <20181101211343.yooxwqfnoloprb5h@yavin> References: <20181101083551.3805-1-cyphar@cyphar.com> <20181101083551.3805-2-cyphar@cyphar.com> <20181102002039.8f22c10fa47cae75fa709165@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ywyssjdmzzy34rtq" Content-Disposition: inline In-Reply-To: <20181102002039.8f22c10fa47cae75fa709165@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ywyssjdmzzy34rtq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018-11-02, Masami Hiramatsu wrote: > Please split the test case as an independent patch. Will do. Should the Documentation/ change also be a separate patch? > > new file mode 100644 > > index 000000000000..03146c6a1a3c > > --- /dev/null > > +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_stacktrace= =2Etc > > @@ -0,0 +1,25 @@ > > +#!/bin/sh > > +# SPDX-License-Identifier: GPL-2.0+ > > +# description: Kretprobe dynamic event with a stacktrace > > + > > +[ -f kprobe_events ] || exit_unsupported # this is configurable > > + > > +echo 0 > events/enable > > +echo 1 > options/stacktrace > > + > > +echo 'r:teststackprobe sched_fork $retval' > kprobe_events > > +grep teststackprobe kprobe_events > > +test -d events/kprobes/teststackprobe >=20 > Hmm, what happen if we have 2 or more kretprobes on same stack? > It seems you just save stack in pre_handler, but that stack can already > includes another kretprobe's trampline address... Yeah, you're quite right... My first instinct was to do something awful like iterate over the set of "kretprobe_instance"s with ->task =3D=3D current, and then correct kretprobe_trampoline entries using ->ret_addr. (I think this would be correct because each task can only be in one context at once, and in order to get to a particular kretprobe all of your caller kretprobes were inserted before you and any sibling or later kretprobe_instances will have been removed. But I might be insanely wrong on this front.) However (as I noted in the other thread), there is a problem where kretprobe_trampoline actually stops the unwinder in its tracks and thus you only get the first kretprobe_trampoline. This is something I'm going to look into some more (despite not having made progress on it last time) since now it's something that actually needs to be fixed (and as I mentioned in the other thread, show_stack() actually works on x86 in this context unlike the other stack_trace users). --=20 Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH --ywyssjdmzzy34rtq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEb6Gz4/mhjNy+aiz1Snvnv3Dem58FAlvbbIcACgkQSnvnv3De m5+H3g//U3dUHafkMVldC9z5E7aA1ljh+ZbM/PA/HhWq6BaNUkibEKu4/M4TYi6g FGphK06koWBePb0HkeqEQ7gspO1FPxwRUwn/DJNAM3yR+VLIZftkwwjQadFpKMVX T3TTYFf4ogUMeqQPRBld3cVK23ILeiokik02tRcN2Tq1dP3vish0TgH4Z38Rbiql LSbFhRz62GJ99yXrUlgoircGDFKCrCCJBTd7JuN4XXZk4PHJfpsmp9aQQMWY5u2Z IjgNQt4nuArS7eloy8WtlyYNsOhGwf7eyqEsAc1jwcYCMRq1C2zth6vDg3cIk7+K G1s3ZX40jE8a7/w7H09dp0PLgHHuXWZChKdyvTzWmXyEiKKjm+wNBF5dGiELPoqX +K94Mp9LLbOFOCg7yCZDHaal67xktu9o5G8zmpaVNSFfrgLSSiXXh6mNcqSJ4psI CdRSU51NlRtf9cXhsHKZ8s2FMW1bH2q6GVR9cEazCIDdLHDrbDD6PfvpK7NBPiru NlZ9U4GKrm2e/SQJrfMOzukI2ftqmjJzRvD/bytNvDjVn3k2hu3gb+1XFm2VzZaK FaOJFXhQWr0oP+yT4hoTAiPWquXcYA4trlhy88WqKkNMPzB0hhHSr9VVediVfyYH AnBW1Q8Uv9GaKyBe5LIkaMth3u36Cf5ustLvjfweVYkHak9Obaw= =BZZ/ -----END PGP SIGNATURE----- --ywyssjdmzzy34rtq--