summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2012-06-06 04:47:44 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2012-06-06 04:47:44 +0000
commit26ff5f629cee273823a79d7f9b10b44fddd18ee5 (patch)
tree65ba517bb7418c7a9290a65a8c2f6d27eb73b9a5 /sys/kern
parente587be9b554cd99ab0c870bebe4450d4c4d71a31 (diff)
EVFILT_SIGNAL and EVFILT_PROC events need to track the process they're
attached to and not just the thread, which can go away. Problem observed by jsg@; ok jsg@ matthew@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_event.c28
-rw-r--r--sys/kern/kern_sig.c12
2 files changed, 20 insertions, 20 deletions
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index b016310e652..7b1469ac144 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_event.c,v 1.46 2012/04/22 05:43:14 guenther Exp $ */
+/* $OpenBSD: kern_event.c,v 1.47 2012/06/06 04:47:43 guenther Exp $ */
/*-
* Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
@@ -210,26 +210,26 @@ filt_kqueue(struct knote *kn, long hint)
int
filt_procattach(struct knote *kn)
{
- struct proc *p;
+ struct process *pr;
- p = pfind(kn->kn_id);
- if (p == NULL)
+ pr = prfind(kn->kn_id);
+ if (pr == NULL)
return (ESRCH);
- /* threads and exiting processes can't be specified */
- if (p->p_flag & P_THREAD || p->p_p->ps_flags & PS_EXITING)
+ /* exiting processes can't be specified */
+ if (pr->ps_flags & PS_EXITING)
return (ESRCH);
/*
* Fail if it's not owned by you, or the last exec gave us
* setuid/setgid privs (unless you're root).
*/
- if (p->p_p != curproc->p_p &&
- (p->p_cred->p_ruid != curproc->p_cred->p_ruid ||
- (p->p_p->ps_flags & PS_SUGID)) && suser(curproc, 0) != 0)
+ if (pr != curproc->p_p &&
+ (pr->ps_cred->p_ruid != curproc->p_cred->p_ruid ||
+ (pr->ps_flags & PS_SUGID)) && suser(curproc, 0) != 0)
return (EACCES);
- kn->kn_ptr.p_proc = p;
+ kn->kn_ptr.p_process = pr;
kn->kn_flags |= EV_CLEAR; /* automatically set */
/*
@@ -242,7 +242,7 @@ filt_procattach(struct knote *kn)
}
/* XXX lock the proc here while adding to the list? */
- SLIST_INSERT_HEAD(&p->p_p->ps_klist, kn, kn_selnext);
+ SLIST_INSERT_HEAD(&pr->ps_klist, kn, kn_selnext);
return (0);
}
@@ -258,13 +258,13 @@ filt_procattach(struct knote *kn)
void
filt_procdetach(struct knote *kn)
{
- struct proc *p = kn->kn_ptr.p_proc;
+ struct process *pr = kn->kn_ptr.p_process;
if (kn->kn_status & KN_DETACHED)
return;
/* XXX locking? this might modify another process. */
- SLIST_REMOVE(&p->p_p->ps_klist, kn, knote, kn_selnext);
+ SLIST_REMOVE(&pr->ps_klist, kn, knote, kn_selnext);
}
int
@@ -288,7 +288,7 @@ filt_proc(struct knote *kn, long hint)
* from the process's klist
*/
if (event == NOTE_EXIT) {
- struct process *pr = kn->kn_ptr.p_proc->p_p;
+ struct process *pr = kn->kn_ptr.p_process;
kn->kn_status |= KN_DETACHED;
kn->kn_flags |= (EV_EOF | EV_ONESHOT);
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index c1cb5857ce0..06c26542e46 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.141 2012/04/13 16:37:51 kettenis Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.142 2012/06/06 04:47:43 guenther Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -1647,13 +1647,13 @@ initsiginfo(siginfo_t *si, int sig, u_long trapno, int code, union sigval val)
int
filt_sigattach(struct knote *kn)
{
- struct proc *p = curproc;
+ struct process *pr = curproc->p_p;
- kn->kn_ptr.p_proc = p;
+ kn->kn_ptr.p_process = pr;
kn->kn_flags |= EV_CLEAR; /* automatically set */
/* XXX lock the proc here while adding to the list? */
- SLIST_INSERT_HEAD(&p->p_p->ps_klist, kn, kn_selnext);
+ SLIST_INSERT_HEAD(&pr->ps_klist, kn, kn_selnext);
return (0);
}
@@ -1661,9 +1661,9 @@ filt_sigattach(struct knote *kn)
void
filt_sigdetach(struct knote *kn)
{
- struct proc *p = kn->kn_ptr.p_proc;
+ struct process *pr = kn->kn_ptr.p_process;
- SLIST_REMOVE(&p->p_p->ps_klist, kn, knote, kn_selnext);
+ SLIST_REMOVE(&pr->ps_klist, kn, knote, kn_selnext);
}
/*