Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 May 2002 13:18:20 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Archie Cobbs <archie@dellroad.org>
Cc:        Jake Burkholder <jake@locore.ca>, freebsd-arch@FreeBSD.ORG
Subject:   Re: Kernel stack overflow detection?
Message-ID:  <3CF5378C.52C15200@mindspring.com>
References:  <200205291920.g4TJKkE92786@arch20m.dellroad.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Archie Cobbs wrote:
> +        * Map the 1st and the 3rd UPAGES pages as writable and the 2nd
> +        * page as read-only to detect kernel stack overflows.
> +        *
> +        * Because of the way fillkptphys() works we have to do this in
> +        * three stages: 1st page RW, 2nd page RO, and pages 3-N RW.
> +        */

IMO, the 2nd page should be unmapped, not mapped R/O.

With it mapped R/O, you won't detect reads of auto variables in a
terminal function which are not used for a given code path, but
might be used for a different code path.

You might be able to 100% trust the compiler for "might be used
before initialized".

Also, while it's not a problem for most people, mapping it R/O
on the 386 won't actually do anything when it comes to writing it
from kernel space (no fault will be generated because the 386 lacks
this capability, even if it lets you map that way).  Unmapping it
will ensure a fault, even on the 386.

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3CF5378C.52C15200>