proc: make collect_sigign_sigcatch() rcu-safe
PATCH 2/3 proc: make collect_sigign_sigcatch() rcu-safe
Make collect_sigign_sigcatch() rcu-safe. The necessary changes are simple, use rcu_dereference() to get ->sighand and check it is not NULL.
In theory, this ->sighand can be re-used under us (but it can't go away). We could check task->sighand == sighand once again after the main loop to prevent the race with exit/exec, but I don't think this is really needed for fs/proc.
---
fs/proc/array.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/proc/array.c renamed from fs/proc/array.c~PROC_2_SIGCATCH_RCU +6 -1
@@ -235,13 +235,18 @@ static void render_sigset_t(struct seq_fseq_printf (m,"\n" ); } +/* needs ->siglock or rcu_read_lock() */ static void collect_sigign_sigcatch (struct task_struct *p,sigset_t *ign,sigset_t *catch) { +struct sighand_struct *sighand =rcu_dereference (p->sighand);struct k_sigaction *k;int i; - k = p->sighand->action; +if (unlikely (!sighand)) +return ; + + k = sighand->action;for (i =1 ; i <= _NSIG; ++i, ++k) {if (k->sa.sa_handler ==SIG_IGN )sigaddset (ign, i);
Quoted 4 lines
In theory, this ->sighand can be re-used under us (but it can't go away). We could check
task->sighand== sighand once again after the main loop to prevent the race with exit/exec, but I don't think this is really needed for fs/proc.
In v2.6.34-rc3-500-g0eddb51 this isn't possible because the calls from task_sig() and do_task_stat() are under siglock. Is that locking removed by another pending change?
Thanks,
Roland
Quoted 8 lines · Roland McGrath
Quoted 5 lines
In theory, this ->sighand can be re-used under us (but it can't go away). We could check
task->sighand== sighand once again after the main loop to prevent the race with exit/exec, but I don't think this is really needed for fs/proc.In v2.6.34-rc3-500-g0eddb51 this isn't possible because the calls from
task_sig()anddo_task_stat()are under siglock.
Yes sure. If it is called under ->siglock we have no races we should worry about.
Quoted 2 lines
Is that locking removed
by another pending change?
Yes, the next 3/3 patch.
Oleg.