linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] tracing: remove igrab() iput() call from uprobes.c
@ 2018-04-20 18:08 Song Liu
  2018-04-20 18:29 ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Song Liu @ 2018-04-20 18:08 UTC (permalink / raw)
  To: linux-kernel
  Cc: kernel-team, Song Liu, Steven Rostedt, Ingo Molnar,
	Howard McLauchlan, Josef Bacik, Srikar Dronamraju,
	Miklos Szeredi

Caller of uprobe_register is required to keep the inode and containing
mount point referenced.

There was misuse of igrab() in uprobes.c and trace_uprobe.c. This is
because igrab() will not prevent umount of the containing mount point.
To fix this, we added path to struct trace_uprobe, which keeps the inode
and containing mount reference.

For uprobes.c sisde, igrab() is not necessary. So we removed it and
added comments on requirements to callers of uprobe_register().

Link: http://lkml.kernel.org/r/CAELBmZB2XX=qEOLAdvGG4cPx4GEntcSnWQquJLUK1ongRj35cA@mail.gmail.com
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Howard McLauchlan <hmclauchlan@fb.com>
Cc: Josef Bacik <jbacik@fb.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Song Liu <songliubraving@fb.com>
---
 kernel/events/uprobes.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index ce6848e..20486bb 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -491,7 +491,6 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset)
 	if (!uprobe)
 		return NULL;
 
-	uprobe->inode = igrab(inode);
 	uprobe->offset = offset;
 	init_rwsem(&uprobe->register_rwsem);
 	init_rwsem(&uprobe->consumer_rwsem);
@@ -502,7 +501,6 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset)
 	if (cur_uprobe) {
 		kfree(uprobe);
 		uprobe = cur_uprobe;
-		iput(inode);
 	}
 
 	return uprobe;
@@ -701,7 +699,6 @@ static void delete_uprobe(struct uprobe *uprobe)
 	rb_erase(&uprobe->rb_node, &uprobes_tree);
 	spin_unlock(&uprobes_treelock);
 	RB_CLEAR_NODE(&uprobe->rb_node); /* for uprobe_is_active() */
-	iput(uprobe->inode);
 	put_uprobe(uprobe);
 }
 
@@ -873,7 +870,8 @@ static void __uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *u
  * tuple).  Creation refcount stops uprobe_unregister from freeing the
  * @uprobe even before the register operation is complete. Creation
  * refcount is released when the last @uc for the @uprobe
- * unregisters.
+ * unregisters. Caller of uprobe_register() is required to keep @inode
+ * (and the containing mount) referenced.
  *
  * Return errno if it cannot successully install probes
  * else return 0 (success)
-- 
2.9.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] tracing: remove igrab() iput() call from uprobes.c
  2018-04-20 18:08 [PATCH v4] tracing: remove igrab() iput() call from uprobes.c Song Liu
@ 2018-04-20 18:29 ` Steven Rostedt
  2018-04-20 18:36   ` Song Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2018-04-20 18:29 UTC (permalink / raw)
  To: Song Liu
  Cc: linux-kernel, kernel-team, Ingo Molnar, Howard McLauchlan,
	Josef Bacik, Srikar Dronamraju, Miklos Szeredi

On Fri, 20 Apr 2018 11:08:47 -0700
Song Liu <songliubraving@fb.com> wrote:

> For uprobes.c sisde, igrab() is not necessary. So we removed it and

You don't need to send another patch, but what is the above sentence
suppose to say?

-- Steve

