linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>,
	Brad Spengler <spender@grsecurity.net>,
	Colin Walters <walters@redhat.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] pidns: kill the unnecessary CLONE_NEWPID in copy_process()
Date: Thu, 22 Aug 2013 19:10:01 +0200	[thread overview]
Message-ID: <20130822171001.GA20321@redhat.com> (raw)
In-Reply-To: <20130822170939.GA20296@redhat.com>

8382fcac "pidns: Outlaw thread creation after unshare(CLONE_NEWPID)"
nacks CLONE_NEWPID if the forking process unshared pid_ns. This is
correct but unnecessary, copy_pid_ns() does the same check.

Test-case (needs root or CLONE_NEWUSER should be added):

	static int child(void *arg)
	{
		return 0;
	}

	static char stack[16 * 1024];

	int main(void)
	{
		pid_t pid;

		assert(unshare(CLONE_NEWPID) == 0);

		pid = clone(child, stack + sizeof(stack) / 2,
				CLONE_NEWPID | SIGCHLD, NULL);
		assert(pid < 0 && errno == EINVAL);

		return 0;
	}

clone(CLONE_NEWPID) correctly fails with or without this change.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/fork.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index 86f5376..8d56338 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1176,7 +1176,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
 	 * If the new process will be in a different pid namespace don't
 	 * allow the creation of threads, or share the signal handlers.
 	 */
-	if ((clone_flags & (CLONE_SIGHAND | CLONE_NEWPID)) &&
+	if ((clone_flags & CLONE_SIGHAND) &&
 	    (task_active_pid_ns(current) != current->nsproxy->pid_ns))
 		return ERR_PTR(-EINVAL);
 
-- 
1.5.5.1


  parent reply	other threads:[~2013-08-22 17:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-22 17:09 [PATCH 0/3] namespaces && fork fixes/cleanups Oleg Nesterov
2013-08-22 17:09 ` [PATCH 1/3] pidns: fix vfork() after unshare(CLONE_NEWPID) Oleg Nesterov
2013-08-22 17:59   ` Andy Lutomirski
2013-08-22 18:22     ` Oleg Nesterov
2013-08-22 17:10 ` Oleg Nesterov [this message]
2013-08-22 18:05   ` [PATCH 2/3] pidns: kill the unnecessary CLONE_NEWPID in copy_process() Andy Lutomirski
2013-08-22 17:10 ` [PATCH 3/3] fork: unify and tighten up CLONE_NEWUSER/CLONE_NEWPID checks Oleg Nesterov
2013-08-22 18:10   ` Andy Lutomirski
2013-08-22 18:15     ` Oleg Nesterov
2013-08-22 18:29       ` Andy Lutomirski
2013-08-22 18:32         ` Oleg Nesterov
2013-08-22 19:11           ` Andy Lutomirski
2013-08-23 13:59             ` Oleg Nesterov
2013-08-23 17:42               ` Andy Lutomirski

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=20130822171001.GA20321@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=spender@grsecurity.net \
    --cc=torvalds@linux-foundation.org \
    --cc=walters@redhat.com \
    --cc=xemul@parallels.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).