Lines Matching refs:msq
131 struct msg_queue *msq = container_of(p, struct msg_queue, q_perm); in msg_rcu_free() local
133 security_msg_queue_free(&msq->q_perm); in msg_rcu_free()
134 kfree(msq); in msg_rcu_free()
146 struct msg_queue *msq; in newque() local
151 msq = kmalloc(sizeof(*msq), GFP_KERNEL_ACCOUNT); in newque()
152 if (unlikely(!msq)) in newque()
155 msq->q_perm.mode = msgflg & S_IRWXUGO; in newque()
156 msq->q_perm.key = key; in newque()
158 msq->q_perm.security = NULL; in newque()
159 retval = security_msg_queue_alloc(&msq->q_perm); in newque()
161 kfree(msq); in newque()
165 msq->q_stime = msq->q_rtime = 0; in newque()
166 msq->q_ctime = ktime_get_real_seconds(); in newque()
167 msq->q_cbytes = msq->q_qnum = 0; in newque()
168 msq->q_qbytes = ns->msg_ctlmnb; in newque()
169 msq->q_lspid = msq->q_lrpid = NULL; in newque()
170 INIT_LIST_HEAD(&msq->q_messages); in newque()
171 INIT_LIST_HEAD(&msq->q_receivers); in newque()
172 INIT_LIST_HEAD(&msq->q_senders); in newque()
175 retval = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni); in newque()
177 ipc_rcu_putref(&msq->q_perm, msg_rcu_free); in newque()
181 ipc_unlock_object(&msq->q_perm); in newque()
184 return msq->q_perm.id; in newque()
187 static inline bool msg_fits_inqueue(struct msg_queue *msq, size_t msgsz) in msg_fits_inqueue() argument
189 return msgsz + msq->q_cbytes <= msq->q_qbytes && in msg_fits_inqueue()
190 1 + msq->q_qnum <= msq->q_qbytes; in msg_fits_inqueue()
193 static inline void ss_add(struct msg_queue *msq, in ss_add() argument
203 list_add_tail(&mss->list, &msq->q_senders); in ss_add()
212 static void ss_wakeup(struct msg_queue *msq, in ss_wakeup() argument
217 struct list_head *h = &msq->q_senders; in ss_wakeup()
237 else if (!msg_fits_inqueue(msq, mss->msgsz)) { in ss_wakeup()
241 list_move_tail(&mss->list, &msq->q_senders); in ss_wakeup()
249 static void expunge_all(struct msg_queue *msq, int res, in expunge_all() argument
254 list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) { in expunge_all()
275 __releases(&msq->q_perm) in freeque()
278 struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); in freeque() local
281 expunge_all(msq, -EIDRM, &wake_q); in freeque()
282 ss_wakeup(msq, &wake_q, true); in freeque()
283 msg_rmid(ns, msq); in freeque()
284 ipc_unlock_object(&msq->q_perm); in freeque()
288 list_for_each_entry_safe(msg, t, &msq->q_messages, m_list) { in freeque()
292 percpu_counter_sub_local(&ns->percpu_msg_bytes, msq->q_cbytes); in freeque()
293 ipc_update_pid(&msq->q_lspid, NULL); in freeque()
294 ipc_update_pid(&msq->q_lrpid, NULL); in freeque()
295 ipc_rcu_putref(&msq->q_perm, msg_rcu_free); in freeque()
405 struct msg_queue *msq; in msgctl_down() local
418 msq = container_of(ipcp, struct msg_queue, q_perm); in msgctl_down()
420 err = security_msg_queue_msgctl(&msq->q_perm, cmd); in msgctl_down()
426 ipc_lock_object(&msq->q_perm); in msgctl_down()
440 ipc_lock_object(&msq->q_perm); in msgctl_down()
445 msq->q_qbytes = msg_qbytes; in msgctl_down()
447 msq->q_ctime = ktime_get_real_seconds(); in msgctl_down()
452 expunge_all(msq, -EAGAIN, &wake_q); in msgctl_down()
457 ss_wakeup(msq, &wake_q, false); in msgctl_down()
458 ipc_unlock_object(&msq->q_perm); in msgctl_down()
469 ipc_unlock_object(&msq->q_perm); in msgctl_down()
521 struct msg_queue *msq; in msgctl_stat() local
528 msq = msq_obtain_object(ns, msqid); in msgctl_stat()
529 if (IS_ERR(msq)) { in msgctl_stat()
530 err = PTR_ERR(msq); in msgctl_stat()
534 msq = msq_obtain_object_check(ns, msqid); in msgctl_stat()
535 if (IS_ERR(msq)) { in msgctl_stat()
536 err = PTR_ERR(msq); in msgctl_stat()
543 audit_ipc_obj(&msq->q_perm); in msgctl_stat()
546 if (ipcperms(ns, &msq->q_perm, S_IRUGO)) in msgctl_stat()
550 err = security_msg_queue_msgctl(&msq->q_perm, cmd); in msgctl_stat()
554 ipc_lock_object(&msq->q_perm); in msgctl_stat()
556 if (!ipc_valid_object(&msq->q_perm)) { in msgctl_stat()
557 ipc_unlock_object(&msq->q_perm); in msgctl_stat()
562 kernel_to_ipc64_perm(&msq->q_perm, &p->msg_perm); in msgctl_stat()
563 p->msg_stime = msq->q_stime; in msgctl_stat()
564 p->msg_rtime = msq->q_rtime; in msgctl_stat()
565 p->msg_ctime = msq->q_ctime; in msgctl_stat()
567 p->msg_stime_high = msq->q_stime >> 32; in msgctl_stat()
568 p->msg_rtime_high = msq->q_rtime >> 32; in msgctl_stat()
569 p->msg_ctime_high = msq->q_ctime >> 32; in msgctl_stat()
571 p->msg_cbytes = msq->q_cbytes; in msgctl_stat()
572 p->msg_qnum = msq->q_qnum; in msgctl_stat()
573 p->msg_qbytes = msq->q_qbytes; in msgctl_stat()
574 p->msg_lspid = pid_vnr(msq->q_lspid); in msgctl_stat()
575 p->msg_lrpid = pid_vnr(msq->q_lrpid); in msgctl_stat()
588 err = msq->q_perm.id; in msgctl_stat()
591 ipc_unlock_object(&msq->q_perm); in msgctl_stat()
816 static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg, in pipelined_send() argument
821 list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) { in pipelined_send()
823 !security_msg_queue_msgrcv(&msq->q_perm, msg, msr->r_tsk, in pipelined_send()
833 ipc_update_pid(&msq->q_lrpid, task_pid(msr->r_tsk)); in pipelined_send()
834 msq->q_rtime = ktime_get_real_seconds(); in pipelined_send()
851 struct msg_queue *msq; in do_msgsnd() local
872 msq = msq_obtain_object_check(ns, msqid); in do_msgsnd()
873 if (IS_ERR(msq)) { in do_msgsnd()
874 err = PTR_ERR(msq); in do_msgsnd()
878 ipc_lock_object(&msq->q_perm); in do_msgsnd()
884 if (ipcperms(ns, &msq->q_perm, S_IWUGO)) in do_msgsnd()
888 if (!ipc_valid_object(&msq->q_perm)) { in do_msgsnd()
893 err = security_msg_queue_msgsnd(&msq->q_perm, msg, msgflg); in do_msgsnd()
897 if (msg_fits_inqueue(msq, msgsz)) in do_msgsnd()
907 ss_add(msq, &s, msgsz); in do_msgsnd()
909 if (!ipc_rcu_getref(&msq->q_perm)) { in do_msgsnd()
914 ipc_unlock_object(&msq->q_perm); in do_msgsnd()
919 ipc_lock_object(&msq->q_perm); in do_msgsnd()
921 ipc_rcu_putref(&msq->q_perm, msg_rcu_free); in do_msgsnd()
923 if (!ipc_valid_object(&msq->q_perm)) { in do_msgsnd()
936 ipc_update_pid(&msq->q_lspid, task_tgid(current)); in do_msgsnd()
937 msq->q_stime = ktime_get_real_seconds(); in do_msgsnd()
939 if (!pipelined_send(msq, msg, &wake_q)) { in do_msgsnd()
941 list_add_tail(&msg->m_list, &msq->q_messages); in do_msgsnd()
942 msq->q_cbytes += msgsz; in do_msgsnd()
943 msq->q_qnum++; in do_msgsnd()
952 ipc_unlock_object(&msq->q_perm); in do_msgsnd()
1074 static struct msg_msg *find_msg(struct msg_queue *msq, long *msgtyp, int mode) in find_msg() argument
1079 list_for_each_entry(msg, &msq->q_messages, m_list) { in find_msg()
1081 !security_msg_queue_msgrcv(&msq->q_perm, msg, current, in find_msg()
1102 struct msg_queue *msq; in do_msgrcv() local
1122 msq = msq_obtain_object_check(ns, msqid); in do_msgrcv()
1123 if (IS_ERR(msq)) { in do_msgrcv()
1126 return PTR_ERR(msq); in do_msgrcv()
1133 if (ipcperms(ns, &msq->q_perm, S_IRUGO)) in do_msgrcv()
1136 ipc_lock_object(&msq->q_perm); in do_msgrcv()
1139 if (!ipc_valid_object(&msq->q_perm)) { in do_msgrcv()
1144 msg = find_msg(msq, &msgtyp, mode); in do_msgrcv()
1164 msq->q_qnum--; in do_msgrcv()
1165 msq->q_rtime = ktime_get_real_seconds(); in do_msgrcv()
1166 ipc_update_pid(&msq->q_lrpid, task_tgid(current)); in do_msgrcv()
1167 msq->q_cbytes -= msg->m_ts; in do_msgrcv()
1170 ss_wakeup(msq, &wake_q, false); in do_msgrcv()
1181 list_add_tail(&msr_d.r_list, &msq->q_receivers); in do_msgrcv()
1196 ipc_unlock_object(&msq->q_perm); in do_msgrcv()
1233 ipc_lock_object(&msq->q_perm); in do_msgrcv()
1245 ipc_unlock_object(&msq->q_perm); in do_msgrcv()
1249 ipc_unlock_object(&msq->q_perm); in do_msgrcv()
1346 struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); in sysvipc_msg_proc_show() local
1350 msq->q_perm.key, in sysvipc_msg_proc_show()
1351 msq->q_perm.id, in sysvipc_msg_proc_show()
1352 msq->q_perm.mode, in sysvipc_msg_proc_show()
1353 msq->q_cbytes, in sysvipc_msg_proc_show()
1354 msq->q_qnum, in sysvipc_msg_proc_show()
1355 pid_nr_ns(msq->q_lspid, pid_ns), in sysvipc_msg_proc_show()
1356 pid_nr_ns(msq->q_lrpid, pid_ns), in sysvipc_msg_proc_show()
1357 from_kuid_munged(user_ns, msq->q_perm.uid), in sysvipc_msg_proc_show()
1358 from_kgid_munged(user_ns, msq->q_perm.gid), in sysvipc_msg_proc_show()
1359 from_kuid_munged(user_ns, msq->q_perm.cuid), in sysvipc_msg_proc_show()
1360 from_kgid_munged(user_ns, msq->q_perm.cgid), in sysvipc_msg_proc_show()
1361 msq->q_stime, in sysvipc_msg_proc_show()
1362 msq->q_rtime, in sysvipc_msg_proc_show()
1363 msq->q_ctime); in sysvipc_msg_proc_show()