.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | |
---|
2 | 3 | /* |
---|
3 | 4 | * DECnet An implementation of the DECnet protocol suite for the LINUX |
---|
.. | .. |
---|
46 | 47 | /****************************************************************************** |
---|
47 | 48 | (c) 1995-1998 E.M. Serrat emserrat@geocities.com |
---|
48 | 49 | |
---|
49 | | - This program is free software; you can redistribute it and/or modify |
---|
50 | | - it under the terms of the GNU General Public License as published by |
---|
51 | | - the Free Software Foundation; either version 2 of the License, or |
---|
52 | | - any later version. |
---|
53 | | - |
---|
54 | | - This program is distributed in the hope that it will be useful, |
---|
55 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
56 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
57 | | - GNU General Public License for more details. |
---|
58 | 50 | |
---|
59 | 51 | HISTORY: |
---|
60 | 52 | |
---|
.. | .. |
---|
158 | 150 | static struct hlist_head dn_wild_sk; |
---|
159 | 151 | static atomic_long_t decnet_memory_allocated; |
---|
160 | 152 | |
---|
161 | | -static int __dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen, int flags); |
---|
| 153 | +static int __dn_setsockopt(struct socket *sock, int level, int optname, |
---|
| 154 | + sockptr_t optval, unsigned int optlen, int flags); |
---|
162 | 155 | static int __dn_getsockopt(struct socket *sock, int level, int optname, char __user *optval, int __user *optlen, int flags); |
---|
163 | 156 | |
---|
164 | 157 | static struct hlist_head *dn_find_list(struct sock *sk) |
---|
.. | .. |
---|
192 | 185 | static unsigned short port_alloc(struct sock *sk) |
---|
193 | 186 | { |
---|
194 | 187 | struct dn_scp *scp = DN_SK(sk); |
---|
195 | | -static unsigned short port = 0x2000; |
---|
| 188 | + static unsigned short port = 0x2000; |
---|
196 | 189 | unsigned short i_port = port; |
---|
197 | 190 | |
---|
198 | 191 | while(check_port(cpu_to_le16(++port)) != 0) { |
---|
.. | .. |
---|
444 | 437 | skb_queue_purge(&scp->other_xmit_queue); |
---|
445 | 438 | skb_queue_purge(&scp->other_receive_queue); |
---|
446 | 439 | |
---|
447 | | - dst_release(rcu_dereference_check(sk->sk_dst_cache, 1)); |
---|
| 440 | + dst_release(rcu_dereference_protected(sk->sk_dst_cache, 1)); |
---|
448 | 441 | } |
---|
449 | 442 | |
---|
450 | 443 | static unsigned long dn_memory_pressure; |
---|
.. | .. |
---|
487 | 480 | sk->sk_family = PF_DECnet; |
---|
488 | 481 | sk->sk_protocol = 0; |
---|
489 | 482 | sk->sk_allocation = gfp; |
---|
490 | | - sk->sk_sndbuf = sysctl_decnet_wmem[1]; |
---|
491 | | - sk->sk_rcvbuf = sysctl_decnet_rmem[1]; |
---|
| 483 | + sk->sk_sndbuf = READ_ONCE(sysctl_decnet_wmem[1]); |
---|
| 484 | + sk->sk_rcvbuf = READ_ONCE(sysctl_decnet_rmem[1]); |
---|
492 | 485 | |
---|
493 | 486 | /* Initialization of DECnet Session Control Port */ |
---|
494 | 487 | scp = DN_SK(sk); |
---|
.. | .. |
---|
630 | 623 | goto disc_reject; |
---|
631 | 624 | case DN_RUN: |
---|
632 | 625 | scp->state = DN_DI; |
---|
633 | | - /* fall through */ |
---|
| 626 | + fallthrough; |
---|
634 | 627 | case DN_DI: |
---|
635 | 628 | case DN_DR: |
---|
636 | 629 | disc_reject: |
---|
637 | 630 | dn_nsp_send_disc(sk, NSP_DISCINIT, 0, sk->sk_allocation); |
---|
638 | | - /* fall through */ |
---|
| 631 | + fallthrough; |
---|
639 | 632 | case DN_NC: |
---|
640 | 633 | case DN_NR: |
---|
641 | 634 | case DN_RJ: |
---|
.. | .. |
---|
649 | 642 | break; |
---|
650 | 643 | default: |
---|
651 | 644 | printk(KERN_DEBUG "DECnet: dn_destroy_sock passed socket in invalid state\n"); |
---|
652 | | - /* fall through */ |
---|
| 645 | + fallthrough; |
---|
653 | 646 | case DN_O: |
---|
654 | 647 | dn_stop_slow_timer(sk); |
---|
655 | 648 | |
---|
.. | .. |
---|
678 | 671 | { |
---|
679 | 672 | struct sock *sk; |
---|
680 | 673 | |
---|
681 | | - if (protocol < 0 || protocol > SK_PROTOCOL_MAX) |
---|
| 674 | + if (protocol < 0 || protocol > U8_MAX) |
---|
682 | 675 | return -EINVAL; |
---|
683 | 676 | |
---|
684 | 677 | if (!net_eq(net, &init_net)) |
---|
.. | .. |
---|
1096 | 1089 | } |
---|
1097 | 1090 | |
---|
1098 | 1091 | cb = DN_SKB_CB(skb); |
---|
1099 | | - sk->sk_ack_backlog--; |
---|
| 1092 | + sk_acceptq_removed(sk); |
---|
1100 | 1093 | newsk = dn_alloc_sock(sock_net(sk), newsock, sk->sk_allocation, kern); |
---|
1101 | 1094 | if (newsk == NULL) { |
---|
1102 | 1095 | release_sock(sk); |
---|
.. | .. |
---|
1325 | 1318 | return err; |
---|
1326 | 1319 | } |
---|
1327 | 1320 | |
---|
1328 | | -static int dn_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen) |
---|
| 1321 | +static int dn_setsockopt(struct socket *sock, int level, int optname, |
---|
| 1322 | + sockptr_t optval, unsigned int optlen) |
---|
1329 | 1323 | { |
---|
1330 | 1324 | struct sock *sk = sock->sk; |
---|
1331 | 1325 | int err; |
---|
.. | .. |
---|
1343 | 1337 | return err; |
---|
1344 | 1338 | } |
---|
1345 | 1339 | |
---|
1346 | | -static int __dn_setsockopt(struct socket *sock, int level,int optname, char __user *optval, unsigned int optlen, int flags) |
---|
| 1340 | +static int __dn_setsockopt(struct socket *sock, int level, int optname, |
---|
| 1341 | + sockptr_t optval, unsigned int optlen, int flags) |
---|
1347 | 1342 | { |
---|
1348 | 1343 | struct sock *sk = sock->sk; |
---|
1349 | 1344 | struct dn_scp *scp = DN_SK(sk); |
---|
.. | .. |
---|
1359 | 1354 | } u; |
---|
1360 | 1355 | int err; |
---|
1361 | 1356 | |
---|
1362 | | - if (optlen && !optval) |
---|
| 1357 | + if (optlen && sockptr_is_null(optval)) |
---|
1363 | 1358 | return -EINVAL; |
---|
1364 | 1359 | |
---|
1365 | 1360 | if (optlen > sizeof(u)) |
---|
1366 | 1361 | return -EINVAL; |
---|
1367 | 1362 | |
---|
1368 | | - if (copy_from_user(&u, optval, optlen)) |
---|
| 1363 | + if (copy_from_sockptr(&u, optval, optlen)) |
---|
1369 | 1364 | return -EFAULT; |
---|
1370 | 1365 | |
---|
1371 | 1366 | switch (optname) { |
---|
.. | .. |
---|
2139 | 2134 | struct dn_iter_state *state = seq->private; |
---|
2140 | 2135 | |
---|
2141 | 2136 | n = sk_next(n); |
---|
2142 | | -try_again: |
---|
2143 | | - if (n) |
---|
2144 | | - goto out; |
---|
2145 | | - if (++state->bucket >= DN_SK_HASH_SIZE) |
---|
2146 | | - goto out; |
---|
2147 | | - n = sk_head(&dn_sk_hash[state->bucket]); |
---|
2148 | | - goto try_again; |
---|
2149 | | -out: |
---|
| 2137 | + while (!n) { |
---|
| 2138 | + if (++state->bucket >= DN_SK_HASH_SIZE) |
---|
| 2139 | + break; |
---|
| 2140 | + n = sk_head(&dn_sk_hash[state->bucket]); |
---|
| 2141 | + } |
---|
2150 | 2142 | return n; |
---|
2151 | 2143 | } |
---|
2152 | 2144 | |
---|
.. | .. |
---|
2402 | 2394 | |
---|
2403 | 2395 | proto_unregister(&dn_proto); |
---|
2404 | 2396 | |
---|
2405 | | - rcu_barrier_bh(); /* Wait for completion of call_rcu_bh()'s */ |
---|
| 2397 | + rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
---|
2406 | 2398 | } |
---|
2407 | 2399 | module_exit(decnet_exit); |
---|
2408 | 2400 | #endif |
---|