|
From: | John Ogness |
Subject: | [Dazuko-devel] Re: trusting relatives |
Date: | Tue, 03 May 2005 12:46:02 +0200 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |