All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] user namespace: make signal.c respect user namespaces
@ 2011-09-19 21:45 Serge E. Hallyn
  2011-09-19 21:47 ` [PATCH] user namespace: usb: make usb urbs user namespace aware Serge E. Hallyn
                   ` (2 more replies)
  0 siblings, 3 replies; 63+ messages in thread
From: Serge E. Hallyn @ 2011-09-19 21:45 UTC (permalink / raw)
  To: lkml
  Cc: richard, Andrew Morton, Oleg Nesterov, Eric W. Biederman,
	Tejun Heo, serge, serge.hallyn

__send_signal: convert the uid being sent in SI_USER to the target task's
user namespace.

do_notify_parent and do_notify_parent_cldstop: map task's uid to parent's
 user namespace

ptrace_signal: map parent's uid into current's user namespace before
including in signal to current.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Tejun Heo <tj@kernel.org>
---
 kernel/signal.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index 291c970..bb8ce03 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -27,6 +27,7 @@
 #include <linux/capability.h>
 #include <linux/freezer.h>
 #include <linux/pid_namespace.h>
+#include <linux/user_namespace.h>
 #include <linux/nsproxy.h>
 #define CREATE_TRACE_POINTS
 #include <trace/events/signal.h>
@@ -1073,7 +1074,8 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
 			q->info.si_code = SI_USER;
 			q->info.si_pid = task_tgid_nr_ns(current,
 							task_active_pid_ns(t));
-			q->info.si_uid = current_uid();
+			q->info.si_uid = user_ns_map_uid(task_cred_xxx(t, user_ns),
+					current_cred(), current_uid());
 			break;
 		case (unsigned long) SEND_SIG_PRIV:
 			q->info.si_signo = sig;
@@ -1618,7 +1620,8 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
 	 */
 	rcu_read_lock();
 	info.si_pid = task_pid_nr_ns(tsk, tsk->parent->nsproxy->pid_ns);
-	info.si_uid = __task_cred(tsk)->uid;
+	info.si_uid = user_ns_map_uid(task_cred_xxx(tsk->parent, user_ns),
+				      __task_cred(tsk), __task_cred(tsk)->uid);
 	rcu_read_unlock();
 
 	info.si_utime = cputime_to_clock_t(cputime_add(tsk->utime,
@@ -1688,6 +1691,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
 	unsigned long flags;
 	struct task_struct *parent;
 	struct sighand_struct *sighand;
+	const struct cred *cred;
 
 	if (for_ptracer) {
 		parent = tsk->parent;
@@ -1703,7 +1707,9 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
 	 */
 	rcu_read_lock();
 	info.si_pid = task_pid_nr_ns(tsk, parent->nsproxy->pid_ns);
-	info.si_uid = __task_cred(tsk)->uid;
+	cred = __task_cred(tsk);
+	info.si_uid = user_ns_map_uid(task_cred_xxx(parent, user_ns),
+				cred, cred->uid);
 	rcu_read_unlock();
 
 	info.si_utime = cputime_to_clock_t(tsk->utime);
@@ -2118,11 +2124,16 @@ static int ptrace_signal(int signr, siginfo_t *info,
 	 * have updated *info via PTRACE_SETSIGINFO.
 	 */
 	if (signr != info->si_signo) {
+		const struct cred *pcred;
 		info->si_signo = signr;
 		info->si_errno = 0;
 		info->si_code = SI_USER;
 		info->si_pid = task_pid_vnr(current->parent);
-		info->si_uid = task_uid(current->parent);
+		rcu_read_lock();
+		pcred = __task_cred(current->parent);
+		info->si_uid = user_ns_map_uid(current_user_ns(),
+			pcred, pcred->uid);
+		rcu_read_unlock();
 	}
 
 	/* If the (new) signal is now blocked, requeue it.  */
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 63+ messages in thread

end of thread, other threads:[~2012-04-02  8:11 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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 16:27         ` [PATCH 1/2] creds: kill __task_cred()->task_is_dead() check David Howells
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
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

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.