> added comments on requirements to callers of uprobe_register().

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] tracing: remove igrab() iput() call from uprobes.c
  2018-04-20 18:29 ` Steven Rostedt
@ 2018-04-20 18:36   ` Song Liu
  2018-04-20 18:40     ` Steven Rostedt
  0 siblings, 1 reply; 5+ messages in thread
From: Song Liu @ 2018-04-20 18:36 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Kernel Team, Ingo Molnar, Howard McLauchlan, Josef Bacik,
	Srikar Dronamraju, Miklos Szeredi



> On Apr 20, 2018, at 11:29 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Fri, 20 Apr 2018 11:08:47 -0700
> Song Liu <songliubraving@fb.com> wrote:
> 
>> For uprobes.c sisde, igrab() is not necessary. So we removed it and
> 
> You don't need to send another patch, but what is the above sentence
> suppose to say?
> 
> -- Steve
> 

Sorry for the typo. I meant "For uprobes.c side". Or "it is not necessary
to call igrab() in uprobe_register(), as the caller is required to keep
the inode reference. 

Song


>> added comments on requirements to callers of uprobe_register().

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] tracing: remove igrab() iput() call from uprobes.c
  2018-04-20 18:36   ` Song Liu
@ 2018-04-20 18:40     ` Steven Rostedt
  2018-04-20 18:49       ` Song Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Steven Rostedt @ 2018-04-20 18:40 UTC (permalink / raw)
  To: Song Liu
  Cc: LKML, Kernel Team, Ingo Molnar, Howard McLauchlan, Josef Bacik,
	Srikar Dronamraju, Miklos Szeredi

On Fri, 20 Apr 2018 18:36:38 +0000
Song Liu <songliubraving@fb.com> wrote:

> > On Apr 20, 2018, at 11:29 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> > 
> > On Fri, 20 Apr 2018 11:08:47 -0700
> > Song Liu <songliubraving@fb.com> wrote:
> >   
> >> For uprobes.c sisde, igrab() is not necessary. So we removed it and  
> > 
> > You don't need to send another patch, but what is the above sentence
> > suppose to say?
> > 
> > -- Steve
> >   
> 
> Sorry for the typo. I meant "For uprobes.c side". Or "it is not necessary
> to call igrab() in uprobe_register(), as the caller is required to keep
> the inode reference. 
> 

I'll update it to:

"For uprobes.c, it is not necessary to call igrab() in
uprobe_register(), as the caller is required to keep the inode
reference. The igrab() is removed and comments on this requirement is
added to uprobe_register()."

-- Steve

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] tracing: remove igrab() iput() call from uprobes.c
  2018-04-20 18:40     ` Steven Rostedt
@ 2018-04-20 18:49       ` Song Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Song Liu @ 2018-04-20 18:49 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Kernel Team, Ingo Molnar, Howard McLauchlan, Josef Bacik,
	Srikar Dronamraju, Miklos Szeredi



> On Apr 20, 2018, at 11:40 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> On Fri, 20 Apr 2018 18:36:38 +0000
> Song Liu <songliubraving@fb.com> wrote:
> 
>>> On Apr 20, 2018, at 11:29 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
>>> 
>>> On Fri, 20 Apr 2018 11:08:47 -0700
>>> Song Liu <songliubraving@fb.com> wrote:
>>> 
>>>> For uprobes.c sisde, igrab() is not necessary. So we removed it and  
>>> 
>>> You don't need to send another patch, but what is the above sentence
>>> suppose to say?
>>> 
>>> -- Steve
>>> 
>> 
>> Sorry for the typo. I meant "For uprobes.c side". Or "it is not necessary
>> to call igrab() in uprobe_register(), as the caller is required to keep
>> the inode reference. 
>> 
> 
> I'll update it to:
> 
> "For uprobes.c, it is not necessary to call igrab() in
> uprobe_register(), as the caller is required to keep the inode
> reference. The igrab() is removed and comments on this requirement is
> added to uprobe_register()."
> 
> -- Steve


Looks good!

Thanks,
Song

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-20 18:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-20 18:08 [PATCH v4] tracing: remove igrab() iput() call from uprobes.c Song Liu
2018-04-20 18:29 ` Steven Rostedt
2018-04-20 18:36   ` Song Liu
2018-04-20 18:40     ` Steven Rostedt
2018-04-20 18:49       ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).