All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Will Drewry <wad@chromium.org>
Cc: linux-kernel@vger.kernel.org, nschichan@freebox.fr,
	keescook@chromium.org, james.l.morris@oracle.com,
	akpm@linux-foundation.org, holt@sgi.com, viro@zeniv.linux.org.uk
Subject: Re: [PATCH 2/2] sys, seccomp: add PR_SECCOMP_EXT and SECCOMP_EXT_ACT_TSYNC
Date: Tue, 14 Jan 2014 20:07:56 +0100	[thread overview]
Message-ID: <20140114190756.GA30680@redhat.com> (raw)
In-Reply-To: <1389645028-17157-2-git-send-email-wad@chromium.org>

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.


  parent reply	other threads:[~2014-01-14 19:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 20:30 [PATCH 1/2] seccomp: protect seccomp.filter pointer (w) with the task_lock Will Drewry
2014-01-13 20:30 ` [PATCH 2/2] sys, seccomp: add PR_SECCOMP_EXT and SECCOMP_EXT_ACT_TSYNC Will Drewry
2014-01-13 22:42   ` [PATCH 3/3] Documentation/prctl/seccomp_filter.txt: document extensions Will Drewry
2014-01-13 23:36   ` [PATCH 2/2] sys, seccomp: add PR_SECCOMP_EXT and SECCOMP_EXT_ACT_TSYNC Andy Lutomirski
2014-01-14 18:59     ` Will Drewry
2014-01-14 20:24       ` Andy Lutomirski
2014-01-14 20:59         ` Will Drewry
2014-01-14 21:09           ` Andy Lutomirski
2014-01-14 21:19             ` Will Drewry
2014-01-14 19:07   ` Oleg Nesterov [this message]
2014-01-14 19:21   ` Oleg Nesterov
2014-01-14 20:02     ` Oleg Nesterov
2014-01-14 20:13       ` Oleg Nesterov
2014-01-14 20:53         ` Will Drewry
2014-01-14 21:06     ` Will Drewry
2014-01-15 19:04       ` Oleg Nesterov
2014-01-15 19:28         ` Oleg Nesterov
2014-01-15 19:33         ` Will Drewry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140114190756.GA30680@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=holt@sgi.com \
    --cc=james.l.morris@oracle.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nschichan@freebox.fr \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wad@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.