* Jamie Lokier wrote: > > + if (nx_enabled && (error_code & 16)) > > + printk(KERN_CRIT "kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n", current->uid); > > According to AMD's manual, bit 4 of error_code means the fault was due > to an instruction fetch. It doesn't imply that it's an NX-protected > page: it might be a page not present fault instead. (The manual > doesn't spell that out, it just says the bit is set when it's an > instruction fetch). > > Just so you realise that the above code fragments aren't logically > equivalent. i've attached an updated nx-prefetch-fix.patch that properly fixes this. I've also attached a delta relative to the previous patch. This patch will only print the 'possible exploit' warning if the kernel tries to execute a present page. (hence not printing the message in the quite common jump-to-address-zero crash case.) I've test-compiled and test-booted the full patch on 2.6.7-mm5 using the following x86 kernel configs: SMP+PAE, UP+PAE, SMP+!PAE, UP+!PAE, on an SMP P3 and an Athlon64 box. I've tested various types of instruction-fetch related kernel faults on the Athlon64 box, it all works fine. The full changelog: - fix possible prefetch-fault loop on NX page, based on suggestions from Jamie Lokier. - clean up nx feature dependencies - simplify detection of NX-violations when the kernel executes code - introduce pte_exec_kern() to simplify the NX logic - split the definitions out of pgtable-[23]level.h into pgtable-[23]level-defs.h, to enable the former to use generic pte functions from pgtable.h. Signed-off-by: Ingo Molnar