Re: buffer overflow and caches
security issue: yes but this protection was not present in earlier pentium based systems (referring to Chapter 10, Computer Systems by Bryant)
what i wish to understand is the strategy adopted in those classes of systems to synchronize data between d and i cache while using a write through approach.
how to decide which cache i or d should contain data
i'll have to work out an example. it'll take some time.
here's a quick one though
#syntax is gcc based mov %esp, %eax push $(0x23843443) push $(0x23424345) . . . #stack is in d-cache now jmp (%eax) # d-cache miss, bring old stack from L2 cache in i-cache # stack is present in both d-cache and i-cache # assume DEP not enabled
set of NOPS: yes but i want to understand the cache management scheme for separation of content for d and i cache.
Congratulations on the green belt.
The protection was software-based. It may not have been as good as it is now, but it is still better than nothing.
The method for cache handling was not the best in the older processors. IIRC it would use data from d-cache as it is referenced by instructions.
In your example above, it would only worry about the stack in d-cache. OK I'll try and explain this:
- Instruction block loaded into i-cache
- Instructions executed in sequential order.
- As they reference data that is in RAM, if the item does not exist in d-cache it will try and find it in i-cache.
- If not found in i-cache, it will look in RAM.
This is basically from what I remember of how they manage what goes into what cache. Some instructions, as a result of this scheme, will of course land in d-cache.
As for writing back:
- Modifications are recorded in d-cache
- When any operation that requires cache flush is performed, the d-cache is written back to RAM.
Setting IP to point to a data location, from my understanding, should move the d-cache data into i-cache. This is where the buffer execution vulnerabilities come in.
All this is how data is loaded into the respective caches. As for how data is written back, I am not exactly sure.
Strictly speaking the synchronization of caches should be transparent. And it is usually the d-cache that stores modifications and data addresses while the i-cache stores the instructions to be executed only. I think read operations will obtain data from d-cache if it is present in both caches as well.
|