.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* SCTP kernel implementation |
---|
2 | 3 | * (C) Copyright IBM Corp. 2002, 2004 |
---|
3 | 4 | * Copyright (c) 2002 Intel Corp. |
---|
.. | .. |
---|
5 | 6 | * This file is part of the SCTP kernel implementation |
---|
6 | 7 | * |
---|
7 | 8 | * Sysctl related interfaces for SCTP. |
---|
8 | | - * |
---|
9 | | - * This SCTP implementation is free software; |
---|
10 | | - * you can redistribute it and/or modify it under the terms of |
---|
11 | | - * the GNU General Public License as published by |
---|
12 | | - * the Free Software Foundation; either version 2, or (at your option) |
---|
13 | | - * any later version. |
---|
14 | | - * |
---|
15 | | - * This SCTP implementation is distributed in the hope that it |
---|
16 | | - * will be useful, but WITHOUT ANY WARRANTY; without even the implied |
---|
17 | | - * ************************ |
---|
18 | | - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
---|
19 | | - * See the GNU General Public License for more details. |
---|
20 | | - * |
---|
21 | | - * You should have received a copy of the GNU General Public License |
---|
22 | | - * along with GNU CC; see the file COPYING. If not, see |
---|
23 | | - * <http://www.gnu.org/licenses/>. |
---|
24 | 9 | * |
---|
25 | 10 | * Please send any bug reports or fixes you make to the |
---|
26 | 11 | * email address(es): |
---|
.. | .. |
---|
40 | 25 | #include <net/sctp/sctp.h> |
---|
41 | 26 | #include <linux/sysctl.h> |
---|
42 | 27 | |
---|
43 | | -static int zero = 0; |
---|
44 | | -static int one = 1; |
---|
45 | 28 | static int timer_max = 86400000; /* ms in one day */ |
---|
46 | | -static int int_max = INT_MAX; |
---|
47 | 29 | static int sack_timer_min = 1; |
---|
48 | 30 | static int sack_timer_max = 500; |
---|
49 | 31 | static int addr_scope_max = SCTP_SCOPE_POLICY_MAX; |
---|
.. | .. |
---|
52 | 34 | static int rto_beta_min = 0; |
---|
53 | 35 | static int rto_alpha_max = 1000; |
---|
54 | 36 | static int rto_beta_max = 1000; |
---|
| 37 | +static int pf_expose_max = SCTP_PF_EXPOSE_MAX; |
---|
| 38 | +static int ps_retrans_max = SCTP_PS_RETRANS_MAX; |
---|
55 | 39 | |
---|
56 | 40 | static unsigned long max_autoclose_min = 0; |
---|
57 | 41 | static unsigned long max_autoclose_max = |
---|
.. | .. |
---|
59 | 43 | ? UINT_MAX : MAX_SCHEDULE_TIMEOUT / HZ; |
---|
60 | 44 | |
---|
61 | 45 | static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write, |
---|
62 | | - void __user *buffer, size_t *lenp, |
---|
63 | | - loff_t *ppos); |
---|
| 46 | + void *buffer, size_t *lenp, loff_t *ppos); |
---|
64 | 47 | static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write, |
---|
65 | | - void __user *buffer, size_t *lenp, |
---|
66 | | - loff_t *ppos); |
---|
67 | | -static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, |
---|
68 | | - void __user *buffer, size_t *lenp, |
---|
69 | | - loff_t *ppos); |
---|
| 48 | + void *buffer, size_t *lenp, loff_t *ppos); |
---|
| 49 | +static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, void *buffer, |
---|
| 50 | + size_t *lenp, loff_t *ppos); |
---|
70 | 51 | static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write, |
---|
71 | | - void __user *buffer, size_t *lenp, |
---|
72 | | - loff_t *ppos); |
---|
| 52 | + void *buffer, size_t *lenp, loff_t *ppos); |
---|
73 | 53 | static int proc_sctp_do_auth(struct ctl_table *ctl, int write, |
---|
74 | | - void __user *buffer, size_t *lenp, |
---|
75 | | - loff_t *ppos); |
---|
| 54 | + void *buffer, size_t *lenp, loff_t *ppos); |
---|
76 | 55 | |
---|
77 | 56 | static struct ctl_table sctp_table[] = { |
---|
78 | 57 | { |
---|
.. | .. |
---|
100 | 79 | { /* sentinel */ } |
---|
101 | 80 | }; |
---|
102 | 81 | |
---|
| 82 | +/* The following index defines are used in sctp_sysctl_net_register(). |
---|
| 83 | + * If you add new items to the sctp_net_table, please ensure that |
---|
| 84 | + * the index values of these defines hold the same meaning indicated by |
---|
| 85 | + * their macro names when they appear in sctp_net_table. |
---|
| 86 | + */ |
---|
| 87 | +#define SCTP_RTO_MIN_IDX 0 |
---|
| 88 | +#define SCTP_RTO_MAX_IDX 1 |
---|
| 89 | +#define SCTP_PF_RETRANS_IDX 2 |
---|
| 90 | +#define SCTP_PS_RETRANS_IDX 3 |
---|
| 91 | + |
---|
103 | 92 | static struct ctl_table sctp_net_table[] = { |
---|
104 | | - { |
---|
105 | | - .procname = "rto_initial", |
---|
106 | | - .data = &init_net.sctp.rto_initial, |
---|
107 | | - .maxlen = sizeof(unsigned int), |
---|
108 | | - .mode = 0644, |
---|
109 | | - .proc_handler = proc_dointvec_minmax, |
---|
110 | | - .extra1 = &one, |
---|
111 | | - .extra2 = &timer_max |
---|
112 | | - }, |
---|
113 | | - { |
---|
| 93 | + [SCTP_RTO_MIN_IDX] = { |
---|
114 | 94 | .procname = "rto_min", |
---|
115 | 95 | .data = &init_net.sctp.rto_min, |
---|
116 | 96 | .maxlen = sizeof(unsigned int), |
---|
117 | 97 | .mode = 0644, |
---|
118 | 98 | .proc_handler = proc_sctp_do_rto_min, |
---|
119 | | - .extra1 = &one, |
---|
| 99 | + .extra1 = SYSCTL_ONE, |
---|
120 | 100 | .extra2 = &init_net.sctp.rto_max |
---|
121 | 101 | }, |
---|
122 | | - { |
---|
| 102 | + [SCTP_RTO_MAX_IDX] = { |
---|
123 | 103 | .procname = "rto_max", |
---|
124 | 104 | .data = &init_net.sctp.rto_max, |
---|
125 | 105 | .maxlen = sizeof(unsigned int), |
---|
126 | 106 | .mode = 0644, |
---|
127 | 107 | .proc_handler = proc_sctp_do_rto_max, |
---|
128 | 108 | .extra1 = &init_net.sctp.rto_min, |
---|
| 109 | + .extra2 = &timer_max |
---|
| 110 | + }, |
---|
| 111 | + [SCTP_PF_RETRANS_IDX] = { |
---|
| 112 | + .procname = "pf_retrans", |
---|
| 113 | + .data = &init_net.sctp.pf_retrans, |
---|
| 114 | + .maxlen = sizeof(int), |
---|
| 115 | + .mode = 0644, |
---|
| 116 | + .proc_handler = proc_dointvec_minmax, |
---|
| 117 | + .extra1 = SYSCTL_ZERO, |
---|
| 118 | + .extra2 = &init_net.sctp.ps_retrans, |
---|
| 119 | + }, |
---|
| 120 | + [SCTP_PS_RETRANS_IDX] = { |
---|
| 121 | + .procname = "ps_retrans", |
---|
| 122 | + .data = &init_net.sctp.ps_retrans, |
---|
| 123 | + .maxlen = sizeof(int), |
---|
| 124 | + .mode = 0644, |
---|
| 125 | + .proc_handler = proc_dointvec_minmax, |
---|
| 126 | + .extra1 = &init_net.sctp.pf_retrans, |
---|
| 127 | + .extra2 = &ps_retrans_max, |
---|
| 128 | + }, |
---|
| 129 | + { |
---|
| 130 | + .procname = "rto_initial", |
---|
| 131 | + .data = &init_net.sctp.rto_initial, |
---|
| 132 | + .maxlen = sizeof(unsigned int), |
---|
| 133 | + .mode = 0644, |
---|
| 134 | + .proc_handler = proc_dointvec_minmax, |
---|
| 135 | + .extra1 = SYSCTL_ONE, |
---|
129 | 136 | .extra2 = &timer_max |
---|
130 | 137 | }, |
---|
131 | 138 | { |
---|
.. | .. |
---|
152 | 159 | .maxlen = sizeof(int), |
---|
153 | 160 | .mode = 0644, |
---|
154 | 161 | .proc_handler = proc_dointvec_minmax, |
---|
155 | | - .extra1 = &zero, |
---|
156 | | - .extra2 = &int_max |
---|
| 162 | + .extra1 = SYSCTL_ZERO, |
---|
| 163 | + .extra2 = SYSCTL_INT_MAX, |
---|
157 | 164 | }, |
---|
158 | 165 | { |
---|
159 | 166 | .procname = "cookie_preserve_enable", |
---|
.. | .. |
---|
175 | 182 | .maxlen = sizeof(unsigned int), |
---|
176 | 183 | .mode = 0644, |
---|
177 | 184 | .proc_handler = proc_dointvec_minmax, |
---|
178 | | - .extra1 = &one, |
---|
| 185 | + .extra1 = SYSCTL_ONE, |
---|
179 | 186 | .extra2 = &timer_max |
---|
180 | 187 | }, |
---|
181 | 188 | { |
---|
.. | .. |
---|
193 | 200 | .maxlen = sizeof(unsigned int), |
---|
194 | 201 | .mode = 0644, |
---|
195 | 202 | .proc_handler = proc_dointvec_minmax, |
---|
196 | | - .extra1 = &one, |
---|
| 203 | + .extra1 = SYSCTL_ONE, |
---|
197 | 204 | .extra2 = &timer_max |
---|
198 | 205 | }, |
---|
199 | 206 | { |
---|
.. | .. |
---|
202 | 209 | .maxlen = sizeof(int), |
---|
203 | 210 | .mode = 0644, |
---|
204 | 211 | .proc_handler = proc_dointvec_minmax, |
---|
205 | | - .extra1 = &one, |
---|
206 | | - .extra2 = &int_max |
---|
| 212 | + .extra1 = SYSCTL_ONE, |
---|
| 213 | + .extra2 = SYSCTL_INT_MAX, |
---|
207 | 214 | }, |
---|
208 | 215 | { |
---|
209 | 216 | .procname = "path_max_retrans", |
---|
.. | .. |
---|
211 | 218 | .maxlen = sizeof(int), |
---|
212 | 219 | .mode = 0644, |
---|
213 | 220 | .proc_handler = proc_dointvec_minmax, |
---|
214 | | - .extra1 = &one, |
---|
215 | | - .extra2 = &int_max |
---|
| 221 | + .extra1 = SYSCTL_ONE, |
---|
| 222 | + .extra2 = SYSCTL_INT_MAX, |
---|
216 | 223 | }, |
---|
217 | 224 | { |
---|
218 | 225 | .procname = "max_init_retransmits", |
---|
.. | .. |
---|
220 | 227 | .maxlen = sizeof(int), |
---|
221 | 228 | .mode = 0644, |
---|
222 | 229 | .proc_handler = proc_dointvec_minmax, |
---|
223 | | - .extra1 = &one, |
---|
224 | | - .extra2 = &int_max |
---|
225 | | - }, |
---|
226 | | - { |
---|
227 | | - .procname = "pf_retrans", |
---|
228 | | - .data = &init_net.sctp.pf_retrans, |
---|
229 | | - .maxlen = sizeof(int), |
---|
230 | | - .mode = 0644, |
---|
231 | | - .proc_handler = proc_dointvec_minmax, |
---|
232 | | - .extra1 = &zero, |
---|
233 | | - .extra2 = &int_max |
---|
| 230 | + .extra1 = SYSCTL_ONE, |
---|
| 231 | + .extra2 = SYSCTL_INT_MAX, |
---|
234 | 232 | }, |
---|
235 | 233 | { |
---|
236 | 234 | .procname = "sndbuf_policy", |
---|
.. | .. |
---|
296 | 294 | .proc_handler = proc_dointvec, |
---|
297 | 295 | }, |
---|
298 | 296 | { |
---|
| 297 | + .procname = "ecn_enable", |
---|
| 298 | + .data = &init_net.sctp.ecn_enable, |
---|
| 299 | + .maxlen = sizeof(int), |
---|
| 300 | + .mode = 0644, |
---|
| 301 | + .proc_handler = proc_dointvec, |
---|
| 302 | + }, |
---|
| 303 | + { |
---|
299 | 304 | .procname = "addr_scope_policy", |
---|
300 | 305 | .data = &init_net.sctp.scope_policy, |
---|
301 | 306 | .maxlen = sizeof(int), |
---|
302 | 307 | .mode = 0644, |
---|
303 | 308 | .proc_handler = proc_dointvec_minmax, |
---|
304 | | - .extra1 = &zero, |
---|
| 309 | + .extra1 = SYSCTL_ZERO, |
---|
305 | 310 | .extra2 = &addr_scope_max, |
---|
306 | 311 | }, |
---|
307 | 312 | { |
---|
.. | .. |
---|
310 | 315 | .maxlen = sizeof(int), |
---|
311 | 316 | .mode = 0644, |
---|
312 | 317 | .proc_handler = &proc_dointvec_minmax, |
---|
313 | | - .extra1 = &one, |
---|
| 318 | + .extra1 = SYSCTL_ONE, |
---|
314 | 319 | .extra2 = &rwnd_scale_max, |
---|
315 | 320 | }, |
---|
316 | 321 | { |
---|
.. | .. |
---|
329 | 334 | .mode = 0644, |
---|
330 | 335 | .proc_handler = proc_dointvec, |
---|
331 | 336 | }, |
---|
| 337 | + { |
---|
| 338 | + .procname = "pf_expose", |
---|
| 339 | + .data = &init_net.sctp.pf_expose, |
---|
| 340 | + .maxlen = sizeof(int), |
---|
| 341 | + .mode = 0644, |
---|
| 342 | + .proc_handler = proc_dointvec_minmax, |
---|
| 343 | + .extra1 = SYSCTL_ZERO, |
---|
| 344 | + .extra2 = &pf_expose_max, |
---|
| 345 | + }, |
---|
332 | 346 | |
---|
333 | 347 | { /* sentinel */ } |
---|
334 | 348 | }; |
---|
335 | 349 | |
---|
336 | 350 | static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write, |
---|
337 | | - void __user *buffer, size_t *lenp, |
---|
338 | | - loff_t *ppos) |
---|
| 351 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
339 | 352 | { |
---|
340 | 353 | struct net *net = current->nsproxy->net_ns; |
---|
341 | 354 | struct ctl_table tbl; |
---|
.. | .. |
---|
380 | 393 | } |
---|
381 | 394 | |
---|
382 | 395 | static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write, |
---|
383 | | - void __user *buffer, size_t *lenp, |
---|
384 | | - loff_t *ppos) |
---|
| 396 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
385 | 397 | { |
---|
386 | 398 | struct net *net = current->nsproxy->net_ns; |
---|
387 | 399 | unsigned int min = *(unsigned int *) ctl->extra1; |
---|
.. | .. |
---|
409 | 421 | } |
---|
410 | 422 | |
---|
411 | 423 | static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, |
---|
412 | | - void __user *buffer, size_t *lenp, |
---|
413 | | - loff_t *ppos) |
---|
| 424 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
414 | 425 | { |
---|
415 | 426 | struct net *net = current->nsproxy->net_ns; |
---|
416 | 427 | unsigned int min = *(unsigned int *) ctl->extra1; |
---|
.. | .. |
---|
438 | 449 | } |
---|
439 | 450 | |
---|
440 | 451 | static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write, |
---|
441 | | - void __user *buffer, size_t *lenp, |
---|
442 | | - loff_t *ppos) |
---|
| 452 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
443 | 453 | { |
---|
444 | 454 | if (write) |
---|
445 | 455 | pr_warn_once("Changing rto_alpha or rto_beta may lead to " |
---|
.. | .. |
---|
449 | 459 | } |
---|
450 | 460 | |
---|
451 | 461 | static int proc_sctp_do_auth(struct ctl_table *ctl, int write, |
---|
452 | | - void __user *buffer, size_t *lenp, |
---|
453 | | - loff_t *ppos) |
---|
| 462 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
454 | 463 | { |
---|
455 | 464 | struct net *net = current->nsproxy->net_ns; |
---|
456 | 465 | struct ctl_table tbl; |
---|
.. | .. |
---|
490 | 499 | for (i = 0; table[i].data; i++) |
---|
491 | 500 | table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; |
---|
492 | 501 | |
---|
| 502 | + table[SCTP_RTO_MIN_IDX].extra2 = &net->sctp.rto_max; |
---|
| 503 | + table[SCTP_RTO_MAX_IDX].extra1 = &net->sctp.rto_min; |
---|
| 504 | + table[SCTP_PF_RETRANS_IDX].extra2 = &net->sctp.ps_retrans; |
---|
| 505 | + table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans; |
---|
| 506 | + |
---|
493 | 507 | net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); |
---|
494 | 508 | if (net->sctp.sysctl_header == NULL) { |
---|
495 | 509 | kfree(table); |
---|