Re: trusting relatives

John Ogness <[email protected]>
Newsgroups gmane.linux.dazuko.devel
Message-ID <[email protected]>
Tikka, Sami wrote:
> Woohoo! This looks very nice! Your current implementation matches, at least
> conceptually, pretty closely the trusted pid patch I originally posted. You
> have added some extra checks for the situation where another process has
> taken the same pid. I am happy!

:)



> I'd like to clarify how the "relatives" check is done. It seems to me that
> the while loop below would step up thru the process family hierarchy until it
> finds a process that is its own parent. What kind of a process is that?

Every process can be traced back up to the "init" process (PID 1). This 
process is identifiable because it is its own parent. Dazuko goes up the 
tree until finding the last process *before* init. In other words, Dazuko 
climbs until the parent of the parent points to the parent.

The first 2 if-statements are there for safety (in theory they should never 
match). The 3rd if-statement is there in case the init process itself has 
requested to be trusted by Dazuko (I do not expect this statement to ever 
match either). It is the 4th if-statement that actually identifies that 
we've found the highest parent below init and can exit the loop.


> static inline struct task_struct* get_root_parent(struct task_struct *p)
> {
>         struct task_struct      *ts = p;
> 
>         while (1)
>         {
>                 if (ts == NULL)
>                         return NULL;
> 
>                 if (ts->p_pptr == NULL)
>                         return ts;
> 
>                 if (ts == ts->p_pptr)
>                         return ts;
> 
>                 if (ts->p_pptr == ts->p_pptr->p_pptr)
>                         return ts;
> 
>                 ts = ts->p_pptr;
>         }
> }

John Ogness

-- 
Dazuko Maintainer
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.