summaryrefslogtreecommitdiff
path: root/sys/src/9/port/portdat.h
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-02-23 18:00:21 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2020-02-23 18:00:21 +0100
commit4a80d9d029891e056a7badeeea8e3b588efd694b (patch)
tree2f37c2e83416f47df87d40eae2e2120cd8bcb049 /sys/src/9/port/portdat.h
parentf7c60230669e8e00bc794f07726070d577d5aa3f (diff)
kernel: fix multiple devproc bugs and pid reuse issues
devproc assumes that when we hold the Proc.debug qlock, the process will be prevented from exiting. but there is another race where the process has already exited and the Proc* slot gets reused. to solve this, on process creation we also have to acquire the debug qlock while initializing the fields of the process. this also means newproc() should only initialize fields *not* protected by the debug qlock. always acquire the Proc.debug qlock when changing strings in the proc structure to avoid doublefree on concurrent update. for changing the user string, we add a procsetuser() function that does this for auth.c and devcap. remove pgrpnote() from pgrp.c and replace by static postnotepg() in devproc. avoid the assumption that the Proc* entries returned by proctab() are continuous. fixed devproc permission issues: - make sure only eve can access /proc/trace - none should only be allowed to read its own /proc/n/text - move Proc.kp checks into procopen() pid reuse was not handled correctly, as we where only checking if a pid had a living process, but there still could be processes expecting a particular parentpid or noteid. this is now addressed with reference counted Pid structures which are organized in a hash table. read access to the hash table does not require locks which will be usefull for dtracy later.
Diffstat (limited to 'sys/src/9/port/portdat.h')
-rw-r--r--sys/src/9/port/portdat.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/src/9/port/portdat.h b/sys/src/9/port/portdat.h
index 2a1cd3b07..7c9aa7193 100644
--- a/sys/src/9/port/portdat.h
+++ b/sys/src/9/port/portdat.h
@@ -187,7 +187,6 @@ struct Chan
Mnt* mux; /* Mnt for clients using me for messages */
union {
void* aux;
- Qid pgrpid; /* for #p/notepg */
ulong mid; /* for ns in devproc */
};
Chan* mchan; /* channel to mounted server */
@@ -649,28 +648,31 @@ struct Proc
Mach *mach; /* machine running this proc */
char *text;
char *user;
+
char *args;
int nargs; /* number of bytes of args */
int setargs; /* process changed its args */
+
Proc *rnext; /* next process in run queue */
Proc *qnext; /* next process on queue for a QLock */
- QLock *qlock; /* addr of qlock being queued for DEBUG */
- int state;
+
char *psstate; /* What /proc/#/status reports */
- Segment *seg[NSEG];
- QLock seglock; /* locked whenever seg[] changes */
+ int state;
+
ulong pid;
ulong noteid; /* Equivalent of note group */
ulong parentpid;
- Proc *pidhash; /* next proc in pid hash */
+ Proc *parent; /* Process to send wait record on exit */
Lock exl; /* Lock count and waitq */
Waitq *waitq; /* Exited processes wait children */
int nchild; /* Number of living children */
int nwait; /* Number of uncollected wait records */
QLock qwaitr;
Rendez waitr; /* Place to hang out in wait */
- Proc *parent;
+
+ QLock seglock; /* locked whenever seg[] changes */
+ Segment *seg[NSEG];
Pgrp *pgrp; /* Process group for namespace */
Egrp *egrp; /* Environment group */