Messages in this thread | | | Date | Tue, 14 Jan 2014 20:07:56 +0100 | From | Oleg Nesterov <> | Subject | Re: [PATCH 2/2] sys, seccomp: add PR_SECCOMP_EXT and SECCOMP_EXT_ACT_TSYNC |
| |
On 01/13, Will Drewry wrote: > > When prctl(PR_SECCOMP_EXT, SECCOMP_EXT_ACT_TSYNC, 0, 0) is called, it > will attempt to synchronize all threads in current's threadgroup to its > seccomp filter program.
TBH, I do not understand what this patch actually does ;) I'll try to read it later. Still a couple of nits.
> +static pid_t seccomp_sync_threads(void) > +{ > + struct task_struct *thread, *caller; > + pid_t failed = 0; > + thread = caller = current; > + > + read_lock(&tasklist_lock); > + if (thread_group_empty(caller)) > + goto done;
You can check thread_group_empty() before tasklist_lock, otherwise this fast-path before while_each_thread() makes no sense.
> + while_each_thread(caller, thread) { > + task_lock(thread);
Could you remind what task_lock() protects wrt seccomp?
> + } else { > + /* Keep the last sibling that failed to return. */ > + struct pid *pid = get_task_pid(thread, PIDTYPE_PID); > + failed = pid_vnr(pid); > + put_pid(pid); > + /* If the pid cannot be resolved, then return -ESRCH */ > + if (failed == 0) > + failed = -ESRCH;
You can just do
failed = task_pid_vnr(thread);
"failed == 0" is not possible either way (we are doing while_each_thread under tasklist, the task can't do detach_pid).
Oleg.
| |