- UML - copy_user fixes
PATCH 1/1 - UML - copy_user fixes
This patch fixes some copy_user bugs:
kernelspace page faults that happen on behalf of a process are now
correctly handled
add copy_user treatment so a fault handler which looks at the faulting
instruction
added a note to do the same with the ldt stuff some day
Signed-off-by Jeff Dike <[email protected]>
arch/um/include/user_util.h +1 -0
@@ -88,6 +88,7 @@extern void forward_pending_sigio (int target);extern int can_do_skas (void );extern void arch_init_thread (void ); +extern int setjmp_wrapper (void (*proc)(void *,void *), ...);extern int __raw (int fd,int complain,int now);#define raw (fd, complain) __raw((fd), (complain), 1)
arch/um/kernel/skas/uaccess.c +44 -13
87 lines not on this page · raw message
arch/um/kernel/user_util.c +16 -0
@@ -8,6 +8,7 @@#include <unistd.h> #include <limits.h> #include <sys/mman.h> +#include <setjmp.h> #include <sys/stat.h> #include <sys/ptrace.h> #include <sys/utsname.h>
@@ -169,6 +170,21 @@ host.release, host.version, host.machine); } +int setjmp_wrapper (void (*proc)(void *,void *), ...) +{ +va_list args; +sigjmp_buf buf; +int n; + + n =sigsetjmp (buf,1 ); +if (n ==0 ){ +va_start (args, proc); + (*proc)(&buf, &args); + } +va_end (args); +return (n); +} +/* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically
arch/um/sys-i386/bugs.c +4 -3
@@ -183,15 +183,16 @@int arch_handle_signal (int sig,union uml_pt_regs *regs) { -unsigned long ip; +unsigned char tmp[2 ];/* This is testing for a cmov (0x0f 0x4x) instruction causing a * SIGILL in init. */ if ((sig !=SIGILL ) || (TASK_PID (get_current ()) !=1 ))return (0 ); - ip =UPT_IP (regs); -if ((*((char *) ip) !=0x0f ) || ((*((char *) (ip +1 )) &0xf0 ) !=0x40 )) +if (copy_from_user_proc (tmp, (void *)UPT_IP (regs),2 )) +panic ("SIGILL in init, could not read instructions!\n" ); +if ((tmp[0 ] !=0x0f ) || ((tmp[1 ] &0xf0 ) !=0x40 ))return (0 );if (host_has_cmov ==0 )
arch/um/sys-i386/ldt.c +2 -0
@@ -13,6 +13,8 @@#ifdef CONFIG_MODE_TT extern int modify_ldt (int func,void *ptr,unsigned long bytecount); +/* XXX this needs copy_to_user and copy_from_user */ +int sys_modify_ldt_tt (int func,void *ptr,unsigned long bytecount) {if (verify_area (VERIFY_READ , ptr, bytecount))return (-EFAULT );