Apply some style(9) to Linuxulator linux_sysvec.c comments
This commit is contained in:
parent
c303c68d6a
commit
bc4d21ce60
@ -101,10 +101,9 @@ SYSCTL_PROC(_compat_linux, OID_AUTO, debug,
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allow the this functions to use the ldebug() facility
|
||||
* even though they are not syscalls themselves. Map them
|
||||
* to syscall 0. This is slightly less bogus than using
|
||||
* ldebug(sigreturn).
|
||||
* Allow the sendsig functions to use the ldebug() facility even though they
|
||||
* are not syscalls themselves. Map them to syscall 0. This is slightly less
|
||||
* bogus than using ldebug(sigreturn).
|
||||
*/
|
||||
#define LINUX_SYS_linux_rt_sendsig 0
|
||||
|
||||
@ -253,8 +252,7 @@ linux_set_syscall_retval(struct thread *td, int error)
|
||||
|
||||
/*
|
||||
* On Linux only %rcx and %r11 values are not preserved across
|
||||
* the syscall.
|
||||
* So, do not clobber %rdx and %r10
|
||||
* the syscall. So, do not clobber %rdx and %r10.
|
||||
*/
|
||||
td->td_retval[1] = frame->tf_rdx;
|
||||
frame->tf_r10 = frame->tf_rcx;
|
||||
@ -335,9 +333,7 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
size_t execpath_len;
|
||||
struct proc *p;
|
||||
|
||||
/*
|
||||
* Calculate string base and vector table pointers.
|
||||
*/
|
||||
/* Calculate string base and vector table pointers. */
|
||||
if (imgp->execpath != NULL && imgp->auxargs != NULL)
|
||||
execpath_len = strlen(imgp->execpath) + 1;
|
||||
else
|
||||
@ -345,7 +341,7 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
|
||||
p = imgp->proc;
|
||||
arginfo = (struct ps_strings *)p->p_sysent->sv_psstrings;
|
||||
destp = (caddr_t)arginfo - SPARE_USRSPACE -
|
||||
destp = (caddr_t)arginfo - SPARE_USRSPACE -
|
||||
roundup(sizeof(canary), sizeof(char *)) -
|
||||
roundup(execpath_len, sizeof(char *)) -
|
||||
roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
|
||||
@ -355,19 +351,14 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
copyout(imgp->execpath, (void *)imgp->execpathp, execpath_len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare the canary for SSP.
|
||||
*/
|
||||
/* Prepare the canary for SSP. */
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
imgp->canary = (uintptr_t)arginfo -
|
||||
roundup(execpath_len, sizeof(char *)) -
|
||||
roundup(sizeof(canary), sizeof(char *));
|
||||
copyout(canary, (void *)imgp->canary, sizeof(canary));
|
||||
|
||||
/*
|
||||
* If we have a valid auxargs ptr, prepare some room
|
||||
* on the stack.
|
||||
*/
|
||||
/* If we have a valid auxargs ptr, prepare some room on the stack. */
|
||||
if (imgp->auxargs) {
|
||||
/*
|
||||
* 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
|
||||
@ -393,29 +384,21 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
imgp->args->envc + 2) * sizeof(char *));
|
||||
}
|
||||
|
||||
/*
|
||||
* vectp also becomes our initial stack base
|
||||
*/
|
||||
/* vectp also becomes our initial stack base. */
|
||||
stack_base = (register_t *)vectp;
|
||||
|
||||
stringp = imgp->args->begin_argv;
|
||||
argc = imgp->args->argc;
|
||||
envc = imgp->args->envc;
|
||||
|
||||
/*
|
||||
* Copy out strings - arguments and environment.
|
||||
*/
|
||||
/* Copy out strings - arguments and environment. */
|
||||
copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
|
||||
|
||||
/*
|
||||
* Fill in "ps_strings" struct for ps, w, etc.
|
||||
*/
|
||||
/* Fill in "ps_strings" struct for ps, w, etc. */
|
||||
suword(&arginfo->ps_argvstr, (long)(intptr_t)vectp);
|
||||
suword(&arginfo->ps_nargvstr, argc);
|
||||
|
||||
/*
|
||||
* Fill in argument portion of vector table.
|
||||
*/
|
||||
/* Fill in argument portion of vector table. */
|
||||
for (; argc > 0; --argc) {
|
||||
suword(vectp++, (long)(intptr_t)destp);
|
||||
while (*stringp++ != 0)
|
||||
@ -423,15 +406,13 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
destp++;
|
||||
}
|
||||
|
||||
/* a null vector table pointer separates the argp's from the envp's */
|
||||
/* A null vector table pointer separates the argp's from the envp's. */
|
||||
suword(vectp++, 0);
|
||||
|
||||
suword(&arginfo->ps_envstr, (long)(intptr_t)vectp);
|
||||
suword(&arginfo->ps_nenvstr, envc);
|
||||
|
||||
/*
|
||||
* Fill in environment portion of vector table.
|
||||
*/
|
||||
/* Fill in environment portion of vector table. */
|
||||
for (; envc > 0; --envc) {
|
||||
suword(vectp++, (long)(intptr_t)destp);
|
||||
while (*stringp++ != 0)
|
||||
@ -439,7 +420,7 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
destp++;
|
||||
}
|
||||
|
||||
/* end of vector table is a null pointer */
|
||||
/* The end of the vector table is a null pointer. */
|
||||
suword(vectp, 0);
|
||||
return (stack_base);
|
||||
}
|
||||
@ -681,12 +662,10 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
regs->tf_rdx = (register_t)&sfp->sf_sc; /* arg 3 in %rdx */
|
||||
|
||||
sf.sf_handler = catcher;
|
||||
/* Fill in POSIX parts */
|
||||
/* Fill in POSIX parts. */
|
||||
ksiginfo_to_lsiginfo(ksi, &sf.sf_si, sig);
|
||||
|
||||
/*
|
||||
* Copy the sigframe out to the user's stack.
|
||||
*/
|
||||
/* Copy the sigframe out to the user's stack. */
|
||||
if (copyout(&sf, sfp, sizeof(*sfp)) != 0) {
|
||||
#ifdef DEBUG
|
||||
printf("process %ld has trashed its stack\n", (long)p->p_pid);
|
||||
@ -762,7 +741,7 @@ linux_vsyscall(struct thread *td)
|
||||
|
||||
frame = td->td_frame;
|
||||
|
||||
/* Check %rip for vsyscall area */
|
||||
/* Check %rip for vsyscall area. */
|
||||
if (__predict_true(frame->tf_rip < LINUX_VSYSCALL_START))
|
||||
return (EINVAL);
|
||||
if ((frame->tf_rip & (LINUX_VSYSCALL_SZ - 1)) != 0)
|
||||
@ -773,7 +752,7 @@ linux_vsyscall(struct thread *td)
|
||||
|
||||
/*
|
||||
* vsyscall called as callq *(%rax), so we must
|
||||
* use return address from %rsp and also fixup %rsp
|
||||
* use return address from %rsp and also fixup %rsp.
|
||||
*/
|
||||
error = copyin((void *)frame->tf_rsp, &retqaddr, sizeof(retqaddr));
|
||||
if (error)
|
||||
|
@ -102,10 +102,9 @@ MODULE_VERSION(linux, 1);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allow the sendsig functions to use the ldebug() facility
|
||||
* even though they are not syscalls themselves. Map them
|
||||
* to syscall 0. This is slightly less bogus than using
|
||||
* ldebug(sigreturn).
|
||||
* Allow the sendsig functions to use the ldebug() facility even though they
|
||||
* are not syscalls themselves. Map them to syscall 0. This is slightly less
|
||||
* bogus than using ldebug(sigreturn).
|
||||
*/
|
||||
#define LINUX32_SYS_linux_rt_sendsig 0
|
||||
#define LINUX32_SYS_linux_sendsig 0
|
||||
@ -312,9 +311,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
printf(ARGS(rt_sendsig, "%p, %d, %p, %u"),
|
||||
catcher, sig, (void*)mask, code);
|
||||
#endif
|
||||
/*
|
||||
* Allocate space for the signal handler context.
|
||||
*/
|
||||
/* Allocate space for the signal handler context. */
|
||||
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
|
||||
SIGISMEMBER(psp->ps_sigonstack, sig)) {
|
||||
fp = (struct l_rt_sigframe *)((uintptr_t)td->td_sigstk.ss_sp +
|
||||
@ -323,9 +320,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
fp = (struct l_rt_sigframe *)regs->tf_rsp - 1;
|
||||
mtx_unlock(&psp->ps_mtx);
|
||||
|
||||
/*
|
||||
* Build the argument list for the signal handler.
|
||||
*/
|
||||
/* Build the argument list for the signal handler. */
|
||||
sig = bsd_to_linux_signal(sig);
|
||||
|
||||
bzero(&frame, sizeof(frame));
|
||||
@ -335,12 +330,11 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
frame.sf_siginfo = PTROUT(&fp->sf_si);
|
||||
frame.sf_ucontext = PTROUT(&fp->sf_sc);
|
||||
|
||||
/* Fill in POSIX parts */
|
||||
/* Fill in POSIX parts. */
|
||||
ksiginfo_to_lsiginfo(ksi, &frame.sf_si, sig);
|
||||
|
||||
/*
|
||||
* Build the signal context to be used by sigreturn
|
||||
* and libgcc unwind.
|
||||
* Build the signal context to be used by sigreturn and libgcc unwind.
|
||||
*/
|
||||
frame.sf_sc.uc_flags = 0; /* XXX ??? */
|
||||
frame.sf_sc.uc_link = 0; /* XXX ??? */
|
||||
@ -396,9 +390,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
sigexit(td, SIGILL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Build context to run handler in.
|
||||
*/
|
||||
/* Build context to run handler in. */
|
||||
regs->tf_rsp = PTROUT(fp);
|
||||
regs->tf_rip = linux32_rt_sigcode;
|
||||
regs->tf_rflags &= ~(PSL_T | PSL_D);
|
||||
@ -457,9 +449,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
catcher, sig, (void*)mask, code);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate space for the signal handler context.
|
||||
*/
|
||||
/* Allocate space for the signal handler context. */
|
||||
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
|
||||
SIGISMEMBER(psp->ps_sigonstack, sig)) {
|
||||
fp = (struct l_sigframe *)((uintptr_t)td->td_sigstk.ss_sp +
|
||||
@ -469,9 +459,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
mtx_unlock(&psp->ps_mtx);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
/*
|
||||
* Build the argument list for the signal handler.
|
||||
*/
|
||||
/* Build the argument list for the signal handler. */
|
||||
sig = bsd_to_linux_signal(sig);
|
||||
|
||||
bzero(&frame, sizeof(frame));
|
||||
@ -481,9 +469,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
|
||||
bsd_to_linux_sigset(mask, &lmask);
|
||||
|
||||
/*
|
||||
* Build the signal context to be used by sigreturn.
|
||||
*/
|
||||
/* Build the signal context to be used by sigreturn. */
|
||||
frame.sf_sc.sc_mask = lmask.__mask;
|
||||
frame.sf_sc.sc_gs = regs->tf_gs;
|
||||
frame.sf_sc.sc_fs = regs->tf_fs;
|
||||
@ -517,9 +503,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
sigexit(td, SIGILL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Build context to run handler in.
|
||||
*/
|
||||
/* Build context to run handler in. */
|
||||
regs->tf_rsp = PTROUT(fp);
|
||||
regs->tf_rip = linux32_sigcode;
|
||||
regs->tf_rflags &= ~(PSL_T | PSL_D);
|
||||
@ -569,9 +553,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
|
||||
if (copyin(args->sfp, &frame, sizeof(frame)) != 0)
|
||||
return (EFAULT);
|
||||
|
||||
/*
|
||||
* Check for security violations.
|
||||
*/
|
||||
/* Check for security violations. */
|
||||
#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
|
||||
eflags = frame.sf_sc.sc_eflags;
|
||||
if (!EFLAGS_SECURE(eflags, regs->tf_rflags))
|
||||
@ -598,9 +580,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
|
||||
linux_to_bsd_sigset(&lmask, &bmask);
|
||||
kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0);
|
||||
|
||||
/*
|
||||
* Restore signal context.
|
||||
*/
|
||||
/* Restore signal context. */
|
||||
regs->tf_rdi = frame.sf_sc.sc_edi;
|
||||
regs->tf_rsi = frame.sf_sc.sc_esi;
|
||||
regs->tf_rbp = frame.sf_sc.sc_ebp;
|
||||
@ -660,9 +640,7 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
|
||||
|
||||
context = &uc.uc_mcontext;
|
||||
|
||||
/*
|
||||
* Check for security violations.
|
||||
*/
|
||||
/* Check for security violations. */
|
||||
#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
|
||||
eflags = context->sc_eflags;
|
||||
if (!EFLAGS_SECURE(eflags, regs->tf_rflags))
|
||||
@ -850,9 +828,7 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
char canary[LINUX_AT_RANDOM_LEN];
|
||||
size_t execpath_len;
|
||||
|
||||
/*
|
||||
* Calculate string base and vector table pointers.
|
||||
*/
|
||||
/* Calculate string base and vector table pointers. */
|
||||
if (imgp->execpath != NULL && imgp->auxargs != NULL)
|
||||
execpath_len = strlen(imgp->execpath) + 1;
|
||||
else
|
||||
@ -869,19 +845,14 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
copyout(imgp->execpath, (void *)imgp->execpathp, execpath_len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare the canary for SSP.
|
||||
*/
|
||||
/* Prepare the canary for SSP. */
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
imgp->canary = (uintptr_t)arginfo -
|
||||
roundup(execpath_len, sizeof(char *)) -
|
||||
roundup(sizeof(canary), sizeof(char *));
|
||||
copyout(canary, (void *)imgp->canary, sizeof(canary));
|
||||
|
||||
/*
|
||||
* If we have a valid auxargs ptr, prepare some room
|
||||
* on the stack.
|
||||
*/
|
||||
/* If we have a valid auxargs ptr, prepare some room on the stack. */
|
||||
if (imgp->auxargs) {
|
||||
/*
|
||||
* 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
|
||||
@ -906,28 +877,20 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
vectp = (u_int32_t *)(destp - (imgp->args->argc +
|
||||
imgp->args->envc + 2) * sizeof(u_int32_t));
|
||||
|
||||
/*
|
||||
* vectp also becomes our initial stack base
|
||||
*/
|
||||
/* vectp also becomes our initial stack base. */
|
||||
stack_base = vectp;
|
||||
|
||||
stringp = imgp->args->begin_argv;
|
||||
argc = imgp->args->argc;
|
||||
envc = imgp->args->envc;
|
||||
/*
|
||||
* Copy out strings - arguments and environment.
|
||||
*/
|
||||
/* Copy out strings - arguments and environment. */
|
||||
copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
|
||||
|
||||
/*
|
||||
* Fill in "ps_strings" struct for ps, w, etc.
|
||||
*/
|
||||
/* Fill in "ps_strings" struct for ps, w, etc. */
|
||||
suword32(&arginfo->ps_argvstr, (uint32_t)(intptr_t)vectp);
|
||||
suword32(&arginfo->ps_nargvstr, argc);
|
||||
|
||||
/*
|
||||
* Fill in argument portion of vector table.
|
||||
*/
|
||||
/* Fill in argument portion of vector table. */
|
||||
for (; argc > 0; --argc) {
|
||||
suword32(vectp++, (uint32_t)(intptr_t)destp);
|
||||
while (*stringp++ != 0)
|
||||
@ -935,15 +898,13 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
destp++;
|
||||
}
|
||||
|
||||
/* a null vector table pointer separates the argp's from the envp's */
|
||||
/* A null vector table pointer separates the argp's from the envp's. */
|
||||
suword32(vectp++, 0);
|
||||
|
||||
suword32(&arginfo->ps_envstr, (uint32_t)(intptr_t)vectp);
|
||||
suword32(&arginfo->ps_nenvstr, envc);
|
||||
|
||||
/*
|
||||
* Fill in environment portion of vector table.
|
||||
*/
|
||||
/* Fill in environment portion of vector table. */
|
||||
for (; envc > 0; --envc) {
|
||||
suword32(vectp++, (uint32_t)(intptr_t)destp);
|
||||
while (*stringp++ != 0)
|
||||
@ -951,7 +912,7 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
destp++;
|
||||
}
|
||||
|
||||
/* end of vector table is a null pointer */
|
||||
/* The end of the vector table is a null pointer. */
|
||||
suword32(vectp, 0);
|
||||
|
||||
return ((register_t *)stack_base);
|
||||
|
@ -88,10 +88,9 @@ SYSCTL_PROC(_compat_linux, OID_AUTO, debug, CTLTYPE_STRING | CTLFLAG_RW, 0, 0,
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allow the sendsig functions to use the ldebug() facility
|
||||
* even though they are not syscalls themselves. Map them
|
||||
* to syscall 0. This is slightly less bogus than using
|
||||
* ldebug(sigreturn).
|
||||
* Allow the sendsig functions to use the ldebug() facility even though they
|
||||
* are not syscalls themselves. Map them to syscall 0. This is slightly less
|
||||
* bogus than using ldebug(sigreturn).
|
||||
*/
|
||||
#define LINUX_SYS_linux_rt_sendsig 0
|
||||
#define LINUX_SYS_linux_sendsig 0
|
||||
@ -306,9 +305,7 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
size_t execpath_len;
|
||||
struct proc *p;
|
||||
|
||||
/*
|
||||
* Calculate string base and vector table pointers.
|
||||
*/
|
||||
/* Calculate string base and vector table pointers. */
|
||||
p = imgp->proc;
|
||||
if (imgp->execpath != NULL && imgp->auxargs != NULL)
|
||||
execpath_len = strlen(imgp->execpath) + 1;
|
||||
@ -320,9 +317,7 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
roundup(execpath_len, sizeof(char *)) -
|
||||
roundup(ARG_MAX - imgp->args->stringspace, sizeof(char *));
|
||||
|
||||
/*
|
||||
* install LINUX_PLATFORM
|
||||
*/
|
||||
/* Install LINUX_PLATFORM. */
|
||||
copyout(linux_kplatform, ((caddr_t)arginfo - linux_szplatform),
|
||||
linux_szplatform);
|
||||
|
||||
@ -332,19 +327,14 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
copyout(imgp->execpath, (void *)imgp->execpathp, execpath_len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare the canary for SSP.
|
||||
*/
|
||||
/* Prepare the canary for SSP. */
|
||||
arc4rand(canary, sizeof(canary), 0);
|
||||
imgp->canary = (uintptr_t)arginfo - linux_szplatform -
|
||||
roundup(execpath_len, sizeof(char *)) -
|
||||
roundup(sizeof(canary), sizeof(char *));
|
||||
copyout(canary, (void *)imgp->canary, sizeof(canary));
|
||||
|
||||
/*
|
||||
* If we have a valid auxargs ptr, prepare some room
|
||||
* on the stack.
|
||||
*/
|
||||
/* If we have a valid auxargs ptr, prepare some room on the stack. */
|
||||
if (imgp->auxargs) {
|
||||
/*
|
||||
* 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
|
||||
@ -368,29 +358,21 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
sizeof(char *));
|
||||
}
|
||||
|
||||
/*
|
||||
* vectp also becomes our initial stack base
|
||||
*/
|
||||
/* vectp also becomes our initial stack base. */
|
||||
stack_base = (register_t *)vectp;
|
||||
|
||||
stringp = imgp->args->begin_argv;
|
||||
argc = imgp->args->argc;
|
||||
envc = imgp->args->envc;
|
||||
|
||||
/*
|
||||
* Copy out strings - arguments and environment.
|
||||
*/
|
||||
/* Copy out strings - arguments and environment. */
|
||||
copyout(stringp, destp, ARG_MAX - imgp->args->stringspace);
|
||||
|
||||
/*
|
||||
* Fill in "ps_strings" struct for ps, w, etc.
|
||||
*/
|
||||
/* Fill in "ps_strings" struct for ps, w, etc. */
|
||||
suword(&arginfo->ps_argvstr, (long)(intptr_t)vectp);
|
||||
suword(&arginfo->ps_nargvstr, argc);
|
||||
|
||||
/*
|
||||
* Fill in argument portion of vector table.
|
||||
*/
|
||||
/* Fill in argument portion of vector table. */
|
||||
for (; argc > 0; --argc) {
|
||||
suword(vectp++, (long)(intptr_t)destp);
|
||||
while (*stringp++ != 0)
|
||||
@ -398,15 +380,13 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
destp++;
|
||||
}
|
||||
|
||||
/* a null vector table pointer separates the argp's from the envp's */
|
||||
/* A null vector table pointer separates the argp's from the envp's. */
|
||||
suword(vectp++, 0);
|
||||
|
||||
suword(&arginfo->ps_envstr, (long)(intptr_t)vectp);
|
||||
suword(&arginfo->ps_nenvstr, envc);
|
||||
|
||||
/*
|
||||
* Fill in environment portion of vector table.
|
||||
*/
|
||||
/* Fill in environment portion of vector table. */
|
||||
for (; envc > 0; --envc) {
|
||||
suword(vectp++, (long)(intptr_t)destp);
|
||||
while (*stringp++ != 0)
|
||||
@ -414,7 +394,7 @@ linux_copyout_strings(struct image_params *imgp)
|
||||
destp++;
|
||||
}
|
||||
|
||||
/* end of vector table is a null pointer */
|
||||
/* The end of the vector table is a null pointer. */
|
||||
suword(vectp, 0);
|
||||
|
||||
return (stack_base);
|
||||
@ -444,9 +424,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
printf(ARGS(rt_sendsig, "%p, %d, %p, %u"),
|
||||
catcher, sig, (void*)mask, code);
|
||||
#endif
|
||||
/*
|
||||
* Allocate space for the signal handler context.
|
||||
*/
|
||||
/* Allocate space for the signal handler context. */
|
||||
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
|
||||
SIGISMEMBER(psp->ps_sigonstack, sig)) {
|
||||
fp = (struct l_rt_sigframe *)((uintptr_t)td->td_sigstk.ss_sp +
|
||||
@ -455,9 +433,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
fp = (struct l_rt_sigframe *)regs->tf_esp - 1;
|
||||
mtx_unlock(&psp->ps_mtx);
|
||||
|
||||
/*
|
||||
* Build the argument list for the signal handler.
|
||||
*/
|
||||
/* Build the argument list for the signal handler. */
|
||||
sig = bsd_to_linux_signal(sig);
|
||||
|
||||
bzero(&frame, sizeof(frame));
|
||||
@ -467,12 +443,10 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
frame.sf_siginfo = &fp->sf_si;
|
||||
frame.sf_ucontext = &fp->sf_sc;
|
||||
|
||||
/* Fill in POSIX parts */
|
||||
/* Fill in POSIX parts. */
|
||||
ksiginfo_to_lsiginfo(ksi, &frame.sf_si, sig);
|
||||
|
||||
/*
|
||||
* Build the signal context to be used by sigreturn.
|
||||
*/
|
||||
/* Build the signal context to be used by sigreturn. */
|
||||
frame.sf_sc.uc_flags = 0; /* XXX ??? */
|
||||
frame.sf_sc.uc_link = NULL; /* XXX ??? */
|
||||
|
||||
@ -527,9 +501,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
sigexit(td, SIGILL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Build context to run handler in.
|
||||
*/
|
||||
/* Build context to run handler in. */
|
||||
regs->tf_esp = (int)fp;
|
||||
regs->tf_eip = linux_rt_sigcode;
|
||||
regs->tf_eflags &= ~(PSL_T | PSL_VM | PSL_D);
|
||||
@ -584,9 +556,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
catcher, sig, (void*)mask, code);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate space for the signal handler context.
|
||||
*/
|
||||
/* Allocate space for the signal handler context. */
|
||||
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
|
||||
SIGISMEMBER(psp->ps_sigonstack, sig)) {
|
||||
fp = (struct l_sigframe *)((uintptr_t)td->td_sigstk.ss_sp +
|
||||
@ -596,9 +566,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
mtx_unlock(&psp->ps_mtx);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
/*
|
||||
* Build the argument list for the signal handler.
|
||||
*/
|
||||
/* Build the argument list for the signal handler. */
|
||||
sig = bsd_to_linux_signal(sig);
|
||||
|
||||
bzero(&frame, sizeof(frame));
|
||||
@ -608,9 +576,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
|
||||
bsd_to_linux_sigset(mask, &lmask);
|
||||
|
||||
/*
|
||||
* Build the signal context to be used by sigreturn.
|
||||
*/
|
||||
/* Build the signal context to be used by sigreturn. */
|
||||
frame.sf_sc.sc_mask = lmask.__mask;
|
||||
frame.sf_sc.sc_gs = rgs();
|
||||
frame.sf_sc.sc_fs = regs->tf_fs;
|
||||
@ -644,9 +610,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
|
||||
sigexit(td, SIGILL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Build context to run handler in.
|
||||
*/
|
||||
/* Build context to run handler in. */
|
||||
regs->tf_esp = (int)fp;
|
||||
regs->tf_eip = linux_sigcode;
|
||||
regs->tf_eflags &= ~(PSL_T | PSL_VM | PSL_D);
|
||||
@ -693,9 +657,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
|
||||
if (copyin(args->sfp, &frame, sizeof(frame)) != 0)
|
||||
return (EFAULT);
|
||||
|
||||
/*
|
||||
* Check for security violations.
|
||||
*/
|
||||
/* Check for security violations. */
|
||||
#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
|
||||
eflags = frame.sf_sc.sc_eflags;
|
||||
if (!EFLAGS_SECURE(eflags, regs->tf_eflags))
|
||||
@ -721,9 +683,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
|
||||
linux_to_bsd_sigset(&lmask, &bmask);
|
||||
kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0);
|
||||
|
||||
/*
|
||||
* Restore signal context.
|
||||
*/
|
||||
/* Restore signal context. */
|
||||
/* %gs was restored by the trampoline. */
|
||||
regs->tf_fs = frame.sf_sc.sc_fs;
|
||||
regs->tf_es = frame.sf_sc.sc_es;
|
||||
@ -782,9 +742,7 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
|
||||
|
||||
context = &uc.uc_mcontext;
|
||||
|
||||
/*
|
||||
* Check for security violations.
|
||||
*/
|
||||
/* Check for security violations. */
|
||||
#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0)
|
||||
eflags = context->sc_eflags;
|
||||
if (!EFLAGS_SECURE(eflags, regs->tf_eflags))
|
||||
@ -809,9 +767,7 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
|
||||
linux_to_bsd_sigset(&uc.uc_sigmask, &bmask);
|
||||
kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0);
|
||||
|
||||
/*
|
||||
* Restore signal context
|
||||
*/
|
||||
/* Restore signal context. */
|
||||
/* %gs was restored by the trampoline. */
|
||||
regs->tf_fs = context->sc_fs;
|
||||
regs->tf_es = context->sc_es;
|
||||
@ -829,9 +785,7 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_sigreturn_args *args)
|
||||
regs->tf_esp = context->sc_esp_at_signal;
|
||||
regs->tf_ss = context->sc_ss;
|
||||
|
||||
/*
|
||||
* call sigaltstack & ignore results..
|
||||
*/
|
||||
/* Call sigaltstack & ignore results. */
|
||||
lss = &uc.uc_stack;
|
||||
ss.ss_sp = lss->ss_sp;
|
||||
ss.ss_size = lss->ss_size;
|
||||
@ -928,7 +882,7 @@ exec_linux_setregs(struct thread *td, struct image_params *imgp, u_long stack)
|
||||
|
||||
exec_setregs(td, imgp, stack);
|
||||
|
||||
/* Linux sets %gs to 0, we default to _udatasel */
|
||||
/* Linux sets %gs to 0, we default to _udatasel. */
|
||||
pcb->pcb_gs = 0;
|
||||
load_gs(0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user