“signature checking to validate pointers” works great if used consistently.
Have a valid and invalid signature and check every (for some value every)
access to allocated regions for invalid or corrupt signatures. The truly
paranoid frame the data with signatures on either end. A single ULONG value
(like a pooltag) is sufficient and keeps the overhead down.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-286698-
xxxxx@lists.osr.com] On Behalf Of Bob Kjelgaard
Sent: Monday, May 14, 2007 1:16 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] !verifier “PoolAddress” -> !poolval
?
>
> >>
> > What is it you are trying to do?
>
> Merely trying to understand (and catch) the source of what appears to
> be a
> pool corruption by my driver. It very difficult because verifier hasn't
> caught it, even with special pool enabled.
>
> All I know is that sometime after my driver has been running, another
> random driver in the system will crash with some type of pool
> corruption
> problem (a couple if different ones).
>
> Interestingly, if I prevent my driver from freeing allocated pool
> pages, I
> am yet to see a crash. That suggests to me that it _is_ indeed somehow
> corrupting the pages it is using... or freeing pages it isn't using???
>
> <<
>
> Thanks, Mark (I'm thinking you actually said most of that to begin
> with, so it was probably not a very good question on my part).
>
> Two other tools that *might* help are PreFast For Drivers, and Static
> Driver Verifier in the Vista WDK. They'll work for WDM drivers (SDV
> requires "C" only). Both work directly on your build machine.
>
> The comment about it not occurring if you don't free anything did
> remind me of something, though:
>
> Do you walk any list structures (e.g. using LIST_ENTRY) in some of
> these pool allocations? Is there any chance you might have cases where
> an entry points into a freed allocation? If the allocations aren't
> freed, then you never corrupt anything, because nobody else ever gets
> those addresses and puts something other than your list entries in
> them.
>
> In the bug I remember, the code was something like
>
> LIST_ENTRY MyEntry = MyStruct->ListEntry;
>
> AcquireLockOnTheList();
>
> Remove(MyEntry);
>
> I suspect the original author meant to use the address of the entry,
> but what they did was snap the current entry to the stack, then
> acquired the lock. Well, by the time you acquire it, someone else may
> have changed the entries before or after yours in the list, and that
> snapshot is worthless- the driver started "adjusting" pointers in
> memory now owned by someone else that often weren't even pointers- add
> further problems with the resulting broken links, and you get pool
> corruption, stack corruption, etc...
>
> You could generalize that back to "do you have pointers from one item
> to another that might not get updated properly before you free whatever
> they're pointing at?".
>
> Sometimes one can figure out cheap tracking code for problems like that
> (signature checking to validate pointers, for instance)...
>
>
> ---
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer