diff options
author | Pedro Martelletto <pedro@cvs.openbsd.org> | 2005-11-19 02:18:03 +0000 |
---|---|---|
committer | Pedro Martelletto <pedro@cvs.openbsd.org> | 2005-11-19 02:18:03 +0000 |
commit | 4e00bfe9e4fce563a74dcd487149539b6bc02ba9 (patch) | |
tree | a134970c4687287588758bb78c439e9cde819bb9 /sys/dev/systrace.c | |
parent | 16017b33d1fad6b6fd295f39b365b33719b42ae9 (diff) |
Remove unnecessary lockmgr() archaism that was costing too much in terms
of panics and bugfixes. Access curproc directly, do not expect a process
pointer as an argument. Should fix many "process context required" bugs.
Incentive and okay millert@, okay marc@. Various testing, thanks.
Diffstat (limited to 'sys/dev/systrace.c')
-rw-r--r-- | sys/dev/systrace.c | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/sys/dev/systrace.c b/sys/dev/systrace.c index 2c1fced238c..9fa8f3292cd 100644 --- a/sys/dev/systrace.c +++ b/sys/dev/systrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace.c,v 1.38 2005/04/17 22:11:34 millert Exp $ */ +/* $OpenBSD: systrace.c,v 1.39 2005/11/19 02:18:00 pedro Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -139,13 +139,13 @@ struct lock systrace_lck; static __inline void systrace_lock(void) { - lockmgr(&systrace_lck, LK_EXCLUSIVE, NULL, curproc); + lockmgr(&systrace_lck, LK_EXCLUSIVE, NULL); } static __inline void systrace_unlock(void) { - lockmgr(&systrace_lck, LK_RELEASE, NULL, curproc); + lockmgr(&systrace_lck, LK_RELEASE, NULL); } /* Needs to be called with fst locked */ @@ -216,7 +216,7 @@ systracef_read(fp, poff, uio, cred) again: systrace_lock(); - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); if ((process = TAILQ_FIRST(&fst->messages)) != NULL) { error = uiomove((caddr_t)&process->msg, @@ -236,7 +236,7 @@ systracef_read(fp, poff, uio, cred) if (fp->f_flag & FNONBLOCK) error = EAGAIN; else { - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); error = tsleep(fst, PWAIT|PCATCH, "systrrd", 0); if (error) goto out; @@ -245,7 +245,7 @@ systracef_read(fp, poff, uio, cred) } - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); out: return (error); } @@ -333,7 +333,7 @@ systracef_ioctl(fp, cmd, data, p) return (ret); systrace_lock(); - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); if (pid) { strp = systrace_findpid(fst, pid); @@ -405,7 +405,7 @@ systracef_ioctl(fp, cmd, data, p) } unlock: - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); return (ret); } @@ -423,13 +423,13 @@ systracef_poll(fp, events, p) return (0); systrace_lock(); - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); if (!TAILQ_EMPTY(&fst->messages)) revents = events & (POLLIN | POLLRDNORM); else selrecord(p, &fst->si); - lockmgr(&fst->lock, LK_RELEASE, NULL, p); + lockmgr(&fst->lock, LK_RELEASE, NULL); return (revents); } @@ -464,7 +464,7 @@ systracef_close(fp, p) struct str_policy *strpol; systrace_lock(); - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); /* Untrace all processes */ @@ -493,7 +493,7 @@ systracef_close(fp, p) vrele(fst->fd_cdir); if (fst->fd_rdir) vrele(fst->fd_rdir); - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); FREE(fp->f_data, M_XDATA); fp->f_data = NULL; @@ -639,14 +639,14 @@ systrace_exit(struct proc *proc) strp = proc->p_systrace; if (strp != NULL) { fst = strp->parent; - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); /* Insert Exit message */ systrace_msg_child(fst, strp, -1); systrace_detach(strp); - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); } else systrace_unlock(); CLR(proc->p_flag, P_SYSTRACE); @@ -666,7 +666,7 @@ systrace_fork(struct proc *oldproc, struct proc *p) } fst = oldstrp->parent; - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); if (systrace_insert_process(fst, p)) @@ -681,7 +681,7 @@ systrace_fork(struct proc *oldproc, struct proc *p) /* Insert fork message */ systrace_msg_child(fst, oldstrp, p->p_pid); out: - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); } #define REACQUIRE_LOCK do { \ @@ -692,7 +692,7 @@ systrace_fork(struct proc *oldproc, struct proc *p) return (error); \ } \ fst = strp->parent; \ - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); \ + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); \ systrace_unlock(); \ } while (0) @@ -725,7 +725,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) fst = strp->parent; - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); /* @@ -769,7 +769,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) error = EPERM; } systrace_replacefree(strp); - lockmgr(&fst->lock, LK_RELEASE, NULL, p); + lockmgr(&fst->lock, LK_RELEASE, NULL); if (policy == SYSTR_POLICY_PERMIT) error = (*callp->sy_call)(p, v, retval); return (error); @@ -798,7 +798,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) } fst = strp->parent; - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); if (strp->answer == SYSTR_POLICY_NEVER) { @@ -833,7 +833,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) } else CLR(strp->flags, STR_PROC_SETEUID|STR_PROC_SETEGID); - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); error = (*callp->sy_call)(p, v, retval); @@ -876,7 +876,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) /* Acquire lock */ fst = strp->parent; - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); if (p->p_emul != oldemul) { @@ -908,7 +908,7 @@ systrace_redirect(int code, struct proc *p, void *v, register_t *retval) } out_unlock: - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); out: return (error); } @@ -1321,7 +1321,7 @@ systrace_execve1(char *path, struct proc *p) msg_execve = &strp->msg.msg_data.msg_execve; fst = strp->parent; - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); /* @@ -1332,7 +1332,7 @@ systrace_execve1(char *path, struct proc *p) if (fst->issuser || fst->p_ruid != p->p_cred->p_ruid || fst->p_rgid != p->p_cred->p_rgid) { - lockmgr(&fst->lock, LK_RELEASE, NULL, p); + lockmgr(&fst->lock, LK_RELEASE, NULL); return; } strlcpy(msg_execve->path, path, MAXPATHLEN); @@ -1475,7 +1475,7 @@ systrace_scriptname(struct proc *p, char *dst) strp = p->p_systrace; fst = strp->parent; - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, p); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); if (!fst->issuser && (ISSET(p->p_flag, P_SUGID) || @@ -1498,7 +1498,7 @@ systrace_scriptname(struct proc *p, char *dst) out: strp->scriptname[0] = '\0'; - lockmgr(&fst->lock, LK_RELEASE, NULL, p); + lockmgr(&fst->lock, LK_RELEASE, NULL); return (error); } @@ -1516,7 +1516,7 @@ systrace_namei(struct nameidata *ndp) strp = cnp->cn_proc->p_systrace; if (strp != NULL) { fst = strp->parent; - lockmgr(&fst->lock, LK_EXCLUSIVE, NULL, curproc); + lockmgr(&fst->lock, LK_EXCLUSIVE, NULL); systrace_unlock(); for (i = 0; i < strp->nfname; i++) @@ -1529,7 +1529,7 @@ systrace_namei(struct nameidata *ndp) strcmp(cnp->cn_pnbuf, strp->scriptname) == 0) hamper = 1; - lockmgr(&fst->lock, LK_RELEASE, NULL, curproc); + lockmgr(&fst->lock, LK_RELEASE, NULL); } else systrace_unlock(); @@ -1746,7 +1746,6 @@ systrace_make_msg(struct str_process *strp, int type) { struct str_message *msg = &strp->msg; struct fsystrace *fst = strp->parent; - struct proc *p = strp->proc; int st, pri; pri = PWAIT|PCATCH; @@ -1772,7 +1771,7 @@ systrace_make_msg(struct str_process *strp, int type) systrace_wakeup(fst); /* Release the lock - XXX */ - lockmgr(&fst->lock, LK_RELEASE, NULL, p); + lockmgr(&fst->lock, LK_RELEASE, NULL); while (1) { st = tsleep(strp, pri, "systrmsg", 0); |