stub_clone_handler(void) { long err; struct stub_data *from = (struct stub_data *) UML_CONFIG_STUB_DATA; err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD, UML_CONFIG_STUB_DATA + PAGE_SIZE / 2 - sizeof(void *)); if(err != 0) goto out; err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0); if(err) goto out; err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL, (long) &from->timer, 0); if(err) goto out; err = stub_syscall6(STUB_MMAP_NR, UML_CONFIG_STUB_DATA, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, from->fd, from->offset); out: /* save current result. Parent: pid; child: retcode of mmap */ from->err = err; trap_myself(); }
stub_clone_handler(void) { struct stub_data *data = (struct stub_data *) STUB_DATA; long err; err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD, STUB_DATA + UM_KERN_PAGE_SIZE / 2 - sizeof(void *)); if(err != 0) goto out; err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0); if(err) goto out; err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL, (long) &data->timer, 0); if(err) goto out; remap_stack(data->fd, data->offset); goto done; out: /* save current result. * Parent: pid; * child: retcode of mmap already saved and it jumps around this * assignment */ data->err = err; done: trap_myself(); }
stub_segv_handler(int sig) { struct sigcontext *sc = (struct sigcontext *) (&sig + 1); int pid; GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA), sc); pid = stub_syscall0(__NR_getpid); stub_syscall2(__NR_kill, pid, SIGUSR1); /* Load pointer to sigcontext into esp, since we need to leave * the stack in its original form when we do the sigreturn here, by * hand. */ __asm__ __volatile__("mov %0,%%esp ; movl %1, %%eax ; " "int $0x80" : : "a" (sc), "g" (__NR_sigreturn)); }