• Home
  • Raw
  • Download

Lines Matching refs:msq

130 	struct msg_queue *msq = container_of(p, struct msg_queue, q_perm);  in msg_rcu_free()  local
132 security_msg_queue_free(&msq->q_perm); in msg_rcu_free()
133 kfree(msq); in msg_rcu_free()
145 struct msg_queue *msq; in newque() local
150 msq = kmalloc(sizeof(*msq), GFP_KERNEL_ACCOUNT); in newque()
151 if (unlikely(!msq)) in newque()
154 msq->q_perm.mode = msgflg & S_IRWXUGO; in newque()
155 msq->q_perm.key = key; in newque()
157 msq->q_perm.security = NULL; in newque()
158 retval = security_msg_queue_alloc(&msq->q_perm); in newque()
160 kfree(msq); in newque()
164 msq->q_stime = msq->q_rtime = 0; in newque()
165 msq->q_ctime = ktime_get_real_seconds(); in newque()
166 msq->q_cbytes = msq->q_qnum = 0; in newque()
167 msq->q_qbytes = ns->msg_ctlmnb; in newque()
168 msq->q_lspid = msq->q_lrpid = NULL; in newque()
169 INIT_LIST_HEAD(&msq->q_messages); in newque()
170 INIT_LIST_HEAD(&msq->q_receivers); in newque()
171 INIT_LIST_HEAD(&msq->q_senders); in newque()
174 retval = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni); in newque()
176 ipc_rcu_putref(&msq->q_perm, msg_rcu_free); in newque()
180 ipc_unlock_object(&msq->q_perm); in newque()
183 return msq->q_perm.id; in newque()
186 static inline bool msg_fits_inqueue(struct msg_queue *msq, size_t msgsz) in msg_fits_inqueue() argument
188 return msgsz + msq->q_cbytes <= msq->q_qbytes && in msg_fits_inqueue()
189 1 + msq->q_qnum <= msq->q_qbytes; in msg_fits_inqueue()
192 static inline void ss_add(struct msg_queue *msq, in ss_add() argument
202 list_add_tail(&mss->list, &msq->q_senders); in ss_add()
211 static void ss_wakeup(struct msg_queue *msq, in ss_wakeup() argument
216 struct list_head *h = &msq->q_senders; in ss_wakeup()
236 else if (!msg_fits_inqueue(msq, mss->msgsz)) { in ss_wakeup()
240 list_move_tail(&mss->list, &msq->q_senders); in ss_wakeup()
248 static void expunge_all(struct msg_queue *msq, int res, in expunge_all() argument
253 list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) { in expunge_all()
274 __releases(&msq->q_perm) in freeque()
277 struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); in freeque() local
280 expunge_all(msq, -EIDRM, &wake_q); in freeque()
281 ss_wakeup(msq, &wake_q, true); in freeque()
282 msg_rmid(ns, msq); in freeque()
283 ipc_unlock_object(&msq->q_perm); in freeque()
287 list_for_each_entry_safe(msg, t, &msq->q_messages, m_list) { in freeque()
291 atomic_sub(msq->q_cbytes, &ns->msg_bytes); in freeque()
292 ipc_update_pid(&msq->q_lspid, NULL); in freeque()
293 ipc_update_pid(&msq->q_lrpid, NULL); in freeque()
294 ipc_rcu_putref(&msq->q_perm, msg_rcu_free); in freeque()
404 struct msg_queue *msq; in msgctl_down() local
417 msq = container_of(ipcp, struct msg_queue, q_perm); in msgctl_down()
419 err = security_msg_queue_msgctl(&msq->q_perm, cmd); in msgctl_down()
425 ipc_lock_object(&msq->q_perm); in msgctl_down()
439 ipc_lock_object(&msq->q_perm); in msgctl_down()
444 msq->q_qbytes = msg_qbytes; in msgctl_down()
446 msq->q_ctime = ktime_get_real_seconds(); in msgctl_down()
451 expunge_all(msq, -EAGAIN, &wake_q); in msgctl_down()
456 ss_wakeup(msq, &wake_q, false); in msgctl_down()
457 ipc_unlock_object(&msq->q_perm); in msgctl_down()
468 ipc_unlock_object(&msq->q_perm); in msgctl_down()
515 struct msg_queue *msq; in msgctl_stat() local
522 msq = msq_obtain_object(ns, msqid); in msgctl_stat()
523 if (IS_ERR(msq)) { in msgctl_stat()
524 err = PTR_ERR(msq); in msgctl_stat()
528 msq = msq_obtain_object_check(ns, msqid); in msgctl_stat()
529 if (IS_ERR(msq)) { in msgctl_stat()
530 err = PTR_ERR(msq); in msgctl_stat()
537 audit_ipc_obj(&msq->q_perm); in msgctl_stat()
540 if (ipcperms(ns, &msq->q_perm, S_IRUGO)) in msgctl_stat()
544 err = security_msg_queue_msgctl(&msq->q_perm, cmd); in msgctl_stat()
548 ipc_lock_object(&msq->q_perm); in msgctl_stat()
550 if (!ipc_valid_object(&msq->q_perm)) { in msgctl_stat()
551 ipc_unlock_object(&msq->q_perm); in msgctl_stat()
556 kernel_to_ipc64_perm(&msq->q_perm, &p->msg_perm); in msgctl_stat()
557 p->msg_stime = msq->q_stime; in msgctl_stat()
558 p->msg_rtime = msq->q_rtime; in msgctl_stat()
559 p->msg_ctime = msq->q_ctime; in msgctl_stat()
561 p->msg_stime_high = msq->q_stime >> 32; in msgctl_stat()
562 p->msg_rtime_high = msq->q_rtime >> 32; in msgctl_stat()
563 p->msg_ctime_high = msq->q_ctime >> 32; in msgctl_stat()
565 p->msg_cbytes = msq->q_cbytes; in msgctl_stat()
566 p->msg_qnum = msq->q_qnum; in msgctl_stat()
567 p->msg_qbytes = msq->q_qbytes; in msgctl_stat()
568 p->msg_lspid = pid_vnr(msq->q_lspid); in msgctl_stat()
569 p->msg_lrpid = pid_vnr(msq->q_lrpid); in msgctl_stat()
582 err = msq->q_perm.id; in msgctl_stat()
585 ipc_unlock_object(&msq->q_perm); in msgctl_stat()
810 static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg, in pipelined_send() argument
815 list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) { in pipelined_send()
817 !security_msg_queue_msgrcv(&msq->q_perm, msg, msr->r_tsk, in pipelined_send()
827 ipc_update_pid(&msq->q_lrpid, task_pid(msr->r_tsk)); in pipelined_send()
828 msq->q_rtime = ktime_get_real_seconds(); in pipelined_send()
845 struct msg_queue *msq; in do_msgsnd() local
866 msq = msq_obtain_object_check(ns, msqid); in do_msgsnd()
867 if (IS_ERR(msq)) { in do_msgsnd()
868 err = PTR_ERR(msq); in do_msgsnd()
872 ipc_lock_object(&msq->q_perm); in do_msgsnd()
878 if (ipcperms(ns, &msq->q_perm, S_IWUGO)) in do_msgsnd()
882 if (!ipc_valid_object(&msq->q_perm)) { in do_msgsnd()
887 err = security_msg_queue_msgsnd(&msq->q_perm, msg, msgflg); in do_msgsnd()
891 if (msg_fits_inqueue(msq, msgsz)) in do_msgsnd()
901 ss_add(msq, &s, msgsz); in do_msgsnd()
903 if (!ipc_rcu_getref(&msq->q_perm)) { in do_msgsnd()
908 ipc_unlock_object(&msq->q_perm); in do_msgsnd()
913 ipc_lock_object(&msq->q_perm); in do_msgsnd()
915 ipc_rcu_putref(&msq->q_perm, msg_rcu_free); in do_msgsnd()
917 if (!ipc_valid_object(&msq->q_perm)) { in do_msgsnd()
930 ipc_update_pid(&msq->q_lspid, task_tgid(current)); in do_msgsnd()
931 msq->q_stime = ktime_get_real_seconds(); in do_msgsnd()
933 if (!pipelined_send(msq, msg, &wake_q)) { in do_msgsnd()
935 list_add_tail(&msg->m_list, &msq->q_messages); in do_msgsnd()
936 msq->q_cbytes += msgsz; in do_msgsnd()
937 msq->q_qnum++; in do_msgsnd()
946 ipc_unlock_object(&msq->q_perm); in do_msgsnd()
1068 static struct msg_msg *find_msg(struct msg_queue *msq, long *msgtyp, int mode) in find_msg() argument
1073 list_for_each_entry(msg, &msq->q_messages, m_list) { in find_msg()
1075 !security_msg_queue_msgrcv(&msq->q_perm, msg, current, in find_msg()
1096 struct msg_queue *msq; in do_msgrcv() local
1116 msq = msq_obtain_object_check(ns, msqid); in do_msgrcv()
1117 if (IS_ERR(msq)) { in do_msgrcv()
1120 return PTR_ERR(msq); in do_msgrcv()
1127 if (ipcperms(ns, &msq->q_perm, S_IRUGO)) in do_msgrcv()
1130 ipc_lock_object(&msq->q_perm); in do_msgrcv()
1133 if (!ipc_valid_object(&msq->q_perm)) { in do_msgrcv()
1138 msg = find_msg(msq, &msgtyp, mode); in do_msgrcv()
1158 msq->q_qnum--; in do_msgrcv()
1159 msq->q_rtime = ktime_get_real_seconds(); in do_msgrcv()
1160 ipc_update_pid(&msq->q_lrpid, task_tgid(current)); in do_msgrcv()
1161 msq->q_cbytes -= msg->m_ts; in do_msgrcv()
1164 ss_wakeup(msq, &wake_q, false); in do_msgrcv()
1175 list_add_tail(&msr_d.r_list, &msq->q_receivers); in do_msgrcv()
1190 ipc_unlock_object(&msq->q_perm); in do_msgrcv()
1227 ipc_lock_object(&msq->q_perm); in do_msgrcv()
1239 ipc_unlock_object(&msq->q_perm); in do_msgrcv()
1243 ipc_unlock_object(&msq->q_perm); in do_msgrcv()
1326 struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); in sysvipc_msg_proc_show() local
1330 msq->q_perm.key, in sysvipc_msg_proc_show()
1331 msq->q_perm.id, in sysvipc_msg_proc_show()
1332 msq->q_perm.mode, in sysvipc_msg_proc_show()
1333 msq->q_cbytes, in sysvipc_msg_proc_show()
1334 msq->q_qnum, in sysvipc_msg_proc_show()
1335 pid_nr_ns(msq->q_lspid, pid_ns), in sysvipc_msg_proc_show()
1336 pid_nr_ns(msq->q_lrpid, pid_ns), in sysvipc_msg_proc_show()
1337 from_kuid_munged(user_ns, msq->q_perm.uid), in sysvipc_msg_proc_show()
1338 from_kgid_munged(user_ns, msq->q_perm.gid), in sysvipc_msg_proc_show()
1339 from_kuid_munged(user_ns, msq->q_perm.cuid), in sysvipc_msg_proc_show()
1340 from_kgid_munged(user_ns, msq->q_perm.cgid), in sysvipc_msg_proc_show()
1341 msq->q_stime, in sysvipc_msg_proc_show()
1342 msq->q_rtime, in sysvipc_msg_proc_show()
1343 msq->q_ctime); in sysvipc_msg_proc_show()