.. | .. |
---|
| 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 | { |
---|
.. | .. |
---|
107 | 86 | .maxlen = sizeof(unsigned int), |
---|
108 | 87 | .mode = 0644, |
---|
109 | 88 | .proc_handler = proc_dointvec_minmax, |
---|
110 | | - .extra1 = &one, |
---|
| 89 | + .extra1 = SYSCTL_ONE, |
---|
111 | 90 | .extra2 = &timer_max |
---|
112 | 91 | }, |
---|
113 | 92 | { |
---|
.. | .. |
---|
116 | 95 | .maxlen = sizeof(unsigned int), |
---|
117 | 96 | .mode = 0644, |
---|
118 | 97 | .proc_handler = proc_sctp_do_rto_min, |
---|
119 | | - .extra1 = &one, |
---|
| 98 | + .extra1 = SYSCTL_ONE, |
---|
120 | 99 | .extra2 = &init_net.sctp.rto_max |
---|
121 | 100 | }, |
---|
122 | 101 | { |
---|
.. | .. |
---|
152 | 131 | .maxlen = sizeof(int), |
---|
153 | 132 | .mode = 0644, |
---|
154 | 133 | .proc_handler = proc_dointvec_minmax, |
---|
155 | | - .extra1 = &zero, |
---|
156 | | - .extra2 = &int_max |
---|
| 134 | + .extra1 = SYSCTL_ZERO, |
---|
| 135 | + .extra2 = SYSCTL_INT_MAX, |
---|
157 | 136 | }, |
---|
158 | 137 | { |
---|
159 | 138 | .procname = "cookie_preserve_enable", |
---|
.. | .. |
---|
175 | 154 | .maxlen = sizeof(unsigned int), |
---|
176 | 155 | .mode = 0644, |
---|
177 | 156 | .proc_handler = proc_dointvec_minmax, |
---|
178 | | - .extra1 = &one, |
---|
| 157 | + .extra1 = SYSCTL_ONE, |
---|
179 | 158 | .extra2 = &timer_max |
---|
180 | 159 | }, |
---|
181 | 160 | { |
---|
.. | .. |
---|
193 | 172 | .maxlen = sizeof(unsigned int), |
---|
194 | 173 | .mode = 0644, |
---|
195 | 174 | .proc_handler = proc_dointvec_minmax, |
---|
196 | | - .extra1 = &one, |
---|
| 175 | + .extra1 = SYSCTL_ONE, |
---|
197 | 176 | .extra2 = &timer_max |
---|
198 | 177 | }, |
---|
199 | 178 | { |
---|
.. | .. |
---|
202 | 181 | .maxlen = sizeof(int), |
---|
203 | 182 | .mode = 0644, |
---|
204 | 183 | .proc_handler = proc_dointvec_minmax, |
---|
205 | | - .extra1 = &one, |
---|
206 | | - .extra2 = &int_max |
---|
| 184 | + .extra1 = SYSCTL_ONE, |
---|
| 185 | + .extra2 = SYSCTL_INT_MAX, |
---|
207 | 186 | }, |
---|
208 | 187 | { |
---|
209 | 188 | .procname = "path_max_retrans", |
---|
.. | .. |
---|
211 | 190 | .maxlen = sizeof(int), |
---|
212 | 191 | .mode = 0644, |
---|
213 | 192 | .proc_handler = proc_dointvec_minmax, |
---|
214 | | - .extra1 = &one, |
---|
215 | | - .extra2 = &int_max |
---|
| 193 | + .extra1 = SYSCTL_ONE, |
---|
| 194 | + .extra2 = SYSCTL_INT_MAX, |
---|
216 | 195 | }, |
---|
217 | 196 | { |
---|
218 | 197 | .procname = "max_init_retransmits", |
---|
.. | .. |
---|
220 | 199 | .maxlen = sizeof(int), |
---|
221 | 200 | .mode = 0644, |
---|
222 | 201 | .proc_handler = proc_dointvec_minmax, |
---|
223 | | - .extra1 = &one, |
---|
224 | | - .extra2 = &int_max |
---|
| 202 | + .extra1 = SYSCTL_ONE, |
---|
| 203 | + .extra2 = SYSCTL_INT_MAX, |
---|
225 | 204 | }, |
---|
226 | 205 | { |
---|
227 | 206 | .procname = "pf_retrans", |
---|
.. | .. |
---|
229 | 208 | .maxlen = sizeof(int), |
---|
230 | 209 | .mode = 0644, |
---|
231 | 210 | .proc_handler = proc_dointvec_minmax, |
---|
232 | | - .extra1 = &zero, |
---|
233 | | - .extra2 = &int_max |
---|
| 211 | + .extra1 = SYSCTL_ZERO, |
---|
| 212 | + .extra2 = &init_net.sctp.ps_retrans, |
---|
| 213 | + }, |
---|
| 214 | + { |
---|
| 215 | + .procname = "ps_retrans", |
---|
| 216 | + .data = &init_net.sctp.ps_retrans, |
---|
| 217 | + .maxlen = sizeof(int), |
---|
| 218 | + .mode = 0644, |
---|
| 219 | + .proc_handler = proc_dointvec_minmax, |
---|
| 220 | + .extra1 = &init_net.sctp.pf_retrans, |
---|
| 221 | + .extra2 = &ps_retrans_max, |
---|
234 | 222 | }, |
---|
235 | 223 | { |
---|
236 | 224 | .procname = "sndbuf_policy", |
---|
.. | .. |
---|
296 | 284 | .proc_handler = proc_dointvec, |
---|
297 | 285 | }, |
---|
298 | 286 | { |
---|
| 287 | + .procname = "ecn_enable", |
---|
| 288 | + .data = &init_net.sctp.ecn_enable, |
---|
| 289 | + .maxlen = sizeof(int), |
---|
| 290 | + .mode = 0644, |
---|
| 291 | + .proc_handler = proc_dointvec, |
---|
| 292 | + }, |
---|
| 293 | + { |
---|
299 | 294 | .procname = "addr_scope_policy", |
---|
300 | 295 | .data = &init_net.sctp.scope_policy, |
---|
301 | 296 | .maxlen = sizeof(int), |
---|
302 | 297 | .mode = 0644, |
---|
303 | 298 | .proc_handler = proc_dointvec_minmax, |
---|
304 | | - .extra1 = &zero, |
---|
| 299 | + .extra1 = SYSCTL_ZERO, |
---|
305 | 300 | .extra2 = &addr_scope_max, |
---|
306 | 301 | }, |
---|
307 | 302 | { |
---|
.. | .. |
---|
310 | 305 | .maxlen = sizeof(int), |
---|
311 | 306 | .mode = 0644, |
---|
312 | 307 | .proc_handler = &proc_dointvec_minmax, |
---|
313 | | - .extra1 = &one, |
---|
| 308 | + .extra1 = SYSCTL_ONE, |
---|
314 | 309 | .extra2 = &rwnd_scale_max, |
---|
315 | 310 | }, |
---|
316 | 311 | { |
---|
.. | .. |
---|
329 | 324 | .mode = 0644, |
---|
330 | 325 | .proc_handler = proc_dointvec, |
---|
331 | 326 | }, |
---|
| 327 | + { |
---|
| 328 | + .procname = "pf_expose", |
---|
| 329 | + .data = &init_net.sctp.pf_expose, |
---|
| 330 | + .maxlen = sizeof(int), |
---|
| 331 | + .mode = 0644, |
---|
| 332 | + .proc_handler = proc_dointvec_minmax, |
---|
| 333 | + .extra1 = SYSCTL_ZERO, |
---|
| 334 | + .extra2 = &pf_expose_max, |
---|
| 335 | + }, |
---|
332 | 336 | |
---|
333 | 337 | { /* sentinel */ } |
---|
334 | 338 | }; |
---|
335 | 339 | |
---|
336 | 340 | static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write, |
---|
337 | | - void __user *buffer, size_t *lenp, |
---|
338 | | - loff_t *ppos) |
---|
| 341 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
339 | 342 | { |
---|
340 | 343 | struct net *net = current->nsproxy->net_ns; |
---|
341 | 344 | struct ctl_table tbl; |
---|
.. | .. |
---|
380 | 383 | } |
---|
381 | 384 | |
---|
382 | 385 | static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write, |
---|
383 | | - void __user *buffer, size_t *lenp, |
---|
384 | | - loff_t *ppos) |
---|
| 386 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
385 | 387 | { |
---|
386 | 388 | struct net *net = current->nsproxy->net_ns; |
---|
387 | 389 | unsigned int min = *(unsigned int *) ctl->extra1; |
---|
.. | .. |
---|
409 | 411 | } |
---|
410 | 412 | |
---|
411 | 413 | static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, |
---|
412 | | - void __user *buffer, size_t *lenp, |
---|
413 | | - loff_t *ppos) |
---|
| 414 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
414 | 415 | { |
---|
415 | 416 | struct net *net = current->nsproxy->net_ns; |
---|
416 | 417 | unsigned int min = *(unsigned int *) ctl->extra1; |
---|
.. | .. |
---|
438 | 439 | } |
---|
439 | 440 | |
---|
440 | 441 | static int proc_sctp_do_alpha_beta(struct ctl_table *ctl, int write, |
---|
441 | | - void __user *buffer, size_t *lenp, |
---|
442 | | - loff_t *ppos) |
---|
| 442 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
443 | 443 | { |
---|
444 | 444 | if (write) |
---|
445 | 445 | pr_warn_once("Changing rto_alpha or rto_beta may lead to " |
---|
.. | .. |
---|
449 | 449 | } |
---|
450 | 450 | |
---|
451 | 451 | static int proc_sctp_do_auth(struct ctl_table *ctl, int write, |
---|
452 | | - void __user *buffer, size_t *lenp, |
---|
453 | | - loff_t *ppos) |
---|
| 452 | + void *buffer, size_t *lenp, loff_t *ppos) |
---|
454 | 453 | { |
---|
455 | 454 | struct net *net = current->nsproxy->net_ns; |
---|
456 | 455 | struct ctl_table tbl; |
---|