All of lore.kernel.org
 help / color / mirror / Atom feed
From: Serge Hallyn <serge.hallyn@canonical.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: lkml <linux-kernel@vger.kernel.org>,
	richard@nod.at, Andrew Morton <akpm@google.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Tejun Heo <tj@kernel.org>,
	serge@hallyn.com
Subject: Re: [PATCH] user namespace: make signal.c respect user namespaces
Date: Tue, 27 Sep 2011 09:28:33 -0500	[thread overview]
Message-ID: <20110927142833.GA4876@peqn> (raw)
In-Reply-To: <20110926160619.GA13736@redhat.com>

Quoting Oleg Nesterov (oleg@redhat.com):
> On 09/25, Serge E. Hallyn wrote:
> >
> > Quoting Oleg Nesterov (oleg@redhat.com):
> > > On 09/23, Serge E. Hallyn wrote:
> > > >
> > > > Quoting Oleg Nesterov (oleg@redhat.com):
> > > > > On 09/23, Serge E. Hallyn wrote:
> > > > > >
> > > > > > It looks like I can fix all the
> > > > > > cases
> > > > >
> > > > > except ptrace_signal(). Although we can simply ignore this case, imho.
> > > >
> > > > ptrace_signal() calls send_signal() though.
> > >
> > > Confused... I meant the "if (signr != info->si_signo)" case. This is
> > > simple, and I only meant that this case is not that important.
> >
> > Yes, that's the case I was talking about.  That then proceeds through
> > send_signal().
> 
> It doesn't?

No, I was saying it *does*.

> I am even more confuused. Anyway, your patch adds map_cred_ns()
> into ptrace_signal().

Yes.  Which is fine, because target task is current, so the code I add
in send_signal() which tries to map the uid if necessary will check
that current == current, and not re-map the uid.

> > The whole new patch (so far only compile-tested) is below.
> 
> Perhaps I missed something, but it looks overcomplicated.

That may be :)

