diff options
author | jhb <jhb@FreeBSD.org> | 2001-06-22 23:05:11 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-06-22 23:05:11 +0000 |
commit | e5e16e09ad14c1fc1ed934f3146c5c544b03c8d0 (patch) | |
tree | bf66bbbe6655542b5ecd03df2b842fdf71bbf1cf /sys | |
parent | 8210b8d106096a99d54127a3dd7994fa47bf8a86 (diff) | |
download | FreeBSD-src-e5e16e09ad14c1fc1ed934f3146c5c544b03c8d0.zip FreeBSD-src-e5e16e09ad14c1fc1ed934f3146c5c544b03c8d0.tar.gz |
- Grab the proc lock around CURSIG and postsig(). Don't release the proc
lock until after grabbing the sched_lock to avoid CURSIG racing with
psignal.
- Don't grab Giant for addupc_task() as it isn't needed.
Reported by: tegge (signal race), bde (addupc_task a while back)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/alpha/alpha/trap.c | 6 | ||||
-rw-r--r-- | sys/amd64/amd64/trap.c | 7 | ||||
-rw-r--r-- | sys/i386/i386/trap.c | 7 | ||||
-rw-r--r-- | sys/ia64/ia64/trap.c | 6 | ||||
-rw-r--r-- | sys/kern/subr_trap.c | 7 |
5 files changed, 20 insertions, 13 deletions
diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index 159ef75..4106aef 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -145,10 +145,12 @@ userret(p, frame, oticks) int sig; /* take pending signals */ + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(); p->p_pri.pri_level = p->p_pri.pri_user; if (resched_wanted(p)) { /* @@ -165,9 +167,11 @@ userret(p, frame, oticks) mi_switch(); mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); } /* @@ -175,8 +179,6 @@ userret(p, frame, oticks) */ if (p->p_sflag & PS_PROFIL) { mtx_unlock_spin(&sched_lock); - if (!mtx_owned(&Giant)) - mtx_lock(&Giant); addupc_task(p, TRAPF_PC(frame), (int)(p->p_sticks - oticks) * psratio); } else diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index c1a4e2e..5167ceb 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -171,10 +171,12 @@ userret(p, frame, oticks) { int sig; + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); p->p_pri.pri_level = p->p_pri.pri_user; if (resched_wanted(p)) { /* @@ -191,9 +193,11 @@ userret(p, frame, oticks) mi_switch(); mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); } /* @@ -201,9 +205,6 @@ userret(p, frame, oticks) */ if (p->p_sflag & PS_PROFIL) { mtx_unlock_spin(&sched_lock); - /* XXX - do we need Giant? */ - if (!mtx_owned(&Giant)) - mtx_lock(&Giant); addupc_task(p, TRAPF_PC(frame), (u_int)(p->p_sticks - oticks) * psratio); } else diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index c1a4e2e..5167ceb 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -171,10 +171,12 @@ userret(p, frame, oticks) { int sig; + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); p->p_pri.pri_level = p->p_pri.pri_user; if (resched_wanted(p)) { /* @@ -191,9 +193,11 @@ userret(p, frame, oticks) mi_switch(); mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); } /* @@ -201,9 +205,6 @@ userret(p, frame, oticks) */ if (p->p_sflag & PS_PROFIL) { mtx_unlock_spin(&sched_lock); - /* XXX - do we need Giant? */ - if (!mtx_owned(&Giant)) - mtx_lock(&Giant); addupc_task(p, TRAPF_PC(frame), (u_int)(p->p_sticks - oticks) * psratio); } else diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c index 5573178..edb8767 100644 --- a/sys/ia64/ia64/trap.c +++ b/sys/ia64/ia64/trap.c @@ -85,10 +85,12 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks) int sig; /* take pending signals */ + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(); p->p_pri.pri_level = p->p_pri.pri_user; if (resched_wanted(p)) { /* @@ -105,9 +107,11 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks) mi_switch(); mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); } /* @@ -115,8 +119,6 @@ userret(register struct proc *p, struct trapframe *frame, u_quad_t oticks) */ if (p->p_sflag & PS_PROFIL) { mtx_unlock_spin(&sched_lock); - if (!mtx_owned(&Giant)) - mtx_lock(&Giant); addupc_task(p, TRAPF_PC(frame), (int)(p->p_sticks - oticks) * psratio); } else diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index c1a4e2e..5167ceb 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -171,10 +171,12 @@ userret(p, frame, oticks) { int sig; + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); p->p_pri.pri_level = p->p_pri.pri_user; if (resched_wanted(p)) { /* @@ -191,9 +193,11 @@ userret(p, frame, oticks) mi_switch(); mtx_unlock_spin(&sched_lock); PICKUP_GIANT(); + PROC_LOCK(p); while ((sig = CURSIG(p)) != 0) postsig(sig); mtx_lock_spin(&sched_lock); + PROC_UNLOCK_NOSWITCH(p); } /* @@ -201,9 +205,6 @@ userret(p, frame, oticks) */ if (p->p_sflag & PS_PROFIL) { mtx_unlock_spin(&sched_lock); - /* XXX - do we need Giant? */ - if (!mtx_owned(&Giant)) - mtx_lock(&Giant); addupc_task(p, TRAPF_PC(frame), (u_int)(p->p_sticks - oticks) * psratio); } else |