Print this page
3830 SIGQUEUE_MAX's limit of 32 is too low
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/os/rctl_proc.c
+++ new/usr/src/uts/common/os/rctl_proc.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 26 #include <sys/types.h>
29 27 #include <sys/cmn_err.h>
30 28 #include <sys/sysmacros.h>
31 29 #include <sys/proc.h>
32 30 #include <sys/rctl.h>
33 31 #include <sys/rctl_impl.h>
34 32 #include <sys/port_kernel.h>
33 +#include <sys/signal.h>
35 34
36 35 #include <sys/vmparam.h>
37 36 #include <sys/machparam.h>
38 37
39 38 /*
40 39 * Process-based resource controls
41 40 * The structure of the kernel leaves us no particular place where the process
42 41 * abstraction can be declared--it is intertwined with the growth of the Unix
43 42 * kernel. Accordingly, we place all of the resource control logic associated
44 43 * with processes, both existing and future, in this file.
45 44 */
46 45
47 46 rctl_hndl_t rctlproc_legacy[RLIM_NLIMITS];
48 47 uint_t rctlproc_flags[RLIM_NLIMITS] = {
49 48 RCTL_LOCAL_SIGNAL, /* RLIMIT_CPU */
50 49 RCTL_LOCAL_DENY | RCTL_LOCAL_SIGNAL, /* RLIMIT_FSIZE */
51 50 RCTL_LOCAL_DENY, /* RLIMIT_DATA */
52 51 RCTL_LOCAL_DENY, /* RLIMIT_STACK */
53 52 RCTL_LOCAL_DENY, /* RLIMIT_CORE */
54 53 RCTL_LOCAL_DENY, /* RLIMIT_NOFILE */
55 54 RCTL_LOCAL_DENY /* RLIMIT_VMEM */
56 55 };
57 56 int rctlproc_signals[RLIM_NLIMITS] = {
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
58 57 SIGXCPU, /* RLIMIT_CPU */
59 58 SIGXFSZ, /* RLIMIT_FSIZE */
60 59 0, 0, 0, 0, 0 /* remainder do not signal */
61 60 };
62 61
63 62 rctl_hndl_t rc_process_msgmnb;
64 63 rctl_hndl_t rc_process_msgtql;
65 64 rctl_hndl_t rc_process_semmsl;
66 65 rctl_hndl_t rc_process_semopm;
67 66 rctl_hndl_t rc_process_portev;
67 +rctl_hndl_t rc_process_sigqueue;
68 68
69 69 /*
70 70 * process.max-cpu-time / RLIMIT_CPU
71 71 */
72 72 /*ARGSUSED*/
73 73 static int
74 74 proc_cpu_time_test(struct rctl *rctl, struct proc *p, rctl_entity_p_t *e,
75 75 rctl_val_t *rval, rctl_qty_t inc, uint_t flags)
76 76 {
77 77 return (inc >= rval->rcv_value);
78 78 }
79 79
80 80 static rctl_ops_t proc_cpu_time_ops = {
81 81 rcop_no_action,
82 82 rcop_no_usage,
83 83 rcop_no_set,
84 84 proc_cpu_time_test
85 85 };
86 86
87 87 /*
88 88 * process.max-file-size / RLIMIT_FSIZE
89 89 */
90 90 static int
91 91 proc_filesize_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e,
92 92 rctl_qty_t nv)
93 93 {
94 94 if (p->p_model == DATAMODEL_NATIVE)
95 95 nv = MIN(nv, rctl->rc_dict_entry->rcd_max_native);
96 96 else
97 97 nv = MIN(nv, rctl->rc_dict_entry->rcd_max_ilp32);
98 98
99 99 ASSERT(e->rcep_t == RCENTITY_PROCESS);
100 100 e->rcep_p.proc->p_fsz_ctl = nv;
101 101
102 102 return (0);
103 103 }
104 104
105 105 static rctl_ops_t proc_filesize_ops = {
106 106 rcop_no_action,
107 107 rcop_no_usage,
108 108 proc_filesize_set,
109 109 rcop_no_test
110 110 };
111 111
112 112 /*
113 113 * process.max-data / RLIMIT_DATA
114 114 */
115 115
116 116 /*
117 117 * process.max-stack-size / RLIMIT_STACK
118 118 */
119 119 static int
120 120 proc_stack_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e,
121 121 rctl_qty_t nv)
122 122 {
123 123 klwp_t *lwp = ttolwp(curthread);
124 124
125 125 if (p->p_model == DATAMODEL_NATIVE)
126 126 nv = MIN(nv, rctl->rc_dict_entry->rcd_max_native);
127 127 else
128 128 nv = MIN(nv, rctl->rc_dict_entry->rcd_max_ilp32);
129 129
130 130 /*
131 131 * In the process of changing the rlimit, this function actually
132 132 * gets called a number of times. We only want to save the current
133 133 * rlimit the first time we come through here. In post_syscall(),
134 134 * we copyin() the lwp's ustack, and compare it to the rlimit we
135 135 * save here; if the two match, we adjust the ustack to reflect
136 136 * the new stack bounds.
137 137 *
138 138 * We check to make sure that we're changing the rlimit of our
139 139 * own process rather than on behalf of some other process. The
140 140 * notion of changing this resource limit on behalf of another
141 141 * process is problematic at best, and changing the amount of stack
142 142 * space a process is allowed to consume is a rather antiquated
143 143 * notion that has limited applicability in our multithreaded
144 144 * process model.
145 145 */
146 146 ASSERT(e->rcep_t == RCENTITY_PROCESS);
147 147 if (lwp != NULL && lwp->lwp_procp == e->rcep_p.proc &&
148 148 lwp->lwp_ustack && lwp->lwp_old_stk_ctl == 0) {
149 149 lwp->lwp_old_stk_ctl = (size_t)e->rcep_p.proc->p_stk_ctl;
150 150 curthread->t_post_sys = 1;
151 151 }
152 152
153 153 e->rcep_p.proc->p_stk_ctl = nv;
154 154
155 155 return (0);
156 156 }
157 157
158 158 static rctl_ops_t proc_stack_ops = {
159 159 rcop_no_action,
160 160 rcop_no_usage,
161 161 proc_stack_set,
162 162 rcop_no_test
163 163 };
164 164
165 165 /*
166 166 * process.max-file-descriptors / RLIMIT_NOFILE
167 167 */
168 168 static int
169 169 proc_nofile_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e, rctl_qty_t nv)
170 170 {
171 171 ASSERT(e->rcep_t == RCENTITY_PROCESS);
172 172 if (p->p_model == DATAMODEL_NATIVE)
173 173 nv = MIN(nv, rctl->rc_dict_entry->rcd_max_native);
174 174 else
175 175 nv = MIN(nv, rctl->rc_dict_entry->rcd_max_ilp32);
176 176
177 177 e->rcep_p.proc->p_fno_ctl = nv;
178 178
179 179 return (0);
180 180 }
181 181
182 182 static rctl_ops_t proc_nofile_ops = {
183 183 rcop_no_action,
184 184 rcop_no_usage,
185 185 proc_nofile_set,
186 186 rcop_absolute_test
187 187 };
188 188
189 189 /*
190 190 * process.max-address-space / RLIMIT_VMEM
191 191 */
192 192 static int
193 193 proc_vmem_set(rctl_t *rctl, struct proc *p, rctl_entity_p_t *e, rctl_qty_t nv)
194 194 {
195 195 ASSERT(e->rcep_t == RCENTITY_PROCESS);
196 196 if (p->p_model == DATAMODEL_ILP32)
197 197 nv = MIN(nv, rctl->rc_dict_entry->rcd_max_ilp32);
198 198 else
199 199 nv = MIN(nv, rctl->rc_dict_entry->rcd_max_native);
200 200
201 201 e->rcep_p.proc->p_vmem_ctl = nv;
202 202
203 203 return (0);
204 204 }
205 205
206 206 static rctl_ops_t proc_vmem_ops = {
207 207 rcop_no_action,
208 208 rcop_no_usage,
209 209 proc_vmem_set,
210 210 rcop_no_test
211 211 };
212 212
213 213 /*
214 214 * void rctlproc_default_init()
215 215 *
216 216 * Overview
217 217 * Establish default basic and privileged control values on the init process.
218 218 * These correspond to the soft and hard limits, respectively.
219 219 */
220 220 void
221 221 rctlproc_default_init(struct proc *initp, rctl_alloc_gp_t *gp)
222 222 {
223 223 struct rlimit64 rlp64;
224 224
225 225 /*
226 226 * RLIMIT_CPU: deny never, sigtoproc(pp, NULL, SIGXCPU).
227 227 */
228 228 rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
229 229 (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_CPU], initp, &rlp64, gp,
230 230 RCTL_LOCAL_SIGNAL, SIGXCPU, kcred);
231 231
232 232 /*
233 233 * RLIMIT_FSIZE: deny always, sigtoproc(pp, NULL, SIGXFSZ).
234 234 */
235 235 rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
236 236 (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_FSIZE], initp, &rlp64, gp,
237 237 RCTL_LOCAL_SIGNAL | RCTL_LOCAL_DENY, SIGXFSZ, kcred);
238 238
239 239 /*
240 240 * RLIMIT_DATA: deny always, no default action.
241 241 */
242 242 rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
243 243 (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_DATA], initp, &rlp64, gp,
244 244 RCTL_LOCAL_DENY, 0, kcred);
245 245
246 246 /*
247 247 * RLIMIT_STACK: deny always, no default action.
248 248 */
249 249 #ifdef __sparc
250 250 rlp64.rlim_cur = DFLSSIZ;
251 251 rlp64.rlim_max = LONG_MAX;
252 252 #else
253 253 rlp64.rlim_cur = DFLSSIZ;
254 254 rlp64.rlim_max = MAXSSIZ;
255 255 #endif
256 256 (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_STACK], initp, &rlp64, gp,
257 257 RCTL_LOCAL_DENY, 0, kcred);
258 258
259 259 /*
260 260 * RLIMIT_CORE: deny always, no default action.
261 261 */
262 262 rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
263 263 (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_CORE], initp, &rlp64, gp,
264 264 RCTL_LOCAL_DENY, 0, kcred);
265 265
266 266 /*
267 267 * RLIMIT_NOFILE: deny always, no action.
268 268 */
269 269 rlp64.rlim_cur = rlim_fd_cur;
270 270 rlp64.rlim_max = rlim_fd_max;
271 271 (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_NOFILE], initp, &rlp64,
272 272 gp, RCTL_LOCAL_DENY, 0, kcred);
273 273
274 274 /*
275 275 * RLIMIT_VMEM
276 276 */
277 277 rlp64.rlim_cur = rlp64.rlim_max = RLIM64_INFINITY;
278 278 (void) rctl_rlimit_set(rctlproc_legacy[RLIMIT_VMEM], initp, &rlp64, gp,
279 279 RCTL_LOCAL_DENY, 0, kcred);
280 280 }
↓ open down ↓ |
203 lines elided |
↑ open up ↑ |
281 281
282 282 /*
283 283 * void rctlproc_init()
284 284 *
285 285 * Overview
286 286 * Register the various resource controls associated with process entities.
287 287 * The historical rlim_infinity_map and rlim_infinity32_map are now encoded
288 288 * here as the native and ILP32 infinite values for each resource control.
289 289 */
290 290 void
291 -rctlproc_init()
291 +rctlproc_init(void)
292 292 {
293 293 rctl_set_t *set;
294 294 rctl_alloc_gp_t *gp;
295 295 rctl_entity_p_t e;
296 296
297 297 rctlproc_legacy[RLIMIT_CPU] = rctl_register("process.max-cpu-time",
298 298 RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_NEVER |
299 299 RCTL_GLOBAL_CPU_TIME | RCTL_GLOBAL_INFINITE | RCTL_GLOBAL_SECONDS,
300 300 UINT64_MAX, UINT64_MAX, &proc_cpu_time_ops);
301 301 rctlproc_legacy[RLIMIT_FSIZE] = rctl_register("process.max-file-size",
302 302 RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
303 303 RCTL_GLOBAL_FILE_SIZE | RCTL_GLOBAL_BYTES,
304 304 MAXOFFSET_T, MAXOFFSET_T, &proc_filesize_ops);
305 305 rctlproc_legacy[RLIMIT_DATA] = rctl_register("process.max-data-size",
306 306 RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
307 307 RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
308 308 ULONG_MAX, UINT32_MAX, &rctl_default_ops);
309 309 #ifdef _LP64
310 310 #ifdef __sparc
311 311 rctlproc_legacy[RLIMIT_STACK] = rctl_register("process.max-stack-size",
312 312 RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
313 313 RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
314 314 LONG_MAX, INT32_MAX, &proc_stack_ops);
315 315 #else /* __sparc */
316 316 rctlproc_legacy[RLIMIT_STACK] = rctl_register("process.max-stack-size",
317 317 RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
318 318 RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
319 319 MAXSSIZ, USRSTACK32 - PAGESIZE, &proc_stack_ops);
320 320 #endif /* __sparc */
321 321 #else /* _LP64 */
322 322 rctlproc_legacy[RLIMIT_STACK] = rctl_register("process.max-stack-size",
323 323 RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
324 324 RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
325 325 USRSTACK - PAGESIZE, USRSTACK - PAGESIZE, &proc_stack_ops);
326 326 #endif
327 327 rctlproc_legacy[RLIMIT_CORE] = rctl_register("process.max-core-size",
328 328 RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
329 329 RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
330 330 MIN(MAXOFFSET_T, ULONG_MAX), UINT32_MAX, &rctl_default_ops);
331 331 rctlproc_legacy[RLIMIT_NOFILE] = rctl_register(
332 332 "process.max-file-descriptor", RCENTITY_PROCESS,
333 333 RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
334 334 RCTL_GLOBAL_COUNT, INT32_MAX, INT32_MAX, &proc_nofile_ops);
335 335 rctlproc_legacy[RLIMIT_VMEM] =
336 336 rctl_register("process.max-address-space", RCENTITY_PROCESS,
337 337 RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
338 338 RCTL_GLOBAL_SIGNAL_NEVER | RCTL_GLOBAL_BYTES,
339 339 ULONG_MAX, UINT32_MAX, &proc_vmem_ops);
340 340
341 341 rc_process_semmsl = rctl_register("process.max-sem-nsems",
342 342 RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_COUNT,
343 343 SHRT_MAX, SHRT_MAX, &rctl_absolute_ops);
344 344 rctl_add_legacy_limit("process.max-sem-nsems", "semsys",
345 345 "seminfo_semmsl", 512, SHRT_MAX);
346 346
347 347 rc_process_semopm = rctl_register("process.max-sem-ops",
348 348 RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_COUNT,
349 349 INT_MAX, INT_MAX, &rctl_absolute_ops);
350 350 rctl_add_legacy_limit("process.max-sem-ops", "semsys",
351 351 "seminfo_semopm", 512, INT_MAX);
352 352
353 353 rc_process_msgmnb = rctl_register("process.max-msg-qbytes",
354 354 RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_BYTES,
355 355 ULONG_MAX, ULONG_MAX, &rctl_absolute_ops);
356 356 rctl_add_legacy_limit("process.max-msg-qbytes", "msgsys",
357 357 "msginfo_msgmnb", 65536, ULONG_MAX);
358 358
359 359 rc_process_msgtql = rctl_register("process.max-msg-messages",
360 360 RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_COUNT,
↓ open down ↓ |
59 lines elided |
↑ open up ↑ |
361 361 UINT_MAX, UINT_MAX, &rctl_absolute_ops);
362 362 rctl_add_legacy_limit("process.max-msg-messages", "msgsys",
363 363 "msginfo_msgtql", 8192, UINT_MAX);
364 364
365 365 rc_process_portev = rctl_register("process.max-port-events",
366 366 RCENTITY_PROCESS, RCTL_GLOBAL_DENY_ALWAYS | RCTL_GLOBAL_COUNT,
367 367 PORT_MAX_EVENTS, PORT_MAX_EVENTS, &rctl_absolute_ops);
368 368 rctl_add_default_limit("process.max-port-events", PORT_DEFAULT_EVENTS,
369 369 RCPRIV_PRIVILEGED, RCTL_LOCAL_DENY);
370 370
371 + rc_process_sigqueue = rctl_register("process.max-sigqueue-size",
372 + RCENTITY_PROCESS, RCTL_GLOBAL_LOWERABLE | RCTL_GLOBAL_DENY_ALWAYS |
373 + RCTL_GLOBAL_COUNT, _SIGQSZ_MAX, _SIGQSZ_MAX, &rctl_absolute_ops);
374 + rctl_add_default_limit("process.max-sigqueue-size", _SIGQSZ_DEFAULT,
375 + RCPRIV_BASIC, RCTL_LOCAL_DENY);
376 + rctl_add_default_limit("process.max-sigqueue-size", _SIGQSZ_PRIVILEGED,
377 + RCPRIV_PRIVILEGED, RCTL_LOCAL_DENY);
378 +
371 379 /*
372 380 * Place minimal set of controls on "sched" process for inheritance by
373 381 * processes created via newproc().
374 382 */
375 383 set = rctl_set_create();
376 384 gp = rctl_set_init_prealloc(RCENTITY_PROCESS);
377 385 mutex_enter(&curproc->p_lock);
378 386 e.rcep_p.proc = curproc;
379 387 e.rcep_t = RCENTITY_PROCESS;
380 388 curproc->p_rctls = rctl_set_init(RCENTITY_PROCESS, curproc, &e,
381 389 set, gp);
382 390 mutex_exit(&curproc->p_lock);
383 391 rctl_prealloc_destroy(gp);
384 392 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX