public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: "Serge E. Hallyn" <serge@hallyn.com>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Matt Helsley <matthltc@us.ibm.com>,
	richard@nod.at, containers@lists.linux-foundation.org,
	eparis@redhat.com, oleg@redhat.com, dhowells@redhat.com
Subject: Re: user namespace: make signal.c respect user namespaces (v5)
Date: Thu, 17 Nov 2011 19:24:34 -0800	[thread overview]
Message-ID: <m1aa7u2jv1.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20111117045230.GA26345@hallyn.com> (Serge E. Hallyn's message of "Thu, 17 Nov 2011 04:52:30 +0000")

"Serge E. Hallyn" <serge@hallyn.com> writes:

> ipc/mqueue.c: for __SI_MESQ, convert the uid being sent to recipient's
> user namespace. (new, thanks Oleg)
>
> __send_signal: convert current's uid to the recipient's user namespace
> for any siginfo which is not SI_FROMKERNEL (patch from Oleg, thanks
> again :)
>
> do_notify_parent and do_notify_parent_cldstop: map task's uid to parent's
> user namespace
>
> ptrace_signal maps parent's uid into current's user namespace before
> including in signal to current.  IIUC Oleg has argued that this shouldn't
> matter as the debugger will play with it, but it seems like not converting
> the value currently being set is misleading.
>
> Changelog:
> Sep 20: Inspired by Oleg's suggestion, define map_cred_ns() helper to
> 	simplify callers and help make clear what we are translating
>         (which uid into which namespace).  Passing the target task would
> 	make callers even easier to read, but we pass in user_ns because
> 	current_user_ns() != task_cred_xxx(current, user_ns).
> Sep 20: As recommended by Oleg, also put task_pid_vnr() under rcu_read_lock
> 	in ptrace_signal().
> Sep 23: In send_signal(), detect when (user) signal is coming from an
> 	ancestor or unrelated user namespace.  Pass that on to __send_signal,
> 	which sets si_uid to 0 or overflowuid if needed.
> Oct 12: Base on Oleg's fixup_uid() patch.  On top of that, handle all
> 	SI_FROMKERNEL cases at callers, because we can't assume sender is
> 	current in those cases.
> Nov 10: (mhelsley) rename fixup_uid to more meaningful usern_fixup_signal_uid
> Nov 10: (akpm) make the !CONFIG_USER_NS case clearer
>

> @@ -1088,6 +1117,9 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
>  				q->info.si_pid = 0;
>  			break;
>  		}
> +
> +		userns_fixup_signal_uid(info, t);

There is a small bug here.  You want to fixup q->info, not info.
Otherwise you might try dereferencing one of the special signals and get
a NULL pointer dereference.

Eric

> +
>  	} else if (!is_si_special(info)) {
>  		if (sig >= SIGRTMIN && info->si_code != SI_USER) {
>  			/*

  reply	other threads:[~2011-11-18  3:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-17  4:52 user namespace: make signal.c respect user namespaces (v5) Serge E. Hallyn
2011-11-18  3:24 ` Eric W. Biederman [this message]
2011-11-18 17:37   ` Serge E. Hallyn
2011-11-18 18:46     ` Eric W. Biederman
2011-11-19  0:43       ` Serge Hallyn
2011-11-19  4:53         ` Eric W. Biederman

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=m1aa7u2jv1.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=akpm@linux-foundation.org \
    --cc=containers@lists.linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=eparis@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthltc@us.ibm.com \
    --cc=oleg@redhat.com \
    --cc=richard@nod.at \
    --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