24.05.2014 Views

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

AIX Version 4.3 Differences Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

destructive overlay can be caught when it occurs if the kernel code is protected<br />

from overwrites. The <strong>AIX</strong> kernel has therefore been enhanced to provide some<br />

protection against these types of errors. The first page of memory is now<br />

protected from writes by setting page protection bits in virtual page tables. A<br />

similar scheme has been implemented for other pages in the kernel that contain<br />

nothing but code (since code should never be altered). Any attempt to overlay<br />

protected pages now results in dumps that point directly to the program that tried<br />

to do the overwriting. This cuts out the most expensive and time-consuming part<br />

of memory overlay debugging for a large number of overlay cases.<br />

For kernel text, enough symbol information has been added to the kernel space<br />

so that the kernel text is protected during system initialization. Note that pages<br />

containing a mixture of data and text, or data only, cannot be protected, so some<br />

kernel text remains writable.<br />

Kernel extension text areas are optionally protected. A run-time check enables<br />

the system loader to protect kernel extension text areas. If xmdbg is set by the<br />

bosdebug or bosboot commands, text pages are protected at kernel extension load<br />

time. Pages that share text and data are not protected.<br />

Note: This change has impacted kernel and kernel extension code that attempts<br />

to modify text. Self-modifying kernel extensions will cause the system to crash<br />

unless those extensions also modify the protection of the text pages.<br />

This design protects as many pages in the kernel space as is practical without<br />

disturbing delicate assembler routines or increasing the working set needed to<br />

run the kernel.<br />

2.6.1 Storage Protection Macro<br />

The STORE_PROTECT macro has been added to store-protect whole pages that<br />

reside between two symbols (x and y). This macro is defined as follows:<br />

#define STORE_PROTECT(x,y) if (STARTOFPAGE(y) > NEXTPAGE(x)) \<br />

vm_protect(NEXTPAGE(x),STARTOFPAGE(y)-NEXTPAGE(x),RDONLY)<br />

The STORE_PROTECT macro has the effect of protecting all pages starting with<br />

the next page boundary beyond x until the last page boundary before y. This<br />

macro is used during system initialization for the various regions in the kernel and<br />

conditionally by the loader during kernel extension load time.<br />

During system initialization, k_protect() is called to protect the regions marked by<br />

the bind steps. k_protect() is called from main() in the following sequence:<br />

debugger init(); /* start the kernel debugger */<br />

kmem init(); /* initialize kernel memory heaps */<br />

k_protect(); /* store protect kernel text areas */<br />

strtdisp(); /* start up the dispatcher */<br />

When called, k_protect() does the following:<br />

• Store protects low.o areas, at least the first three pages<br />

• Store protects pinned text sub binds<br />

• Store protects paged text sub binds<br />

18 <strong>AIX</strong> <strong>Version</strong> <strong>4.3</strong> <strong>Differences</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!