Messages in this thread | | | Date | Tue, 20 Sep 2011 10:39:44 -0500 | From | Serge Hallyn <> | Subject | Re: [PATCH] user namespace: make signal.c respect user namespaces |
| |
Quoting Oleg Nesterov (oleg@redhat.com): > On 09/19, Serge E. Hallyn wrote: > > > > __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. > > And all of them follow the same pattern, > > > @@ -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()); > > Up to you, but may be we can add a helper? Something like > > static inline uid_t good_name(struct task_struct *from, struct task_struct *to) > { > // the caller does rcu_read_lock() if needed > const struct cred *from_cred = __task_cred(from); > return user_ns_map_uid(task_cred_xxx(to, user_ns), > from_cred, from_cred->uid); > } > > As for __send_signal() in particular, I guess we could do > > q->info.si_uid = from_ancestor_ns ? 0 : current_uid();
But wait - can't __send_signal end up being triggered through fcntl F_SETSIG+F_SETOWN to another but none-ancestor namespace? So we do actually need to call the full user_ns_map_uid() there. However, the uid sent in ptrace_signal() can (if i'm thinking right) be set using
info->si_uid = (current_user_ns() == parent_user_ns()) ? 0 : current_uid();
Not much of a win performance-wise, but perhaps better by making it clear that those are the only possibilities (and overflowuid is not possible).
thanks, -serge
| |