Blame view
ipc/msg.c
23.5 KB
1da177e4c
|
1 2 |
/* * linux/ipc/msg.c |
5a06a363e
|
3 |
* Copyright (C) 1992 Krishna Balasubramanian |
1da177e4c
|
4 5 6 7 8 9 10 11 12 13 14 |
* * Removed all the remaining kerneld mess * Catch the -EFAULT stuff properly * Use GFP_KERNEL for messages as in 1.2 * Fixed up the unchecked user space derefs * Copyright (C) 1998 Alan Cox & Andi Kleen * * /proc/sysvipc/msg support (c) 1999 Dragos Acostachioaie <dragos@iname.com> * * mostly rewritten, threaded and wake-one semantics added * MSGMAX limit removed, sysctl's added |
624dffcbc
|
15 |
* (c) 1999 Manfred Spraul <manfred@colorfullife.com> |
073115d6b
|
16 17 18 |
* * support for audit of ipc object properties and permission changes * Dustin Kirkland <dustin.kirkland@us.ibm.com> |
1e7869373
|
19 20 21 22 |
* * namespaces support * OpenVZ, SWsoft Inc. * Pavel Emelianov <xemul@openvz.org> |
1da177e4c
|
23 |
*/ |
c59ede7b7
|
24 |
#include <linux/capability.h> |
1da177e4c
|
25 26 27 |
#include <linux/msg.h> #include <linux/spinlock.h> #include <linux/init.h> |
f7bf3df8b
|
28 |
#include <linux/mm.h> |
1da177e4c
|
29 30 31 32 33 34 |
#include <linux/proc_fs.h> #include <linux/list.h> #include <linux/security.h> #include <linux/sched.h> #include <linux/syscalls.h> #include <linux/audit.h> |
19b4946ca
|
35 |
#include <linux/seq_file.h> |
3e148c799
|
36 |
#include <linux/rwsem.h> |
1e7869373
|
37 |
#include <linux/nsproxy.h> |
ae5e1b22f
|
38 |
#include <linux/ipc_namespace.h> |
5f921ae96
|
39 |
|
1da177e4c
|
40 |
#include <asm/current.h> |
7153e4027
|
41 |
#include <linux/uaccess.h> |
1da177e4c
|
42 |
#include "util.h" |
4bb6657dd
|
43 |
/* one msg_receiver structure for each sleeping receiver */ |
1da177e4c
|
44 |
struct msg_receiver { |
5a06a363e
|
45 46 |
struct list_head r_list; struct task_struct *r_tsk; |
1da177e4c
|
47 |
|
5a06a363e
|
48 49 50 |
int r_mode; long r_msgtype; long r_maxsize; |
1da177e4c
|
51 |
|
ee51636ca
|
52 |
struct msg_msg *r_msg; |
1da177e4c
|
53 54 55 56 |
}; /* one msg_sender for each sleeping sender */ struct msg_sender { |
5a06a363e
|
57 58 |
struct list_head list; struct task_struct *tsk; |
ed27f9122
|
59 |
size_t msgsz; |
1da177e4c
|
60 61 62 63 64 65 |
}; #define SEARCH_ANY 1 #define SEARCH_EQUAL 2 #define SEARCH_NOTEQUAL 3 #define SEARCH_LESSEQUAL 4 |
8ac6ed585
|
66 |
#define SEARCH_NUMBER 5 |
1da177e4c
|
67 |
|
ed2ddbf88
|
68 |
#define msg_ids(ns) ((ns)->ids[IPC_MSG_IDS]) |
1da177e4c
|
69 |
|
a5001a0d9
|
70 71 |
static inline struct msg_queue *msq_obtain_object(struct ipc_namespace *ns, int id) { |
55b7ae501
|
72 |
struct kern_ipc_perm *ipcp = ipc_obtain_object_idr(&msg_ids(ns), id); |
a5001a0d9
|
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
if (IS_ERR(ipcp)) return ERR_CAST(ipcp); return container_of(ipcp, struct msg_queue, q_perm); } static inline struct msg_queue *msq_obtain_object_check(struct ipc_namespace *ns, int id) { struct kern_ipc_perm *ipcp = ipc_obtain_object_check(&msg_ids(ns), id); if (IS_ERR(ipcp)) return ERR_CAST(ipcp); return container_of(ipcp, struct msg_queue, q_perm); } |
7ca7e564e
|
90 91 92 93 |
static inline void msg_rmid(struct ipc_namespace *ns, struct msg_queue *s) { ipc_rmid(&msg_ids(ns), &s->q_perm); } |
53dad6d3a
|
94 95 96 97 98 99 100 101 |
static void msg_rcu_free(struct rcu_head *head) { struct ipc_rcu *p = container_of(head, struct ipc_rcu, rcu); struct msg_queue *msq = ipc_rcu_to_struct(p); security_msg_queue_free(msq); ipc_rcu_free(head); } |
f4566f048
|
102 103 104 105 106 |
/** * newque - Create a new msg queue * @ns: namespace * @params: ptr to the structure that contains the key and msgflg * |
d9a605e40
|
107 |
* Called with msg_ids.rwsem held (writer) |
f4566f048
|
108 |
*/ |
7748dbfaa
|
109 |
static int newque(struct ipc_namespace *ns, struct ipc_params *params) |
1da177e4c
|
110 |
{ |
1da177e4c
|
111 |
struct msg_queue *msq; |
5a06a363e
|
112 |
int id, retval; |
7748dbfaa
|
113 114 |
key_t key = params->key; int msgflg = params->flg; |
1da177e4c
|
115 |
|
5a06a363e
|
116 117 |
msq = ipc_rcu_alloc(sizeof(*msq)); if (!msq) |
1da177e4c
|
118 |
return -ENOMEM; |
5a06a363e
|
119 |
msq->q_perm.mode = msgflg & S_IRWXUGO; |
1da177e4c
|
120 121 122 123 124 |
msq->q_perm.key = key; msq->q_perm.security = NULL; retval = security_msg_queue_alloc(msq); if (retval) { |
53dad6d3a
|
125 |
ipc_rcu_putref(msq, ipc_rcu_free); |
1da177e4c
|
126 127 |
return retval; } |
1da177e4c
|
128 129 130 |
msq->q_stime = msq->q_rtime = 0; msq->q_ctime = get_seconds(); msq->q_cbytes = msq->q_qnum = 0; |
1e7869373
|
131 |
msq->q_qbytes = ns->msg_ctlmnb; |
1da177e4c
|
132 133 134 135 |
msq->q_lspid = msq->q_lrpid = 0; INIT_LIST_HEAD(&msq->q_messages); INIT_LIST_HEAD(&msq->q_receivers); INIT_LIST_HEAD(&msq->q_senders); |
7ca7e564e
|
136 |
|
b9a532277
|
137 138 139 140 141 142 |
/* ipc_addid() locks msq upon success. */ id = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni); if (id < 0) { ipc_rcu_putref(msq, msg_rcu_free); return id; } |
cf9d5d78d
|
143 |
ipc_unlock_object(&msq->q_perm); |
dbfcd91f0
|
144 |
rcu_read_unlock(); |
1da177e4c
|
145 |
|
7ca7e564e
|
146 |
return msq->q_perm.id; |
1da177e4c
|
147 |
} |
ed27f9122
|
148 149 150 151 152 153 154 155 |
static inline bool msg_fits_inqueue(struct msg_queue *msq, size_t msgsz) { return msgsz + msq->q_cbytes <= msq->q_qbytes && 1 + msq->q_qnum <= msq->q_qbytes; } static inline void ss_add(struct msg_queue *msq, struct msg_sender *mss, size_t msgsz) |
1da177e4c
|
156 |
{ |
5a06a363e
|
157 |
mss->tsk = current; |
ed27f9122
|
158 |
mss->msgsz = msgsz; |
f75a2f358
|
159 |
__set_current_state(TASK_INTERRUPTIBLE); |
5a06a363e
|
160 |
list_add_tail(&mss->list, &msq->q_senders); |
1da177e4c
|
161 |
} |
5a06a363e
|
162 |
static inline void ss_del(struct msg_sender *mss) |
1da177e4c
|
163 |
{ |
ed27f9122
|
164 |
if (mss->list.next) |
1da177e4c
|
165 166 |
list_del(&mss->list); } |
ed27f9122
|
167 |
static void ss_wakeup(struct msg_queue *msq, |
d0d6a2a95
|
168 |
struct wake_q_head *wake_q, bool kill) |
1da177e4c
|
169 |
{ |
41239fe82
|
170 |
struct msg_sender *mss, *t; |
ed27f9122
|
171 172 |
struct task_struct *stop_tsk = NULL; struct list_head *h = &msq->q_senders; |
1da177e4c
|
173 |
|
41239fe82
|
174 |
list_for_each_entry_safe(mss, t, h, list) { |
5a06a363e
|
175 176 |
if (kill) mss->list.next = NULL; |
ed27f9122
|
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
/* * Stop at the first task we don't wakeup, * we've already iterated the original * sender queue. */ else if (stop_tsk == mss->tsk) break; /* * We are not in an EIDRM scenario here, therefore * verify that we really need to wakeup the task. * To maintain current semantics and wakeup order, * move the sender to the tail on behalf of the * blocked task. */ else if (!msg_fits_inqueue(msq, mss->msgsz)) { if (!stop_tsk) stop_tsk = mss->tsk; list_move_tail(&mss->list, &msq->q_senders); continue; } |
e3658538b
|
199 |
wake_q_add(wake_q, mss->tsk); |
1da177e4c
|
200 201 |
} } |
ee51636ca
|
202 203 |
static void expunge_all(struct msg_queue *msq, int res, struct wake_q_head *wake_q) |
1da177e4c
|
204 |
{ |
41239fe82
|
205 |
struct msg_receiver *msr, *t; |
5a06a363e
|
206 |
|
41239fe82
|
207 |
list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) { |
ee51636ca
|
208 209 |
wake_q_add(wake_q, msr->r_tsk); WRITE_ONCE(msr->r_msg, ERR_PTR(res)); |
1da177e4c
|
210 211 |
} } |
5a06a363e
|
212 213 214 |
/* * freeque() wakes up waiters on the sender and receiver waiting queue, |
f4566f048
|
215 216 |
* removes the message queue from message queue ID IDR, and cleans up all the * messages associated with this queue. |
1da177e4c
|
217 |
* |
d9a605e40
|
218 219 |
* msg_ids.rwsem (writer) and the spinlock for this message queue are held * before freeque() is called. msg_ids.rwsem remains locked on exit. |
1da177e4c
|
220 |
*/ |
01b8b07a5
|
221 |
static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) |
1da177e4c
|
222 |
{ |
41239fe82
|
223 |
struct msg_msg *msg, *t; |
01b8b07a5
|
224 |
struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); |
194a6b5b9
|
225 |
DEFINE_WAKE_Q(wake_q); |
1da177e4c
|
226 |
|
ee51636ca
|
227 |
expunge_all(msq, -EIDRM, &wake_q); |
ed27f9122
|
228 |
ss_wakeup(msq, &wake_q, true); |
7ca7e564e
|
229 |
msg_rmid(ns, msq); |
4718787d1
|
230 |
ipc_unlock_object(&msq->q_perm); |
ee51636ca
|
231 |
wake_up_q(&wake_q); |
4718787d1
|
232 |
rcu_read_unlock(); |
5a06a363e
|
233 |
|
41239fe82
|
234 |
list_for_each_entry_safe(msg, t, &msq->q_messages, m_list) { |
3ac88a41f
|
235 |
atomic_dec(&ns->msg_hdrs); |
1da177e4c
|
236 237 |
free_msg(msg); } |
3ac88a41f
|
238 |
atomic_sub(msq->q_cbytes, &ns->msg_bytes); |
53dad6d3a
|
239 |
ipc_rcu_putref(msq, msg_rcu_free); |
1da177e4c
|
240 |
} |
f4566f048
|
241 |
/* |
d9a605e40
|
242 |
* Called with msg_ids.rwsem and ipcp locked. |
f4566f048
|
243 |
*/ |
03f02c765
|
244 |
static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg) |
7748dbfaa
|
245 |
{ |
03f02c765
|
246 247 248 |
struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); return security_msg_queue_associate(msq, msgflg); |
7748dbfaa
|
249 |
} |
e48fbb699
|
250 |
SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg) |
1da177e4c
|
251 |
{ |
1e7869373
|
252 |
struct ipc_namespace *ns; |
eb66ec44f
|
253 254 255 256 |
static const struct ipc_ops msg_ops = { .getnew = newque, .associate = msg_security, }; |
7748dbfaa
|
257 |
struct ipc_params msg_params; |
1e7869373
|
258 259 |
ns = current->nsproxy->ipc_ns; |
7ca7e564e
|
260 |
|
7748dbfaa
|
261 262 |
msg_params.key = key; msg_params.flg = msgflg; |
5a06a363e
|
263 |
|
7748dbfaa
|
264 |
return ipcget(ns, &msg_ids(ns), &msg_ops, &msg_params); |
1da177e4c
|
265 |
} |
5a06a363e
|
266 267 |
static inline unsigned long copy_msqid_to_user(void __user *buf, struct msqid64_ds *in, int version) |
1da177e4c
|
268 |
{ |
239521f31
|
269 |
switch (version) { |
1da177e4c
|
270 |
case IPC_64: |
5a06a363e
|
271 |
return copy_to_user(buf, in, sizeof(*in)); |
1da177e4c
|
272 |
case IPC_OLD: |
5a06a363e
|
273 |
{ |
1da177e4c
|
274 |
struct msqid_ds out; |
5a06a363e
|
275 |
memset(&out, 0, sizeof(out)); |
1da177e4c
|
276 277 278 279 280 281 |
ipc64_perm_to_ipc_perm(&in->msg_perm, &out.msg_perm); out.msg_stime = in->msg_stime; out.msg_rtime = in->msg_rtime; out.msg_ctime = in->msg_ctime; |
4be929be3
|
282 283 |
if (in->msg_cbytes > USHRT_MAX) out.msg_cbytes = USHRT_MAX; |
1da177e4c
|
284 285 286 |
else out.msg_cbytes = in->msg_cbytes; out.msg_lcbytes = in->msg_cbytes; |
4be929be3
|
287 288 |
if (in->msg_qnum > USHRT_MAX) out.msg_qnum = USHRT_MAX; |
1da177e4c
|
289 290 |
else out.msg_qnum = in->msg_qnum; |
4be929be3
|
291 292 |
if (in->msg_qbytes > USHRT_MAX) out.msg_qbytes = USHRT_MAX; |
1da177e4c
|
293 294 295 296 297 298 |
else out.msg_qbytes = in->msg_qbytes; out.msg_lqbytes = in->msg_qbytes; out.msg_lspid = in->msg_lspid; out.msg_lrpid = in->msg_lrpid; |
5a06a363e
|
299 300 |
return copy_to_user(buf, &out, sizeof(out)); } |
1da177e4c
|
301 302 303 304 |
default: return -EINVAL; } } |
5a06a363e
|
305 |
static inline unsigned long |
016d7132f
|
306 |
copy_msqid_from_user(struct msqid64_ds *out, void __user *buf, int version) |
1da177e4c
|
307 |
{ |
239521f31
|
308 |
switch (version) { |
1da177e4c
|
309 |
case IPC_64: |
016d7132f
|
310 |
if (copy_from_user(out, buf, sizeof(*out))) |
1da177e4c
|
311 |
return -EFAULT; |
1da177e4c
|
312 |
return 0; |
1da177e4c
|
313 |
case IPC_OLD: |
5a06a363e
|
314 |
{ |
1da177e4c
|
315 |
struct msqid_ds tbuf_old; |
5a06a363e
|
316 |
if (copy_from_user(&tbuf_old, buf, sizeof(tbuf_old))) |
1da177e4c
|
317 |
return -EFAULT; |
239521f31
|
318 319 320 |
out->msg_perm.uid = tbuf_old.msg_perm.uid; out->msg_perm.gid = tbuf_old.msg_perm.gid; out->msg_perm.mode = tbuf_old.msg_perm.mode; |
1da177e4c
|
321 |
|
5a06a363e
|
322 |
if (tbuf_old.msg_qbytes == 0) |
016d7132f
|
323 |
out->msg_qbytes = tbuf_old.msg_lqbytes; |
1da177e4c
|
324 |
else |
016d7132f
|
325 |
out->msg_qbytes = tbuf_old.msg_qbytes; |
1da177e4c
|
326 327 |
return 0; |
5a06a363e
|
328 |
} |
1da177e4c
|
329 330 331 332 |
default: return -EINVAL; } } |
a0d092fc2
|
333 |
/* |
d9a605e40
|
334 |
* This function handles some msgctl commands which require the rwsem |
a0d092fc2
|
335 |
* to be held in write mode. |
d9a605e40
|
336 |
* NOTE: no locks must be held, the rwsem is taken inside this function. |
a0d092fc2
|
337 338 339 |
*/ static int msgctl_down(struct ipc_namespace *ns, int msqid, int cmd, struct msqid_ds __user *buf, int version) |
1da177e4c
|
340 |
{ |
1da177e4c
|
341 |
struct kern_ipc_perm *ipcp; |
f1970c48e
|
342 |
struct msqid64_ds uninitialized_var(msqid64); |
a0d092fc2
|
343 344 345 346 |
struct msg_queue *msq; int err; if (cmd == IPC_SET) { |
016d7132f
|
347 |
if (copy_msqid_from_user(&msqid64, buf, version)) |
a0d092fc2
|
348 349 |
return -EFAULT; } |
d9a605e40
|
350 |
down_write(&msg_ids(ns).rwsem); |
7b4cc5d84
|
351 |
rcu_read_lock(); |
15724ecb7
|
352 353 |
ipcp = ipcctl_pre_down_nolock(ns, &msg_ids(ns), msqid, cmd, &msqid64.msg_perm, msqid64.msg_qbytes); |
7b4cc5d84
|
354 355 |
if (IS_ERR(ipcp)) { err = PTR_ERR(ipcp); |
7b4cc5d84
|
356 357 |
goto out_unlock1; } |
a0d092fc2
|
358 |
|
a5f75e7f2
|
359 |
msq = container_of(ipcp, struct msg_queue, q_perm); |
a0d092fc2
|
360 361 362 |
err = security_msg_queue_msgctl(msq, cmd); if (err) |
15724ecb7
|
363 |
goto out_unlock1; |
a0d092fc2
|
364 365 366 |
switch (cmd) { case IPC_RMID: |
15724ecb7
|
367 |
ipc_lock_object(&msq->q_perm); |
7b4cc5d84
|
368 |
/* freeque unlocks the ipc object and rcu */ |
a0d092fc2
|
369 370 371 |
freeque(ns, ipcp); goto out_up; case IPC_SET: |
e3658538b
|
372 |
{ |
194a6b5b9
|
373 |
DEFINE_WAKE_Q(wake_q); |
e3658538b
|
374 |
|
016d7132f
|
375 |
if (msqid64.msg_qbytes > ns->msg_ctlmnb && |
a0d092fc2
|
376 377 |
!capable(CAP_SYS_RESOURCE)) { err = -EPERM; |
15724ecb7
|
378 |
goto out_unlock1; |
a0d092fc2
|
379 |
} |
15724ecb7
|
380 |
ipc_lock_object(&msq->q_perm); |
1efdb69b0
|
381 382 |
err = ipc_update_perm(&msqid64.msg_perm, ipcp); if (err) |
7b4cc5d84
|
383 |
goto out_unlock0; |
1efdb69b0
|
384 |
|
016d7132f
|
385 |
msq->q_qbytes = msqid64.msg_qbytes; |
a0d092fc2
|
386 |
|
a0d092fc2
|
387 |
msq->q_ctime = get_seconds(); |
e3658538b
|
388 389 |
/* * Sleeping receivers might be excluded by |
a0d092fc2
|
390 391 |
* stricter permissions. */ |
ee51636ca
|
392 |
expunge_all(msq, -EAGAIN, &wake_q); |
e3658538b
|
393 394 |
/* * Sleeping senders might be able to send |
a0d092fc2
|
395 396 |
* due to a larger queue size. */ |
ed27f9122
|
397 |
ss_wakeup(msq, &wake_q, false); |
e3658538b
|
398 399 400 401 402 |
ipc_unlock_object(&msq->q_perm); wake_up_q(&wake_q); goto out_unlock1; } |
a0d092fc2
|
403 404 |
default: err = -EINVAL; |
15724ecb7
|
405 |
goto out_unlock1; |
a0d092fc2
|
406 |
} |
7b4cc5d84
|
407 408 409 410 411 |
out_unlock0: ipc_unlock_object(&msq->q_perm); out_unlock1: rcu_read_unlock(); |
a0d092fc2
|
412 |
out_up: |
d9a605e40
|
413 |
up_write(&msg_ids(ns).rwsem); |
a0d092fc2
|
414 415 |
return err; } |
2cafed30f
|
416 417 |
static int msgctl_nolock(struct ipc_namespace *ns, int msqid, int cmd, int version, void __user *buf) |
a0d092fc2
|
418 |
{ |
2cafed30f
|
419 |
int err; |
5a06a363e
|
420 |
struct msg_queue *msq; |
1da177e4c
|
421 422 |
switch (cmd) { |
5a06a363e
|
423 424 425 |
case IPC_INFO: case MSG_INFO: { |
1da177e4c
|
426 427 |
struct msginfo msginfo; int max_id; |
5a06a363e
|
428 |
|
1da177e4c
|
429 430 |
if (!buf) return -EFAULT; |
2cafed30f
|
431 |
|
5a06a363e
|
432 433 |
/* * We must not return kernel stack data. |
1da177e4c
|
434 435 436 |
* due to padding, it's not enough * to set all member fields. */ |
1da177e4c
|
437 438 439 |
err = security_msg_queue_msgctl(NULL, cmd); if (err) return err; |
5a06a363e
|
440 |
memset(&msginfo, 0, sizeof(msginfo)); |
1e7869373
|
441 442 443 |
msginfo.msgmni = ns->msg_ctlmni; msginfo.msgmax = ns->msg_ctlmax; msginfo.msgmnb = ns->msg_ctlmnb; |
1da177e4c
|
444 445 |
msginfo.msgssz = MSGSSZ; msginfo.msgseg = MSGSEG; |
d9a605e40
|
446 |
down_read(&msg_ids(ns).rwsem); |
1da177e4c
|
447 |
if (cmd == MSG_INFO) { |
1e7869373
|
448 |
msginfo.msgpool = msg_ids(ns).in_use; |
3ac88a41f
|
449 450 |
msginfo.msgmap = atomic_read(&ns->msg_hdrs); msginfo.msgtql = atomic_read(&ns->msg_bytes); |
1da177e4c
|
451 452 453 454 455 |
} else { msginfo.msgmap = MSGMAP; msginfo.msgpool = MSGPOOL; msginfo.msgtql = MSGTQL; } |
7ca7e564e
|
456 |
max_id = ipc_get_maxid(&msg_ids(ns)); |
d9a605e40
|
457 |
up_read(&msg_ids(ns).rwsem); |
5a06a363e
|
458 |
if (copy_to_user(buf, &msginfo, sizeof(struct msginfo))) |
1da177e4c
|
459 |
return -EFAULT; |
5a06a363e
|
460 |
return (max_id < 0) ? 0 : max_id; |
1da177e4c
|
461 |
} |
2cafed30f
|
462 463 |
case MSG_STAT: |
1da177e4c
|
464 465 466 467 |
case IPC_STAT: { struct msqid64_ds tbuf; int success_return; |
5a06a363e
|
468 |
|
1da177e4c
|
469 470 |
if (!buf) return -EFAULT; |
1da177e4c
|
471 |
|
ac0ba20ea
|
472 473 474 |
memset(&tbuf, 0, sizeof(tbuf)); rcu_read_lock(); |
5a06a363e
|
475 |
if (cmd == MSG_STAT) { |
ac0ba20ea
|
476 477 478 479 480 |
msq = msq_obtain_object(ns, msqid); if (IS_ERR(msq)) { err = PTR_ERR(msq); goto out_unlock; } |
7ca7e564e
|
481 |
success_return = msq->q_perm.id; |
1da177e4c
|
482 |
} else { |
ac0ba20ea
|
483 484 485 486 487 |
msq = msq_obtain_object_check(ns, msqid); if (IS_ERR(msq)) { err = PTR_ERR(msq); goto out_unlock; } |
1da177e4c
|
488 489 |
success_return = 0; } |
ac0ba20ea
|
490 |
|
1da177e4c
|
491 |
err = -EACCES; |
b0e77598f
|
492 |
if (ipcperms(ns, &msq->q_perm, S_IRUGO)) |
1da177e4c
|
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
goto out_unlock; err = security_msg_queue_msgctl(msq, cmd); if (err) goto out_unlock; kernel_to_ipc64_perm(&msq->q_perm, &tbuf.msg_perm); tbuf.msg_stime = msq->q_stime; tbuf.msg_rtime = msq->q_rtime; tbuf.msg_ctime = msq->q_ctime; tbuf.msg_cbytes = msq->q_cbytes; tbuf.msg_qnum = msq->q_qnum; tbuf.msg_qbytes = msq->q_qbytes; tbuf.msg_lspid = msq->q_lspid; tbuf.msg_lrpid = msq->q_lrpid; |
ac0ba20ea
|
508 |
rcu_read_unlock(); |
1da177e4c
|
509 510 511 512 |
if (copy_msqid_to_user(buf, &tbuf, version)) return -EFAULT; return success_return; } |
2cafed30f
|
513 |
|
1da177e4c
|
514 |
default: |
2cafed30f
|
515 |
return -EINVAL; |
1da177e4c
|
516 |
} |
2cafed30f
|
517 |
return err; |
1da177e4c
|
518 |
out_unlock: |
ac0ba20ea
|
519 |
rcu_read_unlock(); |
1da177e4c
|
520 521 |
return err; } |
2cafed30f
|
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 |
SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf) { int version; struct ipc_namespace *ns; if (msqid < 0 || cmd < 0) return -EINVAL; version = ipc_parse_version(&cmd); ns = current->nsproxy->ipc_ns; switch (cmd) { case IPC_INFO: case MSG_INFO: case MSG_STAT: /* msqid is an index rather than a msg queue id */ case IPC_STAT: return msgctl_nolock(ns, msqid, cmd, version, buf); case IPC_SET: case IPC_RMID: return msgctl_down(ns, msqid, cmd, buf, version); default: return -EINVAL; } } |
5a06a363e
|
546 |
static int testmsg(struct msg_msg *msg, long type, int mode) |
1da177e4c
|
547 |
{ |
46c0a8ca3
|
548 549 550 551 552 553 554 555 556 557 |
switch (mode) { case SEARCH_ANY: case SEARCH_NUMBER: return 1; case SEARCH_LESSEQUAL: if (msg->m_type <= type) return 1; break; case SEARCH_EQUAL: if (msg->m_type == type) |
1da177e4c
|
558 |
return 1; |
46c0a8ca3
|
559 560 561 562 563 |
break; case SEARCH_NOTEQUAL: if (msg->m_type != type) return 1; break; |
1da177e4c
|
564 565 566 |
} return 0; } |
ee51636ca
|
567 568 |
static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg, struct wake_q_head *wake_q) |
1da177e4c
|
569 |
{ |
41239fe82
|
570 |
struct msg_receiver *msr, *t; |
5a06a363e
|
571 |
|
41239fe82
|
572 |
list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) { |
5a06a363e
|
573 574 575 |
if (testmsg(msg, msr->r_msgtype, msr->r_mode) && !security_msg_queue_msgrcv(msq, msg, msr->r_tsk, msr->r_msgtype, msr->r_mode)) { |
1da177e4c
|
576 |
list_del(&msr->r_list); |
5a06a363e
|
577 |
if (msr->r_maxsize < msg->m_ts) { |
ee51636ca
|
578 579 |
wake_q_add(wake_q, msr->r_tsk); WRITE_ONCE(msr->r_msg, ERR_PTR(-E2BIG)); |
1da177e4c
|
580 |
} else { |
b488893a3
|
581 |
msq->q_lrpid = task_pid_vnr(msr->r_tsk); |
1da177e4c
|
582 |
msq->q_rtime = get_seconds(); |
5a06a363e
|
583 |
|
ee51636ca
|
584 585 |
wake_q_add(wake_q, msr->r_tsk); WRITE_ONCE(msr->r_msg, msg); |
1da177e4c
|
586 587 588 589 |
return 1; } } } |
ffa571daf
|
590 |
|
1da177e4c
|
591 592 |
return 0; } |
651971cb7
|
593 594 |
long do_msgsnd(int msqid, long mtype, void __user *mtext, size_t msgsz, int msgflg) |
1da177e4c
|
595 596 597 |
{ struct msg_queue *msq; struct msg_msg *msg; |
1da177e4c
|
598 |
int err; |
1e7869373
|
599 |
struct ipc_namespace *ns; |
194a6b5b9
|
600 |
DEFINE_WAKE_Q(wake_q); |
1e7869373
|
601 602 |
ns = current->nsproxy->ipc_ns; |
5a06a363e
|
603 |
|
1e7869373
|
604 |
if (msgsz > ns->msg_ctlmax || (long) msgsz < 0 || msqid < 0) |
1da177e4c
|
605 |
return -EINVAL; |
1da177e4c
|
606 607 |
if (mtype < 1) return -EINVAL; |
651971cb7
|
608 |
msg = load_msg(mtext, msgsz); |
5a06a363e
|
609 |
if (IS_ERR(msg)) |
1da177e4c
|
610 611 612 613 |
return PTR_ERR(msg); msg->m_type = mtype; msg->m_ts = msgsz; |
3dd1f784e
|
614 615 |
rcu_read_lock(); msq = msq_obtain_object_check(ns, msqid); |
023a53557
|
616 617 |
if (IS_ERR(msq)) { err = PTR_ERR(msq); |
3dd1f784e
|
618 |
goto out_unlock1; |
023a53557
|
619 |
} |
1da177e4c
|
620 |
|
bebcb928c
|
621 |
ipc_lock_object(&msq->q_perm); |
1da177e4c
|
622 623 |
for (;;) { struct msg_sender s; |
5a06a363e
|
624 |
err = -EACCES; |
b0e77598f
|
625 |
if (ipcperms(ns, &msq->q_perm, S_IWUGO)) |
bebcb928c
|
626 |
goto out_unlock0; |
1da177e4c
|
627 |
|
4271b05a2
|
628 |
/* raced with RMID? */ |
0f3d2b013
|
629 |
if (!ipc_valid_object(&msq->q_perm)) { |
4271b05a2
|
630 631 632 |
err = -EIDRM; goto out_unlock0; } |
1da177e4c
|
633 634 |
err = security_msg_queue_msgsnd(msq, msg, msgflg); if (err) |
bebcb928c
|
635 |
goto out_unlock0; |
1da177e4c
|
636 |
|
ed27f9122
|
637 |
if (msg_fits_inqueue(msq, msgsz)) |
1da177e4c
|
638 |
break; |
1da177e4c
|
639 640 |
/* queue full, wait: */ |
5a06a363e
|
641 642 |
if (msgflg & IPC_NOWAIT) { err = -EAGAIN; |
bebcb928c
|
643 |
goto out_unlock0; |
1da177e4c
|
644 |
} |
3dd1f784e
|
645 |
|
ffa571daf
|
646 |
/* enqueue the sender and prepare to block */ |
ed27f9122
|
647 |
ss_add(msq, &s, msgsz); |
6062a8dc0
|
648 649 650 |
if (!ipc_rcu_getref(msq)) { err = -EIDRM; |
3dd1f784e
|
651 |
goto out_unlock0; |
6062a8dc0
|
652 |
} |
3dd1f784e
|
653 654 |
ipc_unlock_object(&msq->q_perm); rcu_read_unlock(); |
1da177e4c
|
655 |
schedule(); |
3dd1f784e
|
656 657 |
rcu_read_lock(); ipc_lock_object(&msq->q_perm); |
9b24fef9f
|
658 |
ipc_rcu_putref(msq, msg_rcu_free); |
0f3d2b013
|
659 660 |
/* raced with RMID? */ if (!ipc_valid_object(&msq->q_perm)) { |
1da177e4c
|
661 |
err = -EIDRM; |
3dd1f784e
|
662 |
goto out_unlock0; |
1da177e4c
|
663 664 |
} ss_del(&s); |
5a06a363e
|
665 |
|
1da177e4c
|
666 |
if (signal_pending(current)) { |
5a06a363e
|
667 |
err = -ERESTARTNOHAND; |
3dd1f784e
|
668 |
goto out_unlock0; |
1da177e4c
|
669 |
} |
3dd1f784e
|
670 |
|
1da177e4c
|
671 |
} |
ed27f9122
|
672 |
|
b488893a3
|
673 |
msq->q_lspid = task_tgid_vnr(current); |
1da177e4c
|
674 |
msq->q_stime = get_seconds(); |
ee51636ca
|
675 |
if (!pipelined_send(msq, msg, &wake_q)) { |
25985edce
|
676 |
/* no one is waiting for this message, enqueue it */ |
5a06a363e
|
677 |
list_add_tail(&msg->m_list, &msq->q_messages); |
1da177e4c
|
678 679 |
msq->q_cbytes += msgsz; msq->q_qnum++; |
3ac88a41f
|
680 681 |
atomic_add(msgsz, &ns->msg_bytes); atomic_inc(&ns->msg_hdrs); |
1da177e4c
|
682 |
} |
5a06a363e
|
683 |
|
1da177e4c
|
684 685 |
err = 0; msg = NULL; |
3dd1f784e
|
686 687 |
out_unlock0: ipc_unlock_object(&msq->q_perm); |
ee51636ca
|
688 |
wake_up_q(&wake_q); |
3dd1f784e
|
689 690 |
out_unlock1: rcu_read_unlock(); |
5a06a363e
|
691 |
if (msg != NULL) |
1da177e4c
|
692 693 694 |
free_msg(msg); return err; } |
e48fbb699
|
695 696 |
SYSCALL_DEFINE4(msgsnd, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz, int, msgflg) |
651971cb7
|
697 698 699 700 701 702 703 |
{ long mtype; if (get_user(mtype, &msgp->mtype)) return -EFAULT; return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg); } |
5a06a363e
|
704 |
static inline int convert_mode(long *msgtyp, int msgflg) |
1da177e4c
|
705 |
{ |
8ac6ed585
|
706 707 |
if (msgflg & MSG_COPY) return SEARCH_NUMBER; |
5a06a363e
|
708 |
/* |
1da177e4c
|
709 710 711 |
* find message of correct type. * msgtyp = 0 => get first. * msgtyp > 0 => get first message of matching type. |
5a06a363e
|
712 |
* msgtyp < 0 => get message with least type must be < abs(msgtype). |
1da177e4c
|
713 |
*/ |
5a06a363e
|
714 |
if (*msgtyp == 0) |
1da177e4c
|
715 |
return SEARCH_ANY; |
5a06a363e
|
716 |
if (*msgtyp < 0) { |
999898355
|
717 718 719 720 |
if (*msgtyp == LONG_MIN) /* -LONG_MIN is undefined */ *msgtyp = LONG_MAX; else *msgtyp = -*msgtyp; |
1da177e4c
|
721 722 |
return SEARCH_LESSEQUAL; } |
5a06a363e
|
723 |
if (msgflg & MSG_EXCEPT) |
1da177e4c
|
724 725 726 |
return SEARCH_NOTEQUAL; return SEARCH_EQUAL; } |
f9dd87f47
|
727 728 729 730 731 732 733 734 735 736 737 738 739 |
static long do_msg_fill(void __user *dest, struct msg_msg *msg, size_t bufsz) { struct msgbuf __user *msgp = dest; size_t msgsz; if (put_user(msg->m_type, &msgp->mtype)) return -EFAULT; msgsz = (bufsz > msg->m_ts) ? msg->m_ts : bufsz; if (store_msg(msgp->mtext, msg, msgsz)) return -EFAULT; return msgsz; } |
4a674f34b
|
740 |
#ifdef CONFIG_CHECKPOINT_RESTORE |
3fcfe7865
|
741 742 743 744 |
/* * This function creates new kernel message structure, large enough to store * bufsz message bytes. */ |
8ac6ed585
|
745 |
static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz) |
4a674f34b
|
746 747 |
{ struct msg_msg *copy; |
4a674f34b
|
748 749 750 751 752 753 754 755 |
/* * Create dummy message to copy real message to. */ copy = load_msg(buf, bufsz); if (!IS_ERR(copy)) copy->m_ts = bufsz; return copy; } |
85398aa8d
|
756 |
static inline void free_copy(struct msg_msg *copy) |
4a674f34b
|
757 |
{ |
85398aa8d
|
758 |
if (copy) |
4a674f34b
|
759 760 761 |
free_msg(copy); } #else |
8ac6ed585
|
762 |
static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz) |
b30efe277
|
763 764 765 |
{ return ERR_PTR(-ENOSYS); } |
85398aa8d
|
766 767 768 |
static inline void free_copy(struct msg_msg *copy) { } |
4a674f34b
|
769 |
#endif |
daaf74cf0
|
770 771 |
static struct msg_msg *find_msg(struct msg_queue *msq, long *msgtyp, int mode) { |
368ae537e
|
772 |
struct msg_msg *msg, *found = NULL; |
daaf74cf0
|
773 774 775 776 777 778 779 780 |
long count = 0; list_for_each_entry(msg, &msq->q_messages, m_list) { if (testmsg(msg, *msgtyp, mode) && !security_msg_queue_msgrcv(msq, msg, current, *msgtyp, mode)) { if (mode == SEARCH_LESSEQUAL && msg->m_type != 1) { *msgtyp = msg->m_type - 1; |
368ae537e
|
781 |
found = msg; |
daaf74cf0
|
782 783 784 785 786 787 788 789 |
} else if (mode == SEARCH_NUMBER) { if (*msgtyp == count) return msg; } else return msg; count++; } } |
368ae537e
|
790 |
return found ?: ERR_PTR(-EAGAIN); |
daaf74cf0
|
791 |
} |
41a0d523d
|
792 |
long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, int msgflg, |
f9dd87f47
|
793 |
long (*msg_handler)(void __user *, struct msg_msg *, size_t)) |
1da177e4c
|
794 |
{ |
1da177e4c
|
795 |
int mode; |
41a0d523d
|
796 |
struct msg_queue *msq; |
1e7869373
|
797 |
struct ipc_namespace *ns; |
41a0d523d
|
798 |
struct msg_msg *msg, *copy = NULL; |
194a6b5b9
|
799 |
DEFINE_WAKE_Q(wake_q); |
1da177e4c
|
800 |
|
88b9e456b
|
801 |
ns = current->nsproxy->ipc_ns; |
f9dd87f47
|
802 |
if (msqid < 0 || (long) bufsz < 0) |
1da177e4c
|
803 |
return -EINVAL; |
41a0d523d
|
804 |
|
4a674f34b
|
805 |
if (msgflg & MSG_COPY) { |
4f87dac38
|
806 807 |
if ((msgflg & MSG_EXCEPT) || !(msgflg & IPC_NOWAIT)) return -EINVAL; |
8ac6ed585
|
808 |
copy = prepare_copy(buf, min_t(size_t, bufsz, ns->msg_ctlmax)); |
4a674f34b
|
809 810 811 |
if (IS_ERR(copy)) return PTR_ERR(copy); } |
5a06a363e
|
812 |
mode = convert_mode(&msgtyp, msgflg); |
1da177e4c
|
813 |
|
41a0d523d
|
814 815 |
rcu_read_lock(); msq = msq_obtain_object_check(ns, msqid); |
4a674f34b
|
816 |
if (IS_ERR(msq)) { |
41a0d523d
|
817 |
rcu_read_unlock(); |
85398aa8d
|
818 |
free_copy(copy); |
023a53557
|
819 |
return PTR_ERR(msq); |
4a674f34b
|
820 |
} |
1da177e4c
|
821 822 823 |
for (;;) { struct msg_receiver msr_d; |
1da177e4c
|
824 825 |
msg = ERR_PTR(-EACCES); |
b0e77598f
|
826 |
if (ipcperms(ns, &msq->q_perm, S_IRUGO)) |
41a0d523d
|
827 |
goto out_unlock1; |
1da177e4c
|
828 |
|
41a0d523d
|
829 |
ipc_lock_object(&msq->q_perm); |
4271b05a2
|
830 831 |
/* raced with RMID? */ |
0f3d2b013
|
832 |
if (!ipc_valid_object(&msq->q_perm)) { |
4271b05a2
|
833 834 835 |
msg = ERR_PTR(-EIDRM); goto out_unlock0; } |
daaf74cf0
|
836 |
msg = find_msg(msq, &msgtyp, mode); |
5a06a363e
|
837 838 839 840 841 |
if (!IS_ERR(msg)) { /* * Found a suitable message. * Unlink it from the queue. */ |
f9dd87f47
|
842 |
if ((bufsz < msg->m_ts) && !(msgflg & MSG_NOERROR)) { |
1da177e4c
|
843 |
msg = ERR_PTR(-E2BIG); |
41a0d523d
|
844 |
goto out_unlock0; |
1da177e4c
|
845 |
} |
3fcfe7865
|
846 847 848 849 |
/* * If we are copying, then do not unlink message and do * not update queue parameters. */ |
852028af8
|
850 851 |
if (msgflg & MSG_COPY) { msg = copy_msg(msg, copy); |
41a0d523d
|
852 |
goto out_unlock0; |
852028af8
|
853 |
} |
41a0d523d
|
854 |
|
1da177e4c
|
855 856 857 |
list_del(&msg->m_list); msq->q_qnum--; msq->q_rtime = get_seconds(); |
b488893a3
|
858 |
msq->q_lrpid = task_tgid_vnr(current); |
1da177e4c
|
859 |
msq->q_cbytes -= msg->m_ts; |
3ac88a41f
|
860 861 |
atomic_sub(msg->m_ts, &ns->msg_bytes); atomic_dec(&ns->msg_hdrs); |
ed27f9122
|
862 |
ss_wakeup(msq, &wake_q, false); |
41a0d523d
|
863 864 |
goto out_unlock0; |
1da177e4c
|
865 |
} |
41a0d523d
|
866 |
|
1da177e4c
|
867 868 869 |
/* No message waiting. Wait for a message */ if (msgflg & IPC_NOWAIT) { msg = ERR_PTR(-ENOMSG); |
41a0d523d
|
870 |
goto out_unlock0; |
1da177e4c
|
871 |
} |
41a0d523d
|
872 |
|
5a06a363e
|
873 |
list_add_tail(&msr_d.r_list, &msq->q_receivers); |
1da177e4c
|
874 875 876 |
msr_d.r_tsk = current; msr_d.r_msgtype = msgtyp; msr_d.r_mode = mode; |
5a06a363e
|
877 |
if (msgflg & MSG_NOERROR) |
1da177e4c
|
878 |
msr_d.r_maxsize = INT_MAX; |
5a06a363e
|
879 |
else |
f9dd87f47
|
880 |
msr_d.r_maxsize = bufsz; |
1da177e4c
|
881 |
msr_d.r_msg = ERR_PTR(-EAGAIN); |
f75a2f358
|
882 |
__set_current_state(TASK_INTERRUPTIBLE); |
1da177e4c
|
883 |
|
41a0d523d
|
884 885 |
ipc_unlock_object(&msq->q_perm); rcu_read_unlock(); |
1da177e4c
|
886 |
schedule(); |
ee51636ca
|
887 888 889 890 891 892 |
/* * Lockless receive, part 1: * We don't hold a reference to the queue and getting a * reference would defeat the idea of a lockless operation, * thus the code relies on rcu to guarantee the existence of * msq: |
1da177e4c
|
893 894 |
* Prior to destruction, expunge_all(-EIRDM) changes r_msg. * Thus if r_msg is -EAGAIN, then the queue not yet destroyed. |
1da177e4c
|
895 896 |
*/ rcu_read_lock(); |
ee51636ca
|
897 898 899 900 901 902 |
/* * Lockless receive, part 2: * The work in pipelined_send() and expunge_all(): * - Set pointer to message * - Queue the receiver task for later wakeup * - Wake up the process after the lock is dropped. |
ff35e5ef8
|
903 |
* |
ee51636ca
|
904 905 |
* Should the process wake up before this wakeup (due to a * signal) it will either see the message and continue ... |
1da177e4c
|
906 |
*/ |
ee51636ca
|
907 |
msg = READ_ONCE(msr_d.r_msg); |
41a0d523d
|
908 909 |
if (msg != ERR_PTR(-EAGAIN)) goto out_unlock1; |
1da177e4c
|
910 |
|
ee51636ca
|
911 912 913 914 |
/* * ... or see -EAGAIN, acquire the lock to check the message * again. */ |
41a0d523d
|
915 |
ipc_lock_object(&msq->q_perm); |
1da177e4c
|
916 |
|
ee51636ca
|
917 |
msg = msr_d.r_msg; |
5a06a363e
|
918 |
if (msg != ERR_PTR(-EAGAIN)) |
41a0d523d
|
919 |
goto out_unlock0; |
1da177e4c
|
920 921 922 923 |
list_del(&msr_d.r_list); if (signal_pending(current)) { msg = ERR_PTR(-ERESTARTNOHAND); |
41a0d523d
|
924 |
goto out_unlock0; |
1da177e4c
|
925 |
} |
41a0d523d
|
926 927 |
ipc_unlock_object(&msq->q_perm); |
1da177e4c
|
928 |
} |
41a0d523d
|
929 930 931 |
out_unlock0: ipc_unlock_object(&msq->q_perm); |
e3658538b
|
932 |
wake_up_q(&wake_q); |
41a0d523d
|
933 934 |
out_unlock1: rcu_read_unlock(); |
4a674f34b
|
935 |
if (IS_ERR(msg)) { |
85398aa8d
|
936 |
free_copy(copy); |
5a06a363e
|
937 |
return PTR_ERR(msg); |
4a674f34b
|
938 |
} |
1da177e4c
|
939 |
|
f9dd87f47
|
940 |
bufsz = msg_handler(buf, msg, bufsz); |
1da177e4c
|
941 |
free_msg(msg); |
5a06a363e
|
942 |
|
f9dd87f47
|
943 |
return bufsz; |
1da177e4c
|
944 |
} |
e48fbb699
|
945 946 |
SYSCALL_DEFINE5(msgrcv, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz, long, msgtyp, int, msgflg) |
651971cb7
|
947 |
{ |
f9dd87f47
|
948 |
return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill); |
651971cb7
|
949 |
} |
3440a6bd1
|
950 951 952 953 954 |
void msg_init_ns(struct ipc_namespace *ns) { ns->msg_ctlmax = MSGMAX; ns->msg_ctlmnb = MSGMNB; |
0050ee059
|
955 |
ns->msg_ctlmni = MSGMNI; |
3440a6bd1
|
956 957 958 959 960 961 962 963 964 965 966 967 968 |
atomic_set(&ns->msg_bytes, 0); atomic_set(&ns->msg_hdrs, 0); ipc_init_ids(&ns->ids[IPC_MSG_IDS]); } #ifdef CONFIG_IPC_NS void msg_exit_ns(struct ipc_namespace *ns) { free_ipcs(ns, &msg_ids(ns), freeque); idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr); } #endif |
1da177e4c
|
969 |
#ifdef CONFIG_PROC_FS |
19b4946ca
|
970 |
static int sysvipc_msg_proc_show(struct seq_file *s, void *it) |
1da177e4c
|
971 |
{ |
1efdb69b0
|
972 |
struct user_namespace *user_ns = seq_user_ns(s); |
19b4946ca
|
973 |
struct msg_queue *msq = it; |
7f032d6ef
|
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 |
seq_printf(s, "%10d %10d %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %10lu %10lu %10lu ", msq->q_perm.key, msq->q_perm.id, msq->q_perm.mode, msq->q_cbytes, msq->q_qnum, msq->q_lspid, msq->q_lrpid, from_kuid_munged(user_ns, msq->q_perm.uid), from_kgid_munged(user_ns, msq->q_perm.gid), from_kuid_munged(user_ns, msq->q_perm.cuid), from_kgid_munged(user_ns, msq->q_perm.cgid), msq->q_stime, msq->q_rtime, msq->q_ctime); return 0; |
1da177e4c
|
993 994 |
} #endif |
3440a6bd1
|
995 996 997 998 |
void __init msg_init(void) { msg_init_ns(&init_ipc_ns); |
3440a6bd1
|
999 1000 1001 1002 1003 |
ipc_init_proc_interface("sysvipc/msg", " key msqid perms cbytes qnum lspid lrpid uid gid cuid cgid stime rtime ctime ", IPC_MSG_IDS, sysvipc_msg_proc_show); } |