> I was thinking
> about the (uncompiled/untested) simple patch below (it ignores ptrace_signal
> for clarity).
> 
> And note that this way we do not need to modify do_notify_parent*()
> or ipc/mqueue.c:__do_notify() (your patch doesn't cover the latter).
> Unless I missed something of course.
> 
> And we do not need to handle the SEND_SIG_NOINFO case separately.
> 
> 
> However, we still have the problems with sigqueueinfo, 
> 
> > > > > > by checking whether si_fromuser(info)
> > > > >
> > > > > I am not sure... sys_rt_queueinfo() is nasty. Plus we have to handle
> > > > > the "fromkernel" case too. May be we can ignore this too.
> > > >
> > > > sys_rt_tgsigqueueinfo() still seems to go through send_signal().
> > >
> > > Yes. But how can you fix si_uid? We do not even know if it exists.
> > > Please look at siginfo/_uid, there is a union. We can't know what
> > > the caller of sys_rt_sigqueueinfo() puts in this location.
> >
> > But it's a union alongside the pid.
> 
> Again, I do not understand... Yes, we have the same problem with
> 
> 	if (from_ancestor_ns)
> 		q->info.si_pid = 0;
> 
> This was discussed, we do not know what we can do.

I see.

> My point was, this
> change is not sigqueueinfo-friendly too.

Yup.

> Oleg.
> 
> --- x/kernel/signal.c
> +++ x/kernel/signal.c
> @@ -1019,6 +1019,27 @@ static inline int legacy_queue(struct si
>  	return (sig < SIGRTMIN) && sigismember(&signals->signal, sig);
>  }
>  
> +static inline fixup_uid(struct siginfo *info, struct task_struct *t)
> +{
> +#ifdef CONFIG_USER_NS
> +	if (current_user_ns() == task_cred_xxx(t, user_ns)))
> +#endif
> +		return;
> +
> +	if (SI_FROMKERNEL(info))
> +		switch (info->si_code & __SI_MASK) {
> +			default:
> +				return;
> +
> +			case __SI_CHLD:
> +			case __SI_MESGQ:
> +				break;
> +		}
> +
> +	info->si_uid = user_ns_map_uid(task_cred_xxx(t, user_ns),
> +					current_cred(), info->si_uid);
> +}
> +
>  static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
>  			int group, int from_ancestor_ns)
>  {
> @@ -1088,6 +1109,9 @@ static int __send_signal(int sig, struct
>  				q->info.si_pid = 0;
>  			break;
>  		}
> +
> +		fixup_uid(info, t);
> +
>  	} else if (!is_si_special(info)) {
>  		if (sig >= SIGRTMIN && info->si_code != SI_USER) {
>  			/*

It certainly is much simpler.  I'll take some time to walk through all
of send_signal again and make sure I understand what it does in all
the cases.

thanks,
-serge

  reply	other threads:[~2011-09-27 14:28 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-19 21:45 [PATCH] user namespace: make signal.c respect user namespaces Serge E. Hallyn
2011-09-19 21:47 ` [PATCH] user namespace: usb: make usb urbs user namespace aware Serge E. Hallyn
2011-09-20 13:17   ` Oleg Nesterov
2011-09-20 13:33     ` Serge E. Hallyn
2011-09-21  5:01     ` [PATCH] user namespace: usb: make usb urbs user namespace aware (v2) Serge E. Hallyn
2011-09-21 18:31       ` Oleg Nesterov
2011-09-21 19:12         ` Serge E. Hallyn
2011-09-21 19:18           ` Greg KH
2011-09-23  1:27             ` [PATCH resend] " Serge E. Hallyn
2011-09-23 15:48               ` Alan Stern
2011-09-23 16:06                 ` Serge E. Hallyn
2011-09-23 16:21                   ` Alan Stern
2011-09-23 17:22                     ` Serge E. Hallyn
2011-09-23 18:35                       ` Alan Stern
2011-09-20 12:22 ` [PATCH] user namespace: make signal.c respect user namespaces Oleg Nesterov
2011-09-20 12:44   ` Serge E. Hallyn
2011-09-20 13:41     ` Oleg Nesterov
2011-09-20 14:39       ` [PATCH 0/2] (Was: user namespace: make signal.c respect user namespaces) Oleg Nesterov
2011-09-20 14:39         ` [PATCH 1/2] creds: kill __task_cred()->task_is_dead() check Oleg Nesterov
2011-09-20 15:14           ` drivers/staging/usbip/ abuses task_is_dead/exit_state Oleg Nesterov
2011-09-20 18:38             ` Greg KH
2012-03-06 17:39               ` ping: " Oleg Nesterov
2012-03-06 19:30                 ` Tobias Klauser
2012-03-08 18:57                   ` Oleg Nesterov
2012-03-13 11:45                     ` Tobias Klauser
2012-03-13 18:07                       ` [PATCH] staging: usbip: fix the usage of kthread_stop() Oleg Nesterov
2012-04-01 23:17                         ` Oleg Nesterov
2012-04-02  8:11                           ` Tobias Klauser
2011-09-20 15:28           ` [PATCH 1/2] creds: kill __task_cred()->task_is_dead() check Paul E. McKenney
2011-09-20 15:40             ` Oleg Nesterov
2011-09-20 15:48               ` Paul E. McKenney
2011-09-20 16:27           ` David Howells
2011-09-20 14:39         ` [PATCH 2/2] creds: __task_cred(current) doesn't need rcu_read_lock_held() Oleg Nesterov
2011-09-20 15:07           ` Serge Hallyn
2011-09-20 15:35             ` Oleg Nesterov
2011-09-20 16:19           ` David Howells
2011-09-20 16:38             ` Oleg Nesterov
2011-09-20 16:50               ` David Howells
2011-09-20 17:13                 ` Oleg Nesterov
2011-09-20 15:39   ` [PATCH] user namespace: make signal.c respect user namespaces Serge Hallyn
2011-09-20 16:24     ` Oleg Nesterov
2011-09-20 16:45       ` Serge E. Hallyn
2011-09-20 18:17         ` Oleg Nesterov
2011-09-21  5:00   ` [PATCH] user namespace: make signal.c respect user namespaces (v2) Serge E. Hallyn
2011-09-20 17:48 ` [PATCH] user namespace: make signal.c respect user namespaces Oleg Nesterov
2011-09-20 18:53   ` Serge E. Hallyn
2011-09-21 17:53     ` Oleg Nesterov
2011-09-22 15:23       ` Serge Hallyn
2011-09-23 16:31       ` Serge E. Hallyn
2011-09-23 17:36         ` Oleg Nesterov
2011-09-23 21:20           ` Serge E. Hallyn
2011-09-24 16:37             ` Oleg Nesterov
2011-09-25 20:17               ` Serge E. Hallyn
2011-09-26 16:06                 ` Oleg Nesterov
2011-09-27 14:28                   ` Serge Hallyn [this message]
2011-09-27 14:38                     ` Oleg Nesterov
2011-09-27 15:27                       ` Serge Hallyn
2011-09-27 17:12                         ` Oleg Nesterov
2011-10-04 17:42                   ` Serge E. Hallyn
2011-10-09 19:00                     ` Oleg Nesterov
2011-10-11 13:08                       ` Serge E. Hallyn
2011-10-08 20:02                   ` Serge E. Hallyn
2011-10-09 19:03                     ` Oleg Nesterov

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=20110927142833.GA4876@peqn \
    --to=serge.hallyn@canonical.com \
    --cc=akpm@google.com \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=richard@nod.at \
    --cc=serge@hallyn.com \
    --cc=tj@kernel.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.