]>
Commit | Line | Data |
---|---|---|
b886d83c | 1 | // SPDX-License-Identifier: GPL-2.0-only |
bdc8e5f8 SH |
2 | /* |
3 | * Copyright (C) 2007 IBM Corporation | |
4 | * | |
5 | * Author: Cedric Le Goater <clg@fr.ibm.com> | |
bdc8e5f8 SH |
6 | */ |
7 | ||
8 | #include <linux/nsproxy.h> | |
9 | #include <linux/ipc_namespace.h> | |
10 | #include <linux/sysctl.h> | |
11 | ||
f26ec5ba | 12 | #ifdef CONFIG_PROC_SYSCTL |
a5c5928b | 13 | static void *get_mq(struct ctl_table *table) |
bdc8e5f8 SH |
14 | { |
15 | char *which = table->data; | |
16 | struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; | |
17 | which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns; | |
18 | return which; | |
19 | } | |
20 | ||
a5c5928b | 21 | static int proc_mq_dointvec(struct ctl_table *table, int write, |
f3713fd9 DB |
22 | void __user *buffer, size_t *lenp, loff_t *ppos) |
23 | { | |
24 | struct ctl_table mq_table; | |
25 | memcpy(&mq_table, table, sizeof(mq_table)); | |
26 | mq_table.data = get_mq(table); | |
27 | ||
28 | return proc_dointvec(&mq_table, write, buffer, lenp, ppos); | |
29 | } | |
30 | ||
a5c5928b | 31 | static int proc_mq_dointvec_minmax(struct ctl_table *table, int write, |
8d65af78 | 32 | void __user *buffer, size_t *lenp, loff_t *ppos) |
bdc8e5f8 SH |
33 | { |
34 | struct ctl_table mq_table; | |
35 | memcpy(&mq_table, table, sizeof(mq_table)); | |
36 | mq_table.data = get_mq(table); | |
37 | ||
8d65af78 | 38 | return proc_dointvec_minmax(&mq_table, write, buffer, |
bdc8e5f8 SH |
39 | lenp, ppos); |
40 | } | |
41 | #else | |
f3713fd9 | 42 | #define proc_mq_dointvec NULL |
bdc8e5f8 SH |
43 | #define proc_mq_dointvec_minmax NULL |
44 | #endif | |
45 | ||
46 | static int msg_max_limit_min = MIN_MSGMAX; | |
93e6f119 | 47 | static int msg_max_limit_max = HARD_MSGMAX; |
bdc8e5f8 SH |
48 | |
49 | static int msg_maxsize_limit_min = MIN_MSGSIZEMAX; | |
93e6f119 | 50 | static int msg_maxsize_limit_max = HARD_MSGSIZEMAX; |
bdc8e5f8 | 51 | |
a5c5928b | 52 | static struct ctl_table mq_sysctls[] = { |
bdc8e5f8 SH |
53 | { |
54 | .procname = "queues_max", | |
55 | .data = &init_ipc_ns.mq_queues_max, | |
56 | .maxlen = sizeof(int), | |
57 | .mode = 0644, | |
f3713fd9 | 58 | .proc_handler = proc_mq_dointvec, |
bdc8e5f8 SH |
59 | }, |
60 | { | |
61 | .procname = "msg_max", | |
62 | .data = &init_ipc_ns.mq_msg_max, | |
63 | .maxlen = sizeof(int), | |
64 | .mode = 0644, | |
65 | .proc_handler = proc_mq_dointvec_minmax, | |
66 | .extra1 = &msg_max_limit_min, | |
67 | .extra2 = &msg_max_limit_max, | |
68 | }, | |
69 | { | |
70 | .procname = "msgsize_max", | |
71 | .data = &init_ipc_ns.mq_msgsize_max, | |
72 | .maxlen = sizeof(int), | |
73 | .mode = 0644, | |
74 | .proc_handler = proc_mq_dointvec_minmax, | |
75 | .extra1 = &msg_maxsize_limit_min, | |
76 | .extra2 = &msg_maxsize_limit_max, | |
77 | }, | |
cef0184c KM |
78 | { |
79 | .procname = "msg_default", | |
80 | .data = &init_ipc_ns.mq_msg_default, | |
81 | .maxlen = sizeof(int), | |
82 | .mode = 0644, | |
83 | .proc_handler = proc_mq_dointvec_minmax, | |
84 | .extra1 = &msg_max_limit_min, | |
85 | .extra2 = &msg_max_limit_max, | |
86 | }, | |
87 | { | |
88 | .procname = "msgsize_default", | |
89 | .data = &init_ipc_ns.mq_msgsize_default, | |
90 | .maxlen = sizeof(int), | |
91 | .mode = 0644, | |
92 | .proc_handler = proc_mq_dointvec_minmax, | |
93 | .extra1 = &msg_maxsize_limit_min, | |
94 | .extra2 = &msg_maxsize_limit_max, | |
95 | }, | |
2bc4657c | 96 | {} |
bdc8e5f8 SH |
97 | }; |
98 | ||
a5c5928b | 99 | static struct ctl_table mq_sysctl_dir[] = { |
bdc8e5f8 SH |
100 | { |
101 | .procname = "mqueue", | |
102 | .mode = 0555, | |
103 | .child = mq_sysctls, | |
104 | }, | |
2bc4657c | 105 | {} |
bdc8e5f8 SH |
106 | }; |
107 | ||
a5c5928b | 108 | static struct ctl_table mq_sysctl_root[] = { |
bdc8e5f8 | 109 | { |
bdc8e5f8 SH |
110 | .procname = "fs", |
111 | .mode = 0555, | |
112 | .child = mq_sysctl_dir, | |
113 | }, | |
2bc4657c | 114 | {} |
bdc8e5f8 SH |
115 | }; |
116 | ||
117 | struct ctl_table_header *mq_register_sysctl_table(void) | |
118 | { | |
119 | return register_sysctl_table(mq_sysctl_root); | |
120 | } |