Received: by 10.192.165.156 with SMTP id m28csp1309170imm; Wed, 18 Apr 2018 07:41:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+tTAOWgBIrwkCeYY9A2C/h2UT+WunN/+ByqSHkxhEUy9KnEGo1400ND4jZvPkjmih8HlA0 X-Received: by 10.98.139.7 with SMTP id j7mr2255129pfe.28.1524062515572; Wed, 18 Apr 2018 07:41:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524062515; cv=none; d=google.com; s=arc-20160816; b=CFN0Aw1zOWzpM64WvTXG5QFff3fyo5/WriINOkVk2K8cLLyLW4LdhjucFN+NJ/jIaB z80dmx9YMcqS1qa76AGtKs6nON3vcuJznimVgOzYRDkmrfXVUesHCzHiboItam2hxcdt vYC06V+YgfHwz5qAgGQQmy3rg3hOBL2wk5Ld5mlU2r0n4pDxS1bCy50RNx37oloeStwN QfdJuE1j3esSGMqVuVdNcqQ2VTHM+9v8Xvxmz+mPYfPs/6FWLTtBJYtBBeJjfm2PPn+2 YPxEANcdGO7PZWq0kyM96KhxiTx1hS3u+6Pp5FFPIdrYZ8g2ySiPRUC1mIIwjHlw4dX6 qsFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=iPkftspG91Z3c7/xUqxbWjbJsMl3a8zKxrVmO8V//XU=; b=dTjRm56KplzNvZ11e2aOV8Uis4CRIZj0wX+HT0HzKtRYVqvIzrllEZQVs2AG6WdaRQ XIHT23l9XEtruLG5DEOg20krWnXNEevNslmtC6B8br4zqh//1jHh8CAFM3p+nO+bcAkP o7J6f4/R/fcDSSLTXwDbTO77gd75GSkwV1hyF8eIyqrGMB4LziLbUKiSrZzavQTWkq0C tzDC7AMi/5D0bpYxV2d/eSK2GJz9xbA5jwM1yJcAgN3YbMxuGmBnNZfrbbd9lopZ1qIU cNDmFhHaFFBCAybUzOSSWk5gz2eeimp79fWANmg1wbJ5s9LG87iF//fNMt5QTpTHyCcH O1Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=D0bmddSm; 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 t5si1173268pgo.96.2018.04.18.07.41.40; Wed, 18 Apr 2018 07:41:55 -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; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=D0bmddSm; 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 S1753530AbeDROkW (ORCPT + 99 others); Wed, 18 Apr 2018 10:40:22 -0400 Received: from mail-ot0-f193.google.com ([74.125.82.193]:38510 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751232AbeDROkU (ORCPT ); Wed, 18 Apr 2018 10:40:20 -0400 Received: by mail-ot0-f193.google.com with SMTP id j27-v6so2021111ota.5 for ; Wed, 18 Apr 2018 07:40:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=iPkftspG91Z3c7/xUqxbWjbJsMl3a8zKxrVmO8V//XU=; b=D0bmddSmSVEAIx0v9g7mkqmuOZzKEtTgRGZnAii2+wgwtyjZGcGPphvOrmw1Q3j2Cc PAWD3AlPeaJTwwgx0rVDY9KqBZPSdQ16jTd9ItKZ1FamtPXrj9sbStDiu3nj0sAMJinM GsywVXUwE8yy06u5Xe+MfPkbyh7fYfqs9Tr+M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=iPkftspG91Z3c7/xUqxbWjbJsMl3a8zKxrVmO8V//XU=; b=Jn2Ot4yCfKwhm5qkzlGkyMcwzgE9vKGkDogHK9g3k9VabhHAaulC5cPwa0jdtma8d8 jzjf7U2DaqLDxle1mMwSNoUQarcvxYoXVIx8aIalnDQvvSNS7Gyn6atIly6cUDbidC9c VYLZ7q4GtSSwdxiO8mJ5GGNTTdtSdfChDSlBqfQi0VwdUaWresE7r2xGue+QCDGaiihB ClzTarp65xxhSVr/ZEiJ4QuFnHf83bLxHe6OC1gVI824UwmeKL2hZTocs8nwbTxudRE2 uf92FJHwvIWAkgHFXkzoElrbfvvQMQxN+n+RYVneELZgpmL9H614h/1W5LDAWXtWH9D1 xYsw== X-Gm-Message-State: ALQs6tDxzJ5urJ7BmfWn+f/9PO+NmbgXCG4PVfuOJ5pqOilcpFjl5NCz kFadysiJUzMRa75Z8ynt4QJMOngm++CtInyDyT+qbA== X-Received: by 2002:a9d:3a08:: with SMTP id j8-v6mr1339385otc.368.1524062419979; Wed, 18 Apr 2018 07:40:19 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:5303:0:0:0:0:0 with HTTP; Wed, 18 Apr 2018 07:40:19 -0700 (PDT) X-Originating-IP: [176.63.54.97] In-Reply-To: <20180418102504.7673a7f3@gandalf.local.home> References: <20180418062907.3210386-1-songliubraving@fb.com> <20180418102504.7673a7f3@gandalf.local.home> From: Miklos Szeredi Date: Wed, 18 Apr 2018 16:40:19 +0200 Message-ID: Subject: Re: [PATCH 1/2] tracing: fix bad use of igrab in trace_uprobe.c To: Steven Rostedt Cc: Song Liu , LKML , kernel-team , Ingo Molnar , Howard McLauchlan , Josef Bacik , Srikar Dronamraju Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 18, 2018 at 4:25 PM, Steven Rostedt wrote: > On Wed, 18 Apr 2018 16:03:42 +0200 > Miklos Szeredi wrote: > >> > @@ -937,7 +928,8 @@ probe_event_enable(struct trace_uprobe *tu, struct trace_event_file *file, >> > goto err_flags; >> > >> > tu->consumer.filter = filter; >> > - ret = uprobe_register(tu->inode, tu->offset, &tu->consumer); >> > + ret = uprobe_register(d_inode(tu->path.dentry), tu->offset, >> > + &tu->consumer); >> >> It is not entirely clear how the lifetime of uprobe relates to the >> lifetime of trace_uprobe. Is the uprobe object never going to survive >> its creator trace_uprobe object? > > Not exactly sure what you mean here. > > 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. Thanks, Miklos