📄 uml-2.6.10-fc3.patch
字号:
+ * signal handler stack frames.+ */+ err |= __put_user(0xb8, (char __user *)(frame->retcode+0));+ err |= __put_user(__NR_rt_sigreturn, (int __user *)(frame->retcode+1));+ err |= __put_user(0x80cd, (short __user *)(frame->retcode+5));++ if(err)+ return(err);++ PT_REGS_SP(regs) = (unsigned long) frame;+ PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;+ PT_REGS_EAX(regs) = (unsigned long) sig;+ PT_REGS_EDX(regs) = (unsigned long) &frame->info;+ PT_REGS_ECX(regs) = (unsigned long) &frame->uc;++ if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))+ ptrace_notify(SIGTRAP);+ return(0);+}++long sys_sigreturn(struct pt_regs regs)+{+ unsigned long __user sp = PT_REGS_SP(¤t->thread.regs);+ struct sigframe __user *frame = (struct sigframe *)(sp - 8);+ sigset_t set;+ struct sigcontext __user *sc = &frame->sc;+ unsigned long __user *oldmask = &sc->oldmask;+ unsigned long __user *extramask = &frame->extramask;+ int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);++ if(copy_from_user(&set.sig[0], oldmask, sizeof(&set.sig[0])) ||+ copy_from_user(&set.sig[1], extramask, sig_size))+ goto segfault;++ sigdelsetmask(&set, ~_BLOCKABLE);++ spin_lock_irq(¤t->sighand->siglock);+ current->blocked = set;+ recalc_sigpending();+ spin_unlock_irq(¤t->sighand->siglock);++ if(copy_sc_from_user(¤t->thread.regs, sc))+ goto segfault;++ PT_REGS_SYSCALL_NR(¤t->thread.regs) = -1; /* Avoid ERESTART handling */+ return(PT_REGS_SYSCALL_RET(¤t->thread.regs));++ segfault:+ force_sig(SIGSEGV, current);+ return 0;+}++long sys_rt_sigreturn(struct pt_regs regs)+{+ unsigned long __user sp = PT_REGS_SP(¤t->thread.regs);+ struct rt_sigframe __user *frame = (struct rt_sigframe *) (sp - 4);+ sigset_t set;+ struct ucontext __user *uc = &frame->uc;+ int sig_size = _NSIG_WORDS * sizeof(unsigned long);++ if(copy_from_user(&set, &uc->uc_sigmask, sig_size))+ goto segfault;++ sigdelsetmask(&set, ~_BLOCKABLE);++ spin_lock_irq(¤t->sighand->siglock);+ current->blocked = set;+ recalc_sigpending();+ spin_unlock_irq(¤t->sighand->siglock);++ if(copy_sc_from_user(¤t->thread.regs, &uc->uc_mcontext))+ goto segfault;++ PT_REGS_SYSCALL_NR(¤t->thread.regs) = -1; /* Avoid ERESTART handling */+ return(PT_REGS_SYSCALL_RET(¤t->thread.regs));++ segfault:+ force_sig(SIGSEGV, current);+ return 0;+}++/*+ * Overrides for Emacs so that we follow Linus's tabbing style.+ * Emacs will notice this stuff at the end of the file and automatically+ * adjust the settings for this buffer only. This must remain at the end+ * of the file.+ * ---------------------------------------------------------------------------+ * Local variables:+ * c-file-style: "linux"+ * End:+ */Index: linux-2.6.10/arch/um/sys-i386/ptrace_user.c===================================================================--- linux-2.6.10.orig/arch/um/sys-i386/ptrace_user.c 2004-12-25 05:35:50.000000000 +0800+++ linux-2.6.10/arch/um/sys-i386/ptrace_user.c 2005-04-07 22:05:29.480760432 +0800@@ -17,17 +17,30 @@ int ptrace_getregs(long pid, unsigned long *regs_out) {- return(ptrace(PTRACE_GETREGS, pid, 0, regs_out));+ if(ptrace(PTRACE_GETREGS, pid, 0, regs_out) < 0)+ return(-errno);+ return(0); } int ptrace_setregs(long pid, unsigned long *regs) {- return(ptrace(PTRACE_SETREGS, pid, 0, regs));+ if(ptrace(PTRACE_SETREGS, pid, 0, regs) < 0)+ return(-errno);+ return(0); } int ptrace_getfpregs(long pid, unsigned long *regs) {- return(ptrace(PTRACE_GETFPREGS, pid, 0, regs));+ if(ptrace(PTRACE_GETFPREGS, pid, 0, regs) < 0)+ return(-errno);+ return(0);+}++int ptrace_setfpregs(long pid, unsigned long *regs)+{+ if(ptrace(PTRACE_SETFPREGS, pid, 0, regs) < 0)+ return(-errno);+ return(0); } static void write_debugregs(int pid, unsigned long *regs)Index: linux-2.6.10/arch/um/sys-i386/sysrq.c===================================================================--- linux-2.6.10.orig/arch/um/sys-i386/sysrq.c 2004-12-25 05:33:49.000000000 +0800+++ linux-2.6.10/arch/um/sys-i386/sysrq.c 2005-04-07 22:05:29.480760432 +0800@@ -33,3 +33,13 @@ show_trace((unsigned long *) ®s); }++/* Overrides for Emacs so that we follow Linus's tabbing style.+ * Emacs will notice this stuff at the end of the file and automatically+ * adjust the settings for this buffer only. This must remain at the end+ * of the file.+ * ---------------------------------------------------------------------------+ * Local variables:+ * c-file-style: "linux"+ * End:+ */Index: linux-2.6.10/arch/um/sys-i386/Makefile===================================================================--- linux-2.6.10.orig/arch/um/sys-i386/Makefile 2004-12-25 05:34:01.000000000 +0800+++ linux-2.6.10/arch/um/sys-i386/Makefile 2005-04-07 22:05:29.480760432 +0800@@ -1,5 +1,5 @@ obj-y = bitops.o bugs.o checksum.o fault.o ksyms.o ldt.o ptrace.o \- ptrace_user.o semaphore.o sigcontext.o syscalls.o sysrq.o+ ptrace_user.o semaphore.o signal.o sigcontext.o syscalls.o sysrq.o obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_MODULES) += module.oIndex: linux-2.6.10/arch/um/sys-i386/sigcontext.c===================================================================--- linux-2.6.10.orig/arch/um/sys-i386/sigcontext.c 2004-12-25 05:33:49.000000000 +0800+++ linux-2.6.10/arch/um/sys-i386/sigcontext.c 2005-04-07 22:05:29.480760432 +0800@@ -9,22 +9,14 @@ #include <asm/sigcontext.h> #include "sysdep/ptrace.h" #include "kern_util.h"-#include "frame_user.h"--int sc_size(void *data)-{- struct arch_frame_data *arch = data;-- return(sizeof(struct sigcontext) + arch->fpstate_size);-} void sc_to_sc(void *to_ptr, void *from_ptr) { struct sigcontext *to = to_ptr, *from = from_ptr;- int size = sizeof(*to) + signal_frame_sc.common.arch.fpstate_size; - memcpy(to, from, size);- if(from->fpstate != NULL) to->fpstate = (struct _fpstate *) (to + 1);+ memcpy(to, from, sizeof(*to) + sizeof(struct _fpstate));+ if(from->fpstate != NULL)+ to->fpstate = (struct _fpstate *) (to + 1); } unsigned long *sc_sigmask(void *sc_ptr)Index: linux-2.6.10/arch/um/kernel/main.c===================================================================--- linux-2.6.10.orig/arch/um/kernel/main.c 2004-12-25 05:35:24.000000000 +0800+++ linux-2.6.10/arch/um/kernel/main.c 2005-04-07 22:05:29.480760432 +0800@@ -81,6 +81,8 @@ extern int uml_exitcode; +extern void scan_elf_aux( char **envp);+ int main(int argc, char **argv, char **envp) { char **new_argv;@@ -147,6 +149,8 @@ set_handler(SIGTERM, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1); set_handler(SIGHUP, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1); + scan_elf_aux( envp);+ do_uml_initcalls(); ret = linux_main(argc, argv); @@ -155,18 +159,20 @@ int err; printf("\n");-- /* Let any pending signals fire, then disable them. This- * ensures that they won't be delivered after the exec, when- * they are definitely not expected.- */- unblock_signals();+ /* stop timers and set SIG*ALRM to be ignored */ disable_timer();+ /* disable SIGIO for the fds and set SIGIO to be ignored */ err = deactivate_all_fds(); if(err) printf("deactivate_all_fds failed, errno = %d\n", -err); + /* Let any pending signals fire now. This ensures+ * that they won't be delivered after the exec, when+ * they are definitely not expected.+ */+ unblock_signals();+ execvp(new_argv[0], new_argv); perror("Failed to exec kernel"); ret = 1;Index: linux-2.6.10/arch/um/kernel/process.c===================================================================--- linux-2.6.10.orig/arch/um/kernel/process.c 2004-12-25 05:35:25.000000000 +0800+++ linux-2.6.10/arch/um/kernel/process.c 2005-04-07 22:05:29.481760280 +0800@@ -13,6 +13,7 @@ #include <setjmp.h> #include <sys/time.h> #include <sys/ptrace.h>+#include <linux/ptrace.h> #include <sys/wait.h> #include <sys/mman.h> #include <asm/ptrace.h>@@ -285,6 +286,9 @@ printk("Checking that ptrace can change system call numbers..."); pid = start_ptraced_child(&stack); + if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0)+ panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno);+ while(1){ if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) panic("check_ptrace : ptrace failed, errno = %d", @@ -292,8 +296,8 @@ CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); if(n < 0) panic("check_ptrace : wait failed, errno = %d", errno);- if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))- panic("check_ptrace : expected SIGTRAP, "+ if(!WIFSTOPPED(status) || (WSTOPSIG(status) != (SIGTRAP|SYSCALL_TRAP)))+ panic("check_ptrace : expected (SIGTRAP|SYSCALL_TRAP), " "got status = %d", status); syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET,Index: linux-2.6.10/arch/um/kernel/initrd_user.c===================================================================--- linux-2.6.10.orig/arch/um/kernel/initrd_user.c 2004-12-25 05:34:26.000000000 +0800+++ linux-2.6.10/arch/um/kernel/initrd_user.c 2005-04-07 22:05:29.481760280 +0800@@ -29,6 +29,8 @@ filename, -n); return(-1); }++ os_close_file(fd); return(0); } Index: linux-2.6.10/arch/um/kernel/time_kern.c===================================================================--- linux-2.6.10.orig/arch/um/kernel/time_kern.c 2004-12-25 05:35:00.000000000 +0800+++ linux-2.6.10/arch/um/kernel/time_kern.c 2005-04-07 22:05:29.481760280 +0800@@ -170,7 +170,7 @@ void timer_handler(int sig, union uml_pt_regs *regs) { local_irq_disable();- update_process_times(user_context(UPT_SP(regs)));+ update_process_times(CHOOSE_MODE(user_context(UPT_SP(regs)), (regs)->skas.is_user)); local_irq_enable(); if(current_thread->cpu == 0) timer_irq(regs);Index: linux-2.6.10/arch/um/kernel/helper.c===================================================================--- linux-2.6.10.orig/arch/um/kernel/helper.c 2004-12-25 05:34:45.000000000 +0800+++ linux-2.6.10/arch/um/kernel/helper.c 2005-04-07 22:05:29.482760128 +0800@@ -49,14 +49,14 @@ return(0); } -/* XXX The alloc_stack here breaks if this is called in the tracing thread */-+/* Returns either the pid of the child process we run or -E* on failure.+ * XXX The alloc_stack here breaks if this is called in the tracing thread */ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv, unsigned long *stack_out) { struct helper_data data; unsigned long stack, sp;- int pid, fds[2], err, n;+ int pid, fds[2], ret, n; if((stack_out != NULL) && (*stack_out != 0)) stack = *stack_out;@@ -64,16 +64,16 @@ if(stack == 0) return(-ENOMEM); - err = os_pipe(fds, 1, 0);- if(err < 0){- printk("run_helper : pipe failed, err = %d\n", -err);+ ret = os_pipe(fds, 1, 0);+ if(ret < 0){+ printk("run_helper : pipe failed, ret = %d\n", -ret); goto out_free; } - err = os_set_exec_close(fds[1], 1);- if(err < 0){- printk("run_helper : setting FD_CLOEXEC failed, err = %d\n",- -err);+ ret = os_set_exec_close(fds[1], 1);+ if(ret < 0){+ printk("run_helper : setting FD_CLOEXEC failed, ret = %d\n",+ -ret); goto out_close; } @@ -85,34 +85,36 @@ pid = clone(helper_child, (void *) sp, CLONE_VM | SIGCHLD, &data); if(pid < 0){ printk("run_helper : clone failed, errno = %d\n", errno);- err = -errno;+ ret = -errno; goto out_close; } os_close_file(fds[1]);- n = os_read_file(fds[0], &err, sizeof(err));+ fds[1] = -1;++ /*Read the errno value from the child.*/+ n = os_read_file(fds[0], &ret, sizeof(ret)); if(n < 0){- printk("run_helper : read on pipe failed, err = %d\n", -n);- err = n;- goto out_kill;+ printk("run_helper : read on pipe failed, ret = %d\n", -n);+ ret = n;+ os_kill_process(pid, 1); } else if(n != 0){ CATCH_EINTR(n = waitpid(pid, NULL, 0));- pid = -errno;+ ret = -errno;+ } else {+ ret = pid; } - if(stack_out == NULL) free_stack(stack, 0);- else *stack_out = stack;- return(pid);-- out_kill:- os_kill_process(pid, 1); out_close:+ if (fds[1] != -1)+ os_close_file(fds[1]); os_close_file(fds[0]);- os_close_file(fds[1]); out_free:- free_stack(stack, 0);- return(err);+ if(stack_out == NULL)+ free_stack(stack, 0);+ else *stack_out = stack;+ return(ret); } int run_helper_thread(int (*proc)(void *), void *arg, unsigned int flags, Index: linux-2.6.10/arch/um/kernel/irq_user.c===================================================================--- linux-2.6.10.orig/arch/um/kernel/irq_user.c 2004-12-25 05:34:32.000000000 +0800+++ linux-2.6.10/arch/um/kernel/irq_user.c 2005-04-07 22:05:29.482760128 +0800@@ -374,6 +374,8 @@ if(err) return(err); }+ /* If there is a signal already queued, after unblocking ignore it */+ set_handler(SIGIO, SIG_IGN, 0, -1); return(0); }Index: linux-2.6.10/arch/um/kernel/mem.c===================================================================--- linux-2.6.10.orig/arch/um/kernel/mem.c 2004-12-25 05:34:32.000000000 +0800+++ linux-2.6.10/arch/um/kernel/mem.c 2005-04-07 22:05:29.482760128 +0800@@ -175,6 +175,30 @@ } #endif /* CONFIG_HIGHMEM */ +static void __init fixaddr_user_init( void)+{+ long size = FIXADDR_USER_END - FIXADDR_USER_START;+ pgd_t *pgd;+ pmd_t *pmd;+ pte_t *pte;+ unsigned long paddr, vaddr = FIXADDR_USER_START;++ if ( ! size )+ return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -