[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140114190756.GA30680@redhat.com>
Date:	Tue, 14 Jan 2014 20:07:56 +0100
From:	Oleg Nesterov <oleg@...hat.com>
To:	Will Drewry <wad@...omium.org>
Cc:	linux-kernel@...r.kernel.org, nschichan@...ebox.fr,
	keescook@...omium.org, james.l.morris@...cle.com,
	akpm@...ux-foundation.org, holt@....com, viro@...iv.linux.org.uk
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Powered by blists - more mailing lists
 
