mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bastian Blank <bastian@waldi.eu.org>
To: "Serge E. Hallyn" <serge@hallyn.com>
Cc: containers@lists.linux-foundation.org,
	kernel list <linux-kernel@vger.kernel.org>,
	LSM <linux-security-module@vger.kernel.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Kees Cook <kees.cook@canonical.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Michael Kerrisk <mtk.manpages@gmail.com>
Subject: Re: [PATCH 05/08] Allow ptrace from non-init user namespaces
Date: Fri, 14 Jan 2011 15:46:09 +0100	[thread overview]
Message-ID: <20110114144608.GA20945@wavehammer.waldi.eu.org> (raw)
In-Reply-To: <20110111064439.GF27515@mail.hallyn.com>

This mail did not show up in my inbox, even if I'm listed as receipient.
I only got a copy via the mailinglist.

On Tue, Jan 11, 2011 at 06:44:39AM +0000, Serge E. Hallyn wrote:
> diff --git a/kernel/ptrace.c b/kernel/ptrace.c
> index 99bbaa3..ec7605d 100644
> --- a/kernel/ptrace.c
> +++ b/kernel/ptrace.c
> @@ -134,21 +134,24 @@ int __ptrace_may_access(struct task_struct *task, unsigned int mode)
>  		return 0;
>  	rcu_read_lock();
>  	tcred = __task_cred(task);
> -	if ((cred->uid != tcred->euid ||
> -	     cred->uid != tcred->suid ||
> -	     cred->uid != tcred->uid  ||
> -	     cred->gid != tcred->egid ||
> -	     cred->gid != tcred->sgid ||
> -	     cred->gid != tcred->gid) &&
> -	    !capable(CAP_SYS_PTRACE)) {
> -		rcu_read_unlock();
> -		return -EPERM;
> -	}
> +	if (cred->user->user_ns == tcred->user->user_ns &&
> +	    (cred->uid == tcred->euid &&
> +	     cred->uid == tcred->suid &&
> +	     cred->uid == tcred->uid  &&
> +	     cred->gid == tcred->egid &&
> +	     cred->gid == tcred->sgid &&
> +	     cred->gid == tcred->gid))
> +		goto ok;
> +	if (ns_capable(tcred->user->user_ns, CAP_SYS_PTRACE))
> +		goto ok;
> +	rcu_read_unlock();
> +	return -EPERM;
> +ok:

This is wrong. Please move that out into functions if you are unable to
get the conditions right.

Bastian

-- 
If a man had a child who'd gone anti-social, killed perhaps, he'd still
tend to protect that child.
		-- McCoy, "The Ultimate Computer", stardate 4731.3

  reply	other threads:[~2011-01-14 14:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-11  6:43 userns: targeted capabilities v4 Serge E. Hallyn
2011-01-11  6:43 ` [PATCH 01/08] Add a user_namespace as creator/owner of uts_namespace Serge E. Hallyn
2011-01-11  6:44 ` [PATCH 02/08] security: Make capabilities relative to the user namespace Serge E. Hallyn
2011-01-11  6:44 ` [PATCH 03/08] allow sethostname in a container Serge E. Hallyn
2011-01-11 16:14   ` Serge E. Hallyn
2011-02-04 15:56     ` Serge E. Hallyn
2011-01-11  6:44 ` [PATCH 04/08] allow killing tasks in your own or child userns Serge E. Hallyn
2011-01-11  6:44 ` [PATCH 05/08] Allow ptrace from non-init user namespaces Serge E. Hallyn
2011-01-14 14:46   ` Bastian Blank [this message]
2011-01-14 15:00     ` Bastian Blank
2011-01-15  0:35     ` Serge E. Hallyn
2011-01-11  6:44 ` [PATCH 06/08] user namespaces: convert all capable checks in kernel/sys.c Serge E. Hallyn
2011-01-11  6:45 ` [PATCH 07/08] user namespaces: convert several capable() calls Serge E. Hallyn
2011-01-11  6:45 ` [PATCH 08/08] userns: check user namespace for task->file uid equivalence checks Serge E. Hallyn

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=20110114144608.GA20945@wavehammer.waldi.eu.org \
    --to=bastian@waldi.eu.org \
    --cc=adobriyan@gmail.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=kees.cook@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=serge@hallyn.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

all inboxes | Powered by JetHome®