summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2001-01-24 00:27:28 +0000
committerjhb <jhb@FreeBSD.org>2001-01-24 00:27:28 +0000
commita294d4e362c79943729544b2c37f98be3a6f0dac (patch)
tree8794f893081a4e5c2206a94c71a5af5f035f04b7
parentf540aca98452ae3328bb85b3019b403196f8d16d (diff)
downloadFreeBSD-src-a294d4e362c79943729544b2c37f98be3a6f0dac.zip
FreeBSD-src-a294d4e362c79943729544b2c37f98be3a6f0dac.tar.gz
Proc locking.
-rw-r--r--sys/i386/linux/imgact_linux.c1
-rw-r--r--sys/i386/linux/linux_sysvec.c16
-rw-r--r--sys/kern/imgact_aout.c8
-rw-r--r--sys/kern/imgact_elf.c7
-rw-r--r--sys/kern/imgact_gzip.c1
5 files changed, 31 insertions, 2 deletions
diff --git a/sys/i386/linux/imgact_linux.c b/sys/i386/linux/imgact_linux.c
index c560d74..48e14f0 100644
--- a/sys/i386/linux/imgact_linux.c
+++ b/sys/i386/linux/imgact_linux.c
@@ -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);
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index f69f53f..5ba0b68 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -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
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c
index 6e0edde..ff315f5 100644
--- a/sys/kern/imgact_aout.c
+++ b/sys/kern/imgact_aout.c
@@ -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);
}
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 96db3b3..c3d8cf7 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -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;
diff --git a/sys/kern/imgact_gzip.c b/sys/kern/imgact_gzip.c
index a3a6a68..676d37f 100644
--- a/sys/kern/imgact_gzip.c
+++ b/sys/kern/imgact_gzip.c
@@ -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 ||
OpenPOWER on IntegriCloud