diff --git a/servers/pm/main.c b/servers/pm/main.c index aaa2d6bab..90da3812f 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -207,6 +207,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info) /* Initialize process table, including timers. */ for (rmp=&mproc[0]; rmp<&mproc[NR_PROCS]; rmp++) { init_timer(&rmp->mp_timer); + rmp->mp_magic = MP_MAGIC; } /* Build the set of signals which cause core dumps, and the set of signals diff --git a/servers/pm/mproc.h b/servers/pm/mproc.h index ce6fff9af..e841f0152 100644 --- a/servers/pm/mproc.h +++ b/servers/pm/mproc.h @@ -8,6 +8,8 @@ #include #include +#include + /* Needs to be included here, for 'ps' etc */ #include "const.h" @@ -44,6 +46,9 @@ EXTERN struct mproc { sigset_t mp_ksigpending; /* bitmap for pending signals from the kernel */ sigset_t mp_sigtrace; /* signals to hand to tracer first */ struct sigaction mp_sigact[_NSIG]; /* as in sigaction(2) */ +#ifdef __ACK__ + char mp_padding[60]; /* align structure with new libc */ +#endif vir_bytes mp_sigreturn; /* address of C library __sigreturn function */ struct timer mp_timer; /* watchdog timer for alarm(2), setitimer(2) */ clock_t mp_interval[NR_ITIMERS]; /* setitimer(2) repetition intervals */ @@ -63,6 +68,8 @@ EXTERN struct mproc { endpoint_t mp_scheduler; /* scheduler endpoint id */ char mp_name[PROC_NAME_LEN]; /* process name */ + + int mp_magic; /* sanity check, MP_MAGIC */ } mproc[NR_PROCS]; /* Flag values */ @@ -85,4 +92,4 @@ EXTERN struct mproc { #define TRACE_ZOMBIE 0x10000 /* waiting for tracer to issue WAIT call */ #define DELAY_CALL 0x20000 /* waiting for call before sending signal */ - +#define MP_MAGIC 0xC0FFEE0 diff --git a/servers/procfs/tree.c b/servers/procfs/tree.c index 9b4478ec6..e71513fea 100644 --- a/servers/procfs/tree.c +++ b/servers/procfs/tree.c @@ -77,6 +77,22 @@ PRIVATE int dir_is_pid(struct inode *node) get_inode_index(node) != NO_INDEX); } +PRIVATE int mproc_ok(struct mproc *tab, int slots) +{ + int i; + + /* sanity check of mproc */ + + for(i = 0; i < slots; i++) { + if(tab[i].mp_magic != MP_MAGIC) { + printf("procfs: mproc table magic number mismatch\n"); + return 0; + } + } + + return 1; +} + /*===========================================================================* * update_tables * *===========================================================================*/ @@ -99,6 +115,8 @@ PRIVATE int update_tables(void) if ((r = getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc)) != OK) return r; + if(!mproc_ok(mproc, NR_PROCS)) return EINVAL; + if ((r = getsysinfo(VFS_PROC_NR, SI_PROC_TAB, fproc)) != OK) return r; return OK;