Skip to content

Commit 6f9ac6d

Browse files
committed
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 <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent aeb3ae9 commit 6f9ac6d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ipc/mqueue.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ struct mqueue_inode_info {
6666

6767
struct sigevent notify;
6868
struct pid* notify_owner;
69+
struct user_namespace *notify_user_ns;
6970
struct user_struct *user; /* user who created, for accounting */
7071
struct sock *notify_sock;
7172
struct sk_buff *notify_cookie;
@@ -139,6 +140,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
139140
INIT_LIST_HEAD(&info->e_wait_q[0].list);
140141
INIT_LIST_HEAD(&info->e_wait_q[1].list);
141142
info->notify_owner = NULL;
143+
info->notify_user_ns = NULL;
142144
info->qsize = 0;
143145
info->user = NULL; /* set when all is ok */
144146
memset(&info->attr, 0, sizeof(info->attr));
@@ -536,7 +538,7 @@ static void __do_notify(struct mqueue_inode_info *info)
536538
rcu_read_lock();
537539
sig_i.si_pid = task_tgid_nr_ns(current,
538540
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,
540542
current_cred(), current_uid());
541543
rcu_read_unlock();
542544

@@ -550,7 +552,9 @@ static void __do_notify(struct mqueue_inode_info *info)
550552
}
551553
/* after notification unregisters process */
552554
put_pid(info->notify_owner);
555+
put_user_ns(info->notify_user_ns);
553556
info->notify_owner = NULL;
557+
info->notify_user_ns = NULL;
554558
}
555559
wake_up(&info->wait_q);
556560
}
@@ -575,7 +579,9 @@ static void remove_notification(struct mqueue_inode_info *info)
575579
netlink_sendskb(info->notify_sock, info->notify_cookie);
576580
}
577581
put_pid(info->notify_owner);
582+
put_user_ns(info->notify_user_ns);
578583
info->notify_owner = NULL;
584+
info->notify_user_ns = NULL;
579585
}
580586

581587
static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
@@ -1140,6 +1146,7 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
11401146
}
11411147

11421148
info->notify_owner = get_pid(task_tgid(current));
1149+
info->notify_user_ns = get_user_ns(current_user_ns());
11431150
inode->i_atime = inode->i_ctime = CURRENT_TIME;
11441151
}
11451152
spin_unlock(&info->lock);

0 commit comments

Comments
 (0)