Received: by 10.192.165.156 with SMTP id m28csp1352249imm; Wed, 18 Apr 2018 08:20:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SDeA+4M72izRpBBGiFANWxB5zb3UpK18Lm+COv9souYHlNapzNnYiRFPBIdkOedUKK1QE X-Received: by 2002:a17:902:b903:: with SMTP id bf3-v6mr2422174plb.37.1524064844328; Wed, 18 Apr 2018 08:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524064844; cv=none; d=google.com; s=arc-20160816; b=jf5boCyQuycmA+oz+a5YeXYs3VE/9hU+ts5RFx6PA59gOoFj2yg0LqeYyyV3ckrozU oP0cT9FsjYKiZ7vSBdbNqRdKK9NN20tjOOZxJ2IooXr3DUPzFeoD3KBv39+zW55CbVtK IDzpVcjbNks/8df2KCeBPT3coOxZjpSgDkt9Zcan0JnJ4TlEB/l230zJhxQndS4HwSqL iKIJxcE4i3VxIy7qf7VriCvFiE27+AFugqQSCKgfmUnfVBdGSK4d+bMnVWmb9uGirCEy 2gJojQEdmkxCtEWOpTL2uLTjrXsoKx8aEO2Tc5A2wd8HXI8LQRBRic+Vz4tJ8Qe8+fjy ZHxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=I5PyOu+nB4J1GlCsk4GzTTdwzACflpTAYGjJFfSsFAM=; b=QfqgT1hBkPfHZ3L5LLvnnB29gJSm9K2KTo7Jh/5JPKtLRa48Zjdz3G27y2odbCoeSu KEw/0xThxOCVO9E1hbgNnF8Au3oUdBvgIu7/ltMWYbX2Kch9zYi0sfEcyLLeG7O03XIq QHsX6tUnPfXmE/9IUqnDfnevFAdt/GLgYXSp4bcl0aY755O1Fof7fc2tN7a0mmgZejJT z89fc04yYq+e7RkNkw/SHeSkwp6GWjfg/dRmHCw9gaXdMhv2h/u5bNxz3aRsOCKIrgwB 9JOYUfY0aB+dF1WeKUF94feLuFTK2n2loogLr+SOT5gOszpdRAMmkJ4ymBbk6LIpX52/ AByw== 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 b6si1309391pfe.265.2018.04.18.08.20.30; Wed, 18 Apr 2018 08:20: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 S1752632AbeDRPTU (ORCPT + 99 others); Wed, 18 Apr 2018 11:19:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:52110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751204AbeDRPTT (ORCPT ); Wed, 18 Apr 2018 11:19:19 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B8B072178F; Wed, 18 Apr 2018 15:19:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8B072178F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Wed, 18 Apr 2018 11:19:16 -0400 From: Steven Rostedt To: Miklos Szeredi Cc: Song Liu , LKML , kernel-team , Ingo Molnar , Howard McLauchlan , Josef Bacik , Srikar Dronamraju Subject: Re: [PATCH 1/2] tracing: fix bad use of igrab in trace_uprobe.c Message-ID: <20180418111916.2325bf9c@gandalf.local.home> In-Reply-To: References: <20180418062907.3210386-1-songliubraving@fb.com> <20180418102504.7673a7f3@gandalf.local.home> X-Mailer: Claws Mail 3.16.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Apr 2018 16:40:19 +0200 Miklos Szeredi wrote: > > The trace_uprobe (the probe event) is created, it doesn't do anything > > until it is enabled. This function is called when it is enabled. The > > trace_uprobe (probe event) can not be deleted while it is enabled > > (EBUSY). > > > > Are you asking what happens if the file is deleted while it has probe? > > That I don't know about (haven't tried it out). But I would hope that > > it keeps a reference to the inode, isn't that what the igrab is for? > > And is now being replaced by a reference on the path, or is that the > > problem? > > No, that's not the problem. > > What I don't see is how the uprobe object relates to the trace_uprobe object. > > Because after the patch the uprobe object still only has a ref to the > inode, and that can lead to the same issue as with trace_uprobe. > OTOH if uprobe can't survive its creating trace_uprobe, then it > doesn't need to take a ref to the inode at all, since trace_uprobe > already holds it. Taking an extra ref isn't incorrect, it's just > unnecessary and confusing. > > So this needs to be cleared up in some way. The uprobe created by the trace_uprobe creation must be deleted before the trace_uprobe can be deleted. Basically we have this: # cd /sys/kernel/tracing # echo "uprobe creation text" > uprobe_events The trace_uprobe is created (but not the uprobe itself). This is what calls create_trace_uprobe(). # echo 1 > events/uprobes/enable This enables all the trace uprobe events, which creates the uprobes. This is the action that calls probe_event_enable(), which creates uprobes. At this point, any write to uprobe_events that would destroy the trace uprobes would return with -EBUSY, and the trace uprobes will not be deleted. # echo 0 > events/uprobes/enable This will call the probe_event_disable() which will call uprobe_unregister() which will destroy the uprobe. Now we can delete the trace uprobe. Does that answer your question? A uprobe created for trace uprobes can not survive the trace uprobe itself. -- Steve