.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright (C) 2007 |
---|
3 | 4 | * |
---|
4 | 5 | * Author: Eric Biederman <ebiederm@xmision.com> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License as |
---|
8 | | - * published by the Free Software Foundation, version 2 of the |
---|
9 | | - * License. |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/module.h> |
---|
.. | .. |
---|
28 | 24 | |
---|
29 | 25 | #ifdef CONFIG_PROC_SYSCTL |
---|
30 | 26 | static int proc_ipc_dointvec(struct ctl_table *table, int write, |
---|
31 | | - void __user *buffer, size_t *lenp, loff_t *ppos) |
---|
| 27 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
32 | 28 | { |
---|
33 | 29 | struct ctl_table ipc_table; |
---|
34 | 30 | |
---|
.. | .. |
---|
39 | 35 | } |
---|
40 | 36 | |
---|
41 | 37 | static int proc_ipc_dointvec_minmax(struct ctl_table *table, int write, |
---|
42 | | - void __user *buffer, size_t *lenp, loff_t *ppos) |
---|
| 38 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
43 | 39 | { |
---|
44 | 40 | struct ctl_table ipc_table; |
---|
45 | 41 | |
---|
.. | .. |
---|
50 | 46 | } |
---|
51 | 47 | |
---|
52 | 48 | static int proc_ipc_dointvec_minmax_orphans(struct ctl_table *table, int write, |
---|
53 | | - void __user *buffer, size_t *lenp, loff_t *ppos) |
---|
| 49 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
54 | 50 | { |
---|
55 | 51 | struct ipc_namespace *ns = current->nsproxy->ipc_ns; |
---|
56 | 52 | int err = proc_ipc_dointvec_minmax(table, write, buffer, lenp, ppos); |
---|
.. | .. |
---|
63 | 59 | } |
---|
64 | 60 | |
---|
65 | 61 | static int proc_ipc_doulongvec_minmax(struct ctl_table *table, int write, |
---|
66 | | - void __user *buffer, size_t *lenp, loff_t *ppos) |
---|
| 62 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
67 | 63 | { |
---|
68 | 64 | struct ctl_table ipc_table; |
---|
69 | 65 | memcpy(&ipc_table, table, sizeof(ipc_table)); |
---|
.. | .. |
---|
74 | 70 | } |
---|
75 | 71 | |
---|
76 | 72 | static int proc_ipc_auto_msgmni(struct ctl_table *table, int write, |
---|
77 | | - void __user *buffer, size_t *lenp, loff_t *ppos) |
---|
| 73 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
78 | 74 | { |
---|
79 | 75 | struct ctl_table ipc_table; |
---|
80 | 76 | int dummy = 0; |
---|
.. | .. |
---|
88 | 84 | return proc_dointvec_minmax(&ipc_table, write, buffer, lenp, ppos); |
---|
89 | 85 | } |
---|
90 | 86 | |
---|
| 87 | +static int proc_ipc_sem_dointvec(struct ctl_table *table, int write, |
---|
| 88 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
| 89 | +{ |
---|
| 90 | + int ret, semmni; |
---|
| 91 | + struct ipc_namespace *ns = current->nsproxy->ipc_ns; |
---|
| 92 | + |
---|
| 93 | + semmni = ns->sem_ctls[3]; |
---|
| 94 | + ret = proc_ipc_dointvec(table, write, buffer, lenp, ppos); |
---|
| 95 | + |
---|
| 96 | + if (!ret) |
---|
| 97 | + ret = sem_check_semmni(current->nsproxy->ipc_ns); |
---|
| 98 | + |
---|
| 99 | + /* |
---|
| 100 | + * Reset the semmni value if an error happens. |
---|
| 101 | + */ |
---|
| 102 | + if (ret) |
---|
| 103 | + ns->sem_ctls[3] = semmni; |
---|
| 104 | + return ret; |
---|
| 105 | +} |
---|
| 106 | + |
---|
91 | 107 | #else |
---|
92 | 108 | #define proc_ipc_doulongvec_minmax NULL |
---|
93 | 109 | #define proc_ipc_dointvec NULL |
---|
94 | 110 | #define proc_ipc_dointvec_minmax NULL |
---|
95 | 111 | #define proc_ipc_dointvec_minmax_orphans NULL |
---|
96 | 112 | #define proc_ipc_auto_msgmni NULL |
---|
| 113 | +#define proc_ipc_sem_dointvec NULL |
---|
97 | 114 | #endif |
---|
98 | 115 | |
---|
99 | | -static int zero; |
---|
100 | | -static int one = 1; |
---|
101 | | -static int int_max = INT_MAX; |
---|
| 116 | +int ipc_mni = IPCMNI; |
---|
| 117 | +int ipc_mni_shift = IPCMNI_SHIFT; |
---|
| 118 | +int ipc_min_cycle = RADIX_TREE_MAP_SIZE; |
---|
102 | 119 | |
---|
103 | 120 | static struct ctl_table ipc_kern_table[] = { |
---|
104 | 121 | { |
---|
.. | .. |
---|
120 | 137 | .data = &init_ipc_ns.shm_ctlmni, |
---|
121 | 138 | .maxlen = sizeof(init_ipc_ns.shm_ctlmni), |
---|
122 | 139 | .mode = 0644, |
---|
123 | | - .proc_handler = proc_ipc_dointvec, |
---|
| 140 | + .proc_handler = proc_ipc_dointvec_minmax, |
---|
| 141 | + .extra1 = SYSCTL_ZERO, |
---|
| 142 | + .extra2 = &ipc_mni, |
---|
124 | 143 | }, |
---|
125 | 144 | { |
---|
126 | 145 | .procname = "shm_rmid_forced", |
---|
.. | .. |
---|
128 | 147 | .maxlen = sizeof(init_ipc_ns.shm_rmid_forced), |
---|
129 | 148 | .mode = 0644, |
---|
130 | 149 | .proc_handler = proc_ipc_dointvec_minmax_orphans, |
---|
131 | | - .extra1 = &zero, |
---|
132 | | - .extra2 = &one, |
---|
| 150 | + .extra1 = SYSCTL_ZERO, |
---|
| 151 | + .extra2 = SYSCTL_ONE, |
---|
133 | 152 | }, |
---|
134 | 153 | { |
---|
135 | 154 | .procname = "msgmax", |
---|
.. | .. |
---|
137 | 156 | .maxlen = sizeof(init_ipc_ns.msg_ctlmax), |
---|
138 | 157 | .mode = 0644, |
---|
139 | 158 | .proc_handler = proc_ipc_dointvec_minmax, |
---|
140 | | - .extra1 = &zero, |
---|
141 | | - .extra2 = &int_max, |
---|
| 159 | + .extra1 = SYSCTL_ZERO, |
---|
| 160 | + .extra2 = SYSCTL_INT_MAX, |
---|
142 | 161 | }, |
---|
143 | 162 | { |
---|
144 | 163 | .procname = "msgmni", |
---|
.. | .. |
---|
146 | 165 | .maxlen = sizeof(init_ipc_ns.msg_ctlmni), |
---|
147 | 166 | .mode = 0644, |
---|
148 | 167 | .proc_handler = proc_ipc_dointvec_minmax, |
---|
149 | | - .extra1 = &zero, |
---|
150 | | - .extra2 = &int_max, |
---|
| 168 | + .extra1 = SYSCTL_ZERO, |
---|
| 169 | + .extra2 = &ipc_mni, |
---|
151 | 170 | }, |
---|
152 | 171 | { |
---|
153 | 172 | .procname = "auto_msgmni", |
---|
.. | .. |
---|
155 | 174 | .maxlen = sizeof(int), |
---|
156 | 175 | .mode = 0644, |
---|
157 | 176 | .proc_handler = proc_ipc_auto_msgmni, |
---|
158 | | - .extra1 = &zero, |
---|
159 | | - .extra2 = &one, |
---|
| 177 | + .extra1 = SYSCTL_ZERO, |
---|
| 178 | + .extra2 = SYSCTL_ONE, |
---|
160 | 179 | }, |
---|
161 | 180 | { |
---|
162 | 181 | .procname = "msgmnb", |
---|
.. | .. |
---|
164 | 183 | .maxlen = sizeof(init_ipc_ns.msg_ctlmnb), |
---|
165 | 184 | .mode = 0644, |
---|
166 | 185 | .proc_handler = proc_ipc_dointvec_minmax, |
---|
167 | | - .extra1 = &zero, |
---|
168 | | - .extra2 = &int_max, |
---|
| 186 | + .extra1 = SYSCTL_ZERO, |
---|
| 187 | + .extra2 = SYSCTL_INT_MAX, |
---|
169 | 188 | }, |
---|
170 | 189 | { |
---|
171 | 190 | .procname = "sem", |
---|
172 | 191 | .data = &init_ipc_ns.sem_ctls, |
---|
173 | 192 | .maxlen = 4*sizeof(int), |
---|
174 | 193 | .mode = 0644, |
---|
175 | | - .proc_handler = proc_ipc_dointvec, |
---|
| 194 | + .proc_handler = proc_ipc_sem_dointvec, |
---|
176 | 195 | }, |
---|
177 | 196 | #ifdef CONFIG_CHECKPOINT_RESTORE |
---|
178 | 197 | { |
---|
.. | .. |
---|
181 | 200 | .maxlen = sizeof(init_ipc_ns.ids[IPC_SEM_IDS].next_id), |
---|
182 | 201 | .mode = 0644, |
---|
183 | 202 | .proc_handler = proc_ipc_dointvec_minmax, |
---|
184 | | - .extra1 = &zero, |
---|
185 | | - .extra2 = &int_max, |
---|
| 203 | + .extra1 = SYSCTL_ZERO, |
---|
| 204 | + .extra2 = SYSCTL_INT_MAX, |
---|
186 | 205 | }, |
---|
187 | 206 | { |
---|
188 | 207 | .procname = "msg_next_id", |
---|
.. | .. |
---|
190 | 209 | .maxlen = sizeof(init_ipc_ns.ids[IPC_MSG_IDS].next_id), |
---|
191 | 210 | .mode = 0644, |
---|
192 | 211 | .proc_handler = proc_ipc_dointvec_minmax, |
---|
193 | | - .extra1 = &zero, |
---|
194 | | - .extra2 = &int_max, |
---|
| 212 | + .extra1 = SYSCTL_ZERO, |
---|
| 213 | + .extra2 = SYSCTL_INT_MAX, |
---|
195 | 214 | }, |
---|
196 | 215 | { |
---|
197 | 216 | .procname = "shm_next_id", |
---|
.. | .. |
---|
199 | 218 | .maxlen = sizeof(init_ipc_ns.ids[IPC_SHM_IDS].next_id), |
---|
200 | 219 | .mode = 0644, |
---|
201 | 220 | .proc_handler = proc_ipc_dointvec_minmax, |
---|
202 | | - .extra1 = &zero, |
---|
203 | | - .extra2 = &int_max, |
---|
| 221 | + .extra1 = SYSCTL_ZERO, |
---|
| 222 | + .extra2 = SYSCTL_INT_MAX, |
---|
204 | 223 | }, |
---|
205 | 224 | #endif |
---|
206 | 225 | {} |
---|
.. | .. |
---|
222 | 241 | } |
---|
223 | 242 | |
---|
224 | 243 | device_initcall(ipc_sysctl_init); |
---|
| 244 | + |
---|
| 245 | +static int __init ipc_mni_extend(char *str) |
---|
| 246 | +{ |
---|
| 247 | + ipc_mni = IPCMNI_EXTEND; |
---|
| 248 | + ipc_mni_shift = IPCMNI_EXTEND_SHIFT; |
---|
| 249 | + ipc_min_cycle = IPCMNI_EXTEND_MIN_CYCLE; |
---|
| 250 | + pr_info("IPCMNI extended to %d.\n", ipc_mni); |
---|
| 251 | + return 0; |
---|
| 252 | +} |
---|
| 253 | +early_param("ipcmni_extend", ipc_mni_extend); |
---|