EFAULT refresh
PATCH 1/1 EFAULT refresh
Here is a refresh of the EFAULT patch. This fixes a lot of crashes in LTP, and presumably in regular applications too. This still needs to have the checking foldded into lock_user(), but there were a handful of small fixes since this patch was last sent out.
Stuart
Stuart R. Anderson [email protected] Network & Software Engineering http://www.netsweng.com/ 1024D/37A79149: 0791 D3B8 9A4C 2CDC A31F BD03 0A62 E534 37A7 9149
exec.c +23 -0
@@ -1785,6 +1785,29 @@spin_unlock (&tb_lock); } +int page_check_range (target_ulong start,target_ulong len,int flags) +{ +PageDesc *p; +target_ulong end; +target_ulong addr; + + end =TARGET_PAGE_ALIGN (start+len);/* must do before we loose bits in the next step */ + start = start &TARGET_PAGE_MASK ; + +if ( end < start )return EFAULT ;/* we've wrapped around */ +for (addr = start; addr < end; addr +=TARGET_PAGE_SIZE ) { + p =page_find (addr >>TARGET_PAGE_BITS ); +if ( !p )return EFAULT ; +if ( !(p->flags &PAGE_VALID ) )return EFAULT ; + +if (!(p->flags &PAGE_READ ) && + (flags &PAGE_READ ) )return EFAULT ; +if (!(p->flags &PAGE_WRITE ) && + (flags &PAGE_WRITE ) )return EFAULT ; + } +return 0 ; +} +/* called from signal handler: invalidate the code and unprotect the page. Return TRUE if the fault was succesfully handled. */ int page_unprotect (target_ulong address,unsigned long pc,void *puc)
cpu-all.h +1 -0
@@ -689,6 +689,7 @@int page_get_flags (target_ulong address);void page_set_flags (target_ulong start,target_ulong end,int flags);void page_unprotect_range (target_ulong data,target_ulong data_size); +int page_check_range (target_ulong start,target_ulong len,int flags);#define SINGLE_CPU_DEFINES #ifdef SINGLE_CPU_DEFINES
linux-user/syscall.c +149 -59
545 lines not on this page · raw message