mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-05 09:14:03 +00:00
Proc locking.
This commit is contained in:
parent
cfb4c0b4f9
commit
611d940790
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=71497
@ -104,6 +104,7 @@ exec_linux_imgact(imgp)
|
||||
/*
|
||||
* text/data/bss must not exceed limits
|
||||
*/
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
if (a_out->a_text > MAXTSIZ ||
|
||||
a_out->a_data + bss_size > imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur)
|
||||
return (ENOMEM);
|
||||
|
@ -182,10 +182,12 @@ elf_linux_fixup(register_t **stack_base, struct image_params *imgp)
|
||||
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
|
||||
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
|
||||
AUXARGS_ENTRY(pos, AT_BASE, args->base);
|
||||
PROC_LOCK(imgp->proc);
|
||||
AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_cred->p_ruid);
|
||||
AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_cred->p_svuid);
|
||||
AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_cred->p_rgid);
|
||||
AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_cred->p_svgid);
|
||||
PROC_UNLOCK(imgp->proc);
|
||||
AUXARGS_ENTRY(pos, AT_NULL, 0);
|
||||
|
||||
free(imgp->auxargs, M_TEMP);
|
||||
@ -217,12 +219,14 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
/*
|
||||
* Allocate space for the signal handler context.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
if ((p->p_flag & P_ALTSTACK) && !oonstack &&
|
||||
SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
|
||||
fp = (struct linux_rt_sigframe *)(p->p_sigstk.ss_sp +
|
||||
p->p_sigstk.ss_size - sizeof(struct linux_rt_sigframe));
|
||||
} else
|
||||
fp = (struct linux_rt_sigframe *)regs->tf_esp - 1;
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
/*
|
||||
* grow() will return FALSE if the fp will not fit inside the stack
|
||||
@ -236,10 +240,12 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
* Process has trashed its stack; give it an illegal
|
||||
* instruction to halt it in its tracks.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
SIGACTION(p, SIGILL) = SIG_DFL;
|
||||
SIGDELSET(p->p_sigignore, SIGILL);
|
||||
SIGDELSET(p->p_sigcatch, SIGILL);
|
||||
SIGDELSET(p->p_sigmask, SIGILL);
|
||||
PROC_UNLOCK(p);
|
||||
#ifdef DEBUG
|
||||
printf("Linux-emul(%ld): linux_rt_sendsig -- bad stack %p, "
|
||||
"oonstack=%x\n", (long)p->p_pid, fp, oonstack);
|
||||
@ -271,10 +277,12 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
frame.sf_sc.uc_flags = 0; /* XXX ??? */
|
||||
frame.sf_sc.uc_link = NULL; /* XXX ??? */
|
||||
|
||||
PROC_LOCK(p);
|
||||
frame.sf_sc.uc_stack.ss_sp = p->p_sigstk.ss_sp;
|
||||
frame.sf_sc.uc_stack.ss_size = p->p_sigstk.ss_size;
|
||||
frame.sf_sc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK)
|
||||
? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
|
||||
|
||||
@ -367,12 +375,14 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
/*
|
||||
* Allocate space for the signal handler context.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
if ((p->p_flag & P_ALTSTACK) && !oonstack &&
|
||||
SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
|
||||
fp = (struct linux_sigframe *)(p->p_sigstk.ss_sp +
|
||||
p->p_sigstk.ss_size - sizeof(struct linux_sigframe));
|
||||
} else
|
||||
fp = (struct linux_sigframe *)regs->tf_esp - 1;
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
/*
|
||||
* grow() will return FALSE if the fp will not fit inside the stack
|
||||
@ -386,10 +396,12 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
||||
* Process has trashed its stack; give it an illegal
|
||||
* instruction to halt it in its tracks.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
SIGACTION(p, SIGILL) = SIG_DFL;
|
||||
SIGDELSET(p->p_sigignore, SIGILL);
|
||||
SIGDELSET(p->p_sigcatch, SIGILL);
|
||||
SIGDELSET(p->p_sigmask, SIGILL);
|
||||
PROC_UNLOCK(p);
|
||||
psignal(p, SIGILL);
|
||||
return;
|
||||
}
|
||||
@ -524,8 +536,10 @@ linux_sigreturn(p, args)
|
||||
lmask.__bits[0] = frame.sf_sc.sc_mask;
|
||||
for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
|
||||
lmask.__bits[i+1] = frame.sf_extramask[i];
|
||||
PROC_LOCK(p);
|
||||
linux_to_bsd_sigset(&lmask, &p->p_sigmask);
|
||||
SIG_CANTMASK(p->p_sigmask);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
/*
|
||||
* Restore signal context.
|
||||
@ -620,8 +634,10 @@ linux_rt_sigreturn(p, args)
|
||||
return(EINVAL);
|
||||
}
|
||||
|
||||
PROC_LOCK(p);
|
||||
linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask);
|
||||
SIG_CANTMASK(p->p_sigmask);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
/*
|
||||
* Restore signal context
|
||||
|
@ -155,6 +155,7 @@ exec_aout_imgact(imgp)
|
||||
/*
|
||||
* text/data/bss must not exceed limits
|
||||
*/
|
||||
mtx_assert(&Giant, MA_OWNED);
|
||||
if (/* text can't exceed maximum text size */
|
||||
a_out->a_text > MAXTSIZ ||
|
||||
|
||||
@ -248,13 +249,17 @@ aout_coredump(p, vp, limit)
|
||||
register struct vnode *vp;
|
||||
off_t limit;
|
||||
{
|
||||
register struct ucred *cred = p->p_ucred;
|
||||
register struct ucred *cred;
|
||||
register struct vmspace *vm = p->p_vmspace;
|
||||
int error;
|
||||
|
||||
if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >= limit)
|
||||
return (EFAULT);
|
||||
fill_kinfo_proc(p, &p->p_addr->u_kproc);
|
||||
PROC_LOCK(p);
|
||||
cred = p->p_ucred;
|
||||
crhold(cred);
|
||||
PROC_UNLOCK(p);
|
||||
error = cpu_coredump(p, vp, cred);
|
||||
if (error == 0)
|
||||
error = vn_rdwr(UIO_WRITE, vp, vm->vm_daddr,
|
||||
@ -266,6 +271,7 @@ aout_coredump(p, vp, limit)
|
||||
round_page(ctob(vm->vm_ssize)),
|
||||
(off_t)ctob(UPAGES) + ctob(vm->vm_dsize), UIO_USERSPACE,
|
||||
IO_NODELOCKED|IO_UNIT, cred, (int *) NULL, p);
|
||||
crfree(cred);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ elf_coredump(p, vp, limit)
|
||||
register struct vnode *vp;
|
||||
off_t limit;
|
||||
{
|
||||
register struct ucred *cred = p->p_ucred;
|
||||
register struct ucred *cred;
|
||||
int error = 0;
|
||||
struct sseg_closure seginfo;
|
||||
void *hdr;
|
||||
@ -754,6 +754,10 @@ elf_coredump(p, vp, limit)
|
||||
if (hdr == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
PROC_LOCK(p);
|
||||
cred = p->p_ucred;
|
||||
crhold(cred);
|
||||
PROC_UNLOCK(p);
|
||||
error = elf_corehdr(p, vp, cred, seginfo.count, hdr, hdrsize);
|
||||
|
||||
/* Write the contents of all of the writable segments. */
|
||||
@ -774,6 +778,7 @@ elf_coredump(p, vp, limit)
|
||||
php++;
|
||||
}
|
||||
}
|
||||
crfree(cred);
|
||||
free(hdr, M_TEMP);
|
||||
|
||||
return error;
|
||||
|
@ -206,6 +206,7 @@ do_aout_hdr(struct imgact_gzip * gz)
|
||||
/*
|
||||
* text/data/bss must not exceed limits
|
||||
*/
|
||||
mtx_assert(&Giant, MA_OWNWED);
|
||||
if ( /* text can't exceed maximum text size */
|
||||
gz->a_out.a_text > MAXTSIZ ||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user