mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Proc locking.
This commit is contained in:
parent
ee7a93c9ab
commit
60bb997eb3
4 changed files with 36 additions and 6 deletions
|
|
@ -159,10 +159,12 @@ linux_clone(struct proc *p, struct linux_clone_args *args)
|
|||
return (error);
|
||||
|
||||
p2 = pfind(p->p_retval[0]);
|
||||
if (p2 == 0)
|
||||
if (p2 == NULL)
|
||||
return (ESRCH);
|
||||
|
||||
PROC_LOCK(p);
|
||||
p2->p_sigparent = exit_signal;
|
||||
PROC_UNLOCK(p);
|
||||
p2->p_addr->u_pcb.pcb_hw.apcb_usp = (unsigned long)args->stack;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
|||
|
|
@ -100,10 +100,12 @@ elf_linux_fixup(long **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);
|
||||
|
|
|
|||
|
|
@ -648,6 +648,7 @@ osf1_lstat(p, uap)
|
|||
int error;
|
||||
struct nameidata nd;
|
||||
caddr_t sg = stackgap_init();
|
||||
|
||||
CHECKALTEXIST(p, &sg, uap->path);
|
||||
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE,
|
||||
|
|
@ -1065,26 +1066,35 @@ osf1_setuid(p, uap)
|
|||
register struct pcred *pc;
|
||||
|
||||
uid = SCARG(uap, uid);
|
||||
PROC_LOCK(p);
|
||||
pc = p->p_cred;
|
||||
|
||||
if ((error = suser(p)) != 0 &&
|
||||
uid != pc->p_ruid && uid != pc->p_svuid)
|
||||
uid != pc->p_ruid && uid != pc->p_svuid) {
|
||||
PROC_UNLOCK(p);
|
||||
return (error);
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
if (uid != pc->p_ruid) {
|
||||
PROC_UNLOCK(p);
|
||||
change_ruid(p, uid);
|
||||
setsugid(p);
|
||||
PROC_LOCK(p);
|
||||
}
|
||||
if (pc->p_svuid != uid) {
|
||||
PROC_UNLOCK(p);
|
||||
pc->p_svuid = uid;
|
||||
setsugid(p);
|
||||
PROC_LOCK(p);
|
||||
}
|
||||
}
|
||||
if (pc->pc_ucred->cr_uid != uid) {
|
||||
PROC_UNLOCK(p);
|
||||
change_euid(p, uid);
|
||||
setsugid(p);
|
||||
}
|
||||
} else
|
||||
PROC_UNLOCK(p);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
@ -1106,11 +1116,14 @@ osf1_setgid(p, uap)
|
|||
register struct pcred *pc;
|
||||
|
||||
gid = SCARG(uap, gid);
|
||||
PROC_LOCK(p);
|
||||
pc = p->p_cred;
|
||||
|
||||
if (((error = suser(p)) != 0 ) &&
|
||||
gid != pc->p_rgid && gid != pc->p_svgid)
|
||||
gid != pc->p_rgid && gid != pc->p_svgid) {
|
||||
PROC_UNLOCK(p);
|
||||
return (error);
|
||||
}
|
||||
|
||||
pc->pc_ucred = crcopy(pc->pc_ucred);
|
||||
pc->pc_ucred->cr_gid = gid;
|
||||
|
|
@ -1118,6 +1131,7 @@ osf1_setgid(p, uap)
|
|||
pc->p_rgid = gid;
|
||||
pc->p_svgid = gid;
|
||||
}
|
||||
PROC_UNLOCK(p);
|
||||
setsugid(p);
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -1340,7 +1354,9 @@ osf1_getrusage(p, uap)
|
|||
switch (uap->who) {
|
||||
case RUSAGE_SELF:
|
||||
rup = &p->p_stats->p_ru;
|
||||
mtx_enter(&sched_lock, MTX_SPIN);
|
||||
calcru(p, &rup->ru_utime, &rup->ru_stime, NULL);
|
||||
mtx_exit(&sched_lock, MTX_SPIN);
|
||||
break;
|
||||
|
||||
case RUSAGE_CHILDREN:
|
||||
|
|
|
|||
|
|
@ -444,7 +444,9 @@ osf1_signal(p, uap)
|
|||
sigset_t *bmask;
|
||||
|
||||
bmask = stackgap_alloc(&sg, sizeof(sigset_t));
|
||||
PROC_LOCK(p);
|
||||
set = p->p_sigmask;
|
||||
PROC_UNLOCK(p);
|
||||
SIGDELSET(set, signum);
|
||||
SCARG(&sa, sigmask) = bmask;
|
||||
if ((error = copyout(&set, bmask, sizeof(set))) != 0)
|
||||
|
|
@ -476,7 +478,7 @@ osf1_sigprocmask(p, uap)
|
|||
|
||||
osf1_to_bsd_sigset(&uap->mask, &bss);
|
||||
|
||||
(void) splhigh();
|
||||
PROC_LOCK(p);
|
||||
|
||||
switch (SCARG(uap, how)) {
|
||||
case OSF1_SIG_BLOCK:
|
||||
|
|
@ -498,7 +500,7 @@ osf1_sigprocmask(p, uap)
|
|||
break;
|
||||
}
|
||||
|
||||
(void) spl0();
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
|
@ -513,8 +515,10 @@ osf1_sigpending(p, uap)
|
|||
osf1_sigset_t oss;
|
||||
sigset_t bss;
|
||||
|
||||
PROC_LOCK(p);
|
||||
bss = p->p_siglist;
|
||||
SIGSETAND(bss, p->p_sigmask);
|
||||
PROC_UNLOCK(p);
|
||||
bsd_to_osf1_sigset(&bss, &oss);
|
||||
|
||||
return copyout(&oss, SCARG(uap, mask), sizeof(oss));
|
||||
|
|
@ -581,6 +585,7 @@ osf1_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
|||
struct sigacts *psp;
|
||||
|
||||
p = curproc;
|
||||
PROC_LOCK(p);
|
||||
psp = p->p_sigacts;
|
||||
|
||||
frame = p->p_md.md_tf;
|
||||
|
|
@ -601,6 +606,7 @@ osf1_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
|
|||
p->p_sigstk.ss_flags |= SS_ONSTACK;
|
||||
} else
|
||||
sip = (osiginfo_t *)(alpha_pal_rdusp() - rndfsize);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
(void)grow_stack(p, (u_long)sip);
|
||||
if (useracc((caddr_t)sip, fsize, VM_PROT_WRITE) == 0) {
|
||||
|
|
@ -608,10 +614,12 @@ osf1_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;
|
||||
}
|
||||
|
|
@ -699,6 +707,7 @@ osf1_sigreturn(struct proc *p,
|
|||
/*
|
||||
* Restore the user-supplied information.
|
||||
*/
|
||||
PROC_LOCK(p);
|
||||
if (ksc.sc_onstack)
|
||||
p->p_sigstk.ss_flags |= SS_ONSTACK;
|
||||
else
|
||||
|
|
@ -711,6 +720,7 @@ osf1_sigreturn(struct proc *p,
|
|||
*/
|
||||
osf1_to_bsd_sigset(&ksc.sc_mask, &p->p_sigmask);
|
||||
SIG_CANTMASK(p->p_sigmask);
|
||||
PROC_UNLOCK(p);
|
||||
|
||||
set_regs(p, (struct reg *)ksc.sc_regs);
|
||||
p->p_md.md_tf->tf_regs[FRAME_PC] = ksc.sc_pc;
|
||||
|
|
|
|||
Loading…
Reference in a new issue