Subject: Re: kernel stack overflow detection
To: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
From: None <cgd@broadcom.com>
List: tech-kern
Date: 06/10/2002 12:20:00
At Mon, 10 Jun 2002 21:47:20 +0900 (JST), YAMAMOTO Takashi wrote:
> i slightly updated my patch as you suggest. (attached)
Aside from formatting issues, I'd at least suggest the following:
* Pick a better name for "SHAM_USPACE." In fact, I'm not sure why you
bother with having a separate variable for it at all. (I.e., why
not expose the actual size to userland, etc.)
* have have extra crud in your conf/files diff.
* In:
> +void
> +kstack_setup_magic(const struct proc *p)
> +{
> + u_int32_t *ip;
> + u_int32_t const *end;
> +
> + KASSERT(p != 0);
> + KASSERT(p != &proc0);
> +
> + /*
> + * fill all the stack with magic number
> + * so that later modification on it can be detected.
> + */
> + ip = (u_int32_t *)(KSTACK_END(p) + SHAM_USPACE - USPACE);
> + end = (u_int32_t *)((caddr_t)KSTACK_END(p) + KSTACK_SIZE / 2); /* XXX */
> + for (; ip < end; ip++) {
> + *ip = KSTACK_MAGIC;
> + }
> +}
What's the "/ 2" for?!
chris