lkml.org 
[lkml]   [2004]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRE: [PATCH 2.6.9] fork: add a hook in do_fork()
From
Date
On Tue, 2004-11-23 at 01:59 -0800, Hua Zhong wrote:
> > + static int fork_hook_id = 0;
> > +
> > + /* We can set the hook if it's not already used */
> > + if ((func != NULL) && (fork_hook_id == 0)) {
> > + fork_hook = func;
> > + fork_hook_id = id;
> > + return 0;
> > + }
>
> What happens if two modules are calling the same function at the same time?

You are right there is a problem. I need to add a lock.

> > +
> > + if (fork_hook != NULL)
> > + fork_hook(current->pid, pid);
> > +
> > return pid;
>
> What happens if the module is unloaded between the test and the call to
> fork_hook?

Again you are right and I need to protect that.

In fact, Greg suggests to use LSM hook and it seams that it does what I
need. So my patch is obsolete now.

Thank you to everybody for your help,
Best Regards,

Guillaume

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:08    [W:0.254 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site