pm: add mproc table sanity check feature
. make procfs check it . detects pm/procfs mismatches . was triggered by ack/clang pm/procfs: add padding to mproc struct to align ack/clang layout to fix this
This commit is contained in:
parent
b1eba81b9d
commit
c24d15b2db
3 changed files with 27 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <timers.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/* 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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue