aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/mqueue.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-11-17 01:57:55 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-04-07 19:55:53 -0400
commit6f9ac6d93a0916de09d11b0a247ade8f4347728b (patch)
tree93e47420422e8e99befd2c14aaab75fa167cbb59 /ipc/mqueue.c
parentaeb3ae9da9b50a386b22af786d19b623e8d9f0fa (diff)
mqueue: Explicitly capture the user namespace to send the notification to.
Stop relying on user->user_ns which is going away and instead capture the user_namespace of the process we are supposed to notify. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'ipc/mqueue.c')
-rw-r--r--ipc/mqueue.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 28bd64ddeda3..b53cf3469d01 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -66,6 +66,7 @@ struct mqueue_inode_info {
66 66
67 struct sigevent notify; 67 struct sigevent notify;
68 struct pid* notify_owner; 68 struct pid* notify_owner;
69 struct user_namespace *notify_user_ns;
69 struct user_struct *user; /* user who created, for accounting */ 70 struct user_struct *user; /* user who created, for accounting */
70 struct sock *notify_sock; 71 struct sock *notify_sock;
71 struct sk_buff *notify_cookie; 72 struct sk_buff *notify_cookie;
@@ -139,6 +140,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
139 INIT_LIST_HEAD(&info->e_wait_q[0].list); 140 INIT_LIST_HEAD(&info->e_wait_q[0].list);
140 INIT_LIST_HEAD(&info->e_wait_q[1].list); 141 INIT_LIST_HEAD(&info->e_wait_q[1].list);
141 info->notify_owner = NULL; 142 info->notify_owner = NULL;
143 info->notify_user_ns = NULL;
142 info->qsize = 0; 144 info->qsize = 0;
143 info->user = NULL; /* set when all is ok */ 145 info->user = NULL; /* set when all is ok */
144 memset(&info->attr, 0, sizeof(info->attr)); 146 memset(&info->attr, 0, sizeof(info->attr));
@@ -536,7 +538,7 @@ static void __do_notify(struct mqueue_inode_info *info)
536 rcu_read_lock(); 538 rcu_read_lock();
537 sig_i.si_pid = task_tgid_nr_ns(current, 539 sig_i.si_pid = task_tgid_nr_ns(current,
538 ns_of_pid(info->notify_owner)); 540 ns_of_pid(info->notify_owner));
539 sig_i.si_uid = user_ns_map_uid(info->user->user_ns, 541 sig_i.si_uid = user_ns_map_uid(info->notify_user_ns,
540 current_cred(), current_uid()); 542 current_cred(), current_uid());
541 rcu_read_unlock(); 543 rcu_read_unlock();
542 544
@@ -550,7 +552,9 @@ static void __do_notify(struct mqueue_inode_info *info)
550 } 552 }
551 /* after notification unregisters process */ 553 /* after notification unregisters process */
552 put_pid(info->notify_owner); 554 put_pid(info->notify_owner);
555 put_user_ns(info->notify_user_ns);
553 info->notify_owner = NULL; 556 info->notify_owner = NULL;
557 info->notify_user_ns = NULL;
554 } 558 }
555 wake_up(&info->wait_q); 559 wake_up(&info->wait_q);
556} 560}
@@ -575,7 +579,9 @@ static void remove_notification(struct mqueue_inode_info *info)
575 netlink_sendskb(info->notify_sock, info->notify_cookie); 579 netlink_sendskb(info->notify_sock, info->notify_cookie);
576 } 580 }
577 put_pid(info->notify_owner); 581 put_pid(info->notify_owner);
582 put_user_ns(info->notify_user_ns);
578 info->notify_owner = NULL; 583 info->notify_owner = NULL;
584 info->notify_user_ns = NULL;
579} 585}
580 586
581static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr) 587static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
@@ -1140,6 +1146,7 @@ retry:
1140 } 1146 }
1141 1147
1142 info->notify_owner = get_pid(task_tgid(current)); 1148 info->notify_owner = get_pid(task_tgid(current));
1149 info->notify_user_ns = get_user_ns(current_user_ns());
1143 inode->i_atime = inode->i_ctime = CURRENT_TIME; 1150 inode->i_atime = inode->i_ctime = CURRENT_TIME;
1144 } 1151 }
1145 spin_unlock(&info->lock); 1152 spin_unlock(&info->lock);