Christoph Hellwig says: ==================== do a single memdup_user in sctp_setsockopt v2 here is a resend of my series to lift the copy_from_user out of the individual sctp sockopt handlers into the main sctp_setsockopt routine. Changes since v1: - fixes a few sizeof calls. - use memzero_explicit in sctp_setsockopt_auth_key instead of special casing it for a kzfree in the caller - remove some minor cleanups from sctp_setsockopt_autoclose to keep it closer to the existing version - add another little only vaguely related cleanup patch ====================
Unified · Split
| @@ -979,9 +979,8 @@ int sctp_asconf_mgmt(struct sctp_sock *sp, struct sctp_sockaddr_entry *addrw) · 978 unmodified lines | ||
| 979 | 979 | * |
| 980 | 980 | * Returns 0 if ok, <0 errno code on error. |
| 981 | 981 | */ |
| 982 | −static int sctp_setsockopt_bindx_kernel(struct sock *sk, | |
| 983 | − struct sockaddr *addrs, int addrs_size, | |
| 984 | − int op) | |
| 982 | +static int sctp_setsockopt_bindx(struct sock *sk, struct sockaddr *addrs, | |
| 983 | + int addrs_size, int op) | |
| 985 | 984 | { |
| 986 | 985 | int err; |
| 987 | 986 | int addrcnt = 0; |
| @@ -991,7 +990,7 @@ static int sctp_setsockopt_bindx_kernel(struct sock *sk, · 3 unmodified lines | ||
| 991 | 990 | struct sctp_af *af; |
| 992 | 991 | |
| 993 | 992 | pr_debug("%s: sk:%p addrs:%p addrs_size:%d opt:%d\n", |
| 994 | − __func__, sk, addrs, addrs_size, op); | |
| 993 | + __func__, sk, addr_buf, addrs_size, op); | |
| 995 | 994 | |
| 996 | 995 | if (unlikely(addrs_size <= 0)) |
| 997 | 996 | return -EINVAL; |
| @@ -1037,29 +1036,13 @@ static int sctp_setsockopt_bindx_kernel(struct sock *sk, · 39 unmodified lines | ||
| 1037 | 1036 | } |
| 1038 | 1037 | } |
| 1039 | 1038 | |
| 1040 | −static int sctp_setsockopt_bindx(struct sock *sk, | |
| 1041 | − struct sockaddr __user *addrs, | |
| 1042 | − int addrs_size, int op) | |
| 1043 | −{ | |
| 1044 | − struct sockaddr *kaddrs; | |
| 1045 | − int err; | |
| 1046 | − | |
| 1047 | − kaddrs = memdup_user(addrs, addrs_size); | |
| 1048 | − if (IS_ERR(kaddrs)) | |
| 1049 | − return PTR_ERR(kaddrs); | |
| 1050 | − err = sctp_setsockopt_bindx_kernel(sk, kaddrs, addrs_size, op); | |
| 1051 | − kfree(kaddrs); | |
| 1052 | − return err; | |
| 1053 | −} | |
| 1054 | − | |
| 1055 | 1039 | static int sctp_bind_add(struct sock *sk, struct sockaddr *addrs, |
| 1056 | 1040 | int addrlen) |
| 1057 | 1041 | { |
| 1058 | 1042 | int err; |
| 1059 | 1043 | |
| 1060 | 1044 | lock_sock(sk); |
| 1061 | − err = sctp_setsockopt_bindx_kernel(sk, addrs, addrlen, | |
| 1062 | − SCTP_BINDX_ADD_ADDR); | |
| 1045 | + err = sctp_setsockopt_bindx(sk, addrs, addrlen, SCTP_BINDX_ADD_ADDR); | |
| 1063 | 1046 | release_sock(sk); |
| 1064 | 1047 | return err; |
| 1065 | 1048 | } |
| @@ -1303,36 +1286,29 @@ out_free: · 237 unmodified lines | ||
| 1303 | 1286 | * it. |
| 1304 | 1287 | * |
| 1305 | 1288 | * sk The sk of the socket |
| 1306 | − * addrs The pointer to the addresses in user land | |
| 1289 | + * addrs The pointer to the addresses | |
| 1307 | 1290 | * addrssize Size of the addrs buffer |
| 1308 | 1291 | * |
| 1309 | 1292 | * Returns >=0 if ok, <0 errno code on error. |
| 1310 | 1293 | */ |
| 1311 | −static int __sctp_setsockopt_connectx(struct sock *sk, | |
| 1312 | − struct sockaddr __user *addrs, | |
| 1313 | − int addrs_size, | |
| 1314 | − sctp_assoc_t *assoc_id) | |
| 1294 | +static int __sctp_setsockopt_connectx(struct sock *sk, struct sockaddr *kaddrs, | |
| 1295 | + int addrs_size, sctp_assoc_t *assoc_id) | |
| 1315 | 1296 | { |
| 1316 | − struct sockaddr *kaddrs; | |
| 1317 | 1297 | int err = 0, flags = 0; |
| 1318 | 1298 | |
| 1319 | 1299 | pr_debug("%s: sk:%p addrs:%p addrs_size:%d\n", |
| 1320 | − __func__, sk, addrs, addrs_size); | |
| 1300 | + __func__, sk, kaddrs, addrs_size); | |
| 1321 | 1301 | |
| 1322 | 1302 | /* make sure the 1st addr's sa_family is accessible later */ |
| 1323 | 1303 | if (unlikely(addrs_size < sizeof(sa_family_t))) |
| 1324 | 1304 | return -EINVAL; |
| 1325 | 1305 | |
| 1326 | − kaddrs = memdup_user(addrs, addrs_size); | |
| 1327 | − if (IS_ERR(kaddrs)) | |
| 1328 | − return PTR_ERR(kaddrs); | |
| 1329 | − | |
| 1330 | 1306 | /* Allow security module to validate connectx addresses. */ |
| 1331 | 1307 | err = security_sctp_bind_connect(sk, SCTP_SOCKOPT_CONNECTX, |
| 1332 | 1308 | (struct sockaddr *)kaddrs, |
| 1333 | 1309 | addrs_size); |
| 1334 | 1310 | if (err) |
| 1335 | − goto out_free; | |
| 1311 | + return err; | |
| 1336 | 1312 | |
| 1337 | 1313 | /* in-kernel sockets don't generally have a file allocated to them |
| 1338 | 1314 | * if all they do is call sock_create_kern(). |
| @@ -1340,12 +1316,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk, · 1 unmodified line | ||
| 1340 | 1316 | if (sk->sk_socket->file) |
| 1341 | 1317 | flags = sk->sk_socket->file->f_flags; |
| 1342 | 1318 | |
| 1343 | − err = __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id); | |
| 1344 | − | |
| 1345 | −out_free: | |
| 1346 | − kfree(kaddrs); | |
| 1347 | − | |
| 1348 | − return err; | |
| 1319 | + return __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id); | |
| 1349 | 1320 | } |
| 1350 | 1321 | |
| 1351 | 1322 | /* |
| @@ -1353,10 +1324,10 @@ out_free: · 1 unmodified line | ||
| 1353 | 1324 | * to the option that doesn't provide association id. |
| 1354 | 1325 | */ |
| 1355 | 1326 | static int sctp_setsockopt_connectx_old(struct sock *sk, |
| 1356 | − struct sockaddr __user *addrs, | |
| 1327 | + struct sockaddr *kaddrs, | |
| 1357 | 1328 | int addrs_size) |
| 1358 | 1329 | { |
| 1359 | − return __sctp_setsockopt_connectx(sk, addrs, addrs_size, NULL); | |
| 1330 | + return __sctp_setsockopt_connectx(sk, kaddrs, addrs_size, NULL); | |
| 1360 | 1331 | } |
| 1361 | 1332 | |
| 1362 | 1333 | /* |
| @@ -1366,13 +1337,13 @@ static int sctp_setsockopt_connectx_old(struct sock *sk, · 3 unmodified lines | ||
| 1366 | 1337 | * always positive. |
| 1367 | 1338 | */ |
| 1368 | 1339 | static int sctp_setsockopt_connectx(struct sock *sk, |
| 1369 | − struct sockaddr __user *addrs, | |
| 1340 | + struct sockaddr *kaddrs, | |
| 1370 | 1341 | int addrs_size) |
| 1371 | 1342 | { |
| 1372 | 1343 | sctp_assoc_t assoc_id = 0; |
| 1373 | 1344 | int err = 0; |
| 1374 | 1345 | |
| 1375 | − err = __sctp_setsockopt_connectx(sk, addrs, addrs_size, &assoc_id); | |
| 1346 | + err = __sctp_setsockopt_connectx(sk, kaddrs, addrs_size, &assoc_id); | |
| 1376 | 1347 | |
| 1377 | 1348 | if (err) |
| 1378 | 1349 | return err; |
| @@ -1402,6 +1373,7 @@ static int sctp_getsockopt_connectx3(struct sock *sk, int len, · 23 unmodified lines | ||
| 1402 | 1373 | { |
| 1403 | 1374 | struct sctp_getaddrs_old param; |
| 1404 | 1375 | sctp_assoc_t assoc_id = 0; |
| 1376 | + struct sockaddr *kaddrs; | |
| 1405 | 1377 | int err = 0; |
| 1406 | 1378 | |
| 1407 | 1379 | #ifdef CONFIG_COMPAT |
| @@ -1425,9 +1397,12 @@ static int sctp_getsockopt_connectx3(struct sock *sk, int len, · 17 unmodified lines | ||
| 1425 | 1397 | return -EFAULT; |
| 1426 | 1398 | } |
| 1427 | 1399 | |
| 1428 | − err = __sctp_setsockopt_connectx(sk, (struct sockaddr __user *) | |
| 1429 | − param.addrs, param.addr_num, | |
| 1430 | − &assoc_id); | |
| 1400 | + kaddrs = memdup_user(param.addrs, param.addr_num); | |
| 1401 | + if (IS_ERR(kaddrs)) | |
| 1402 | + return PTR_ERR(kaddrs); | |
| 1403 | + | |
| 1404 | + err = __sctp_setsockopt_connectx(sk, kaddrs, param.addr_num, &assoc_id); | |
| 1405 | + kfree(kaddrs); | |
| 1431 | 1406 | if (err == 0 || err == -EINPROGRESS) { |
| 1432 | 1407 | if (copy_to_user(optval, &assoc_id, sizeof(assoc_id))) |
| 1433 | 1408 | return -EFAULT; |
| @@ -2209,28 +2184,18 @@ out: · 775 unmodified lines | ||
| 2209 | 2184 | * exceeds the current PMTU size, the message will NOT be sent and |
| 2210 | 2185 | * instead a error will be indicated to the user. |
| 2211 | 2186 | */ |
| 2212 | −static int sctp_setsockopt_disable_fragments(struct sock *sk, | |
| 2213 | − char __user *optval, | |
| 2187 | +static int sctp_setsockopt_disable_fragments(struct sock *sk, int *val, | |
| 2214 | 2188 | unsigned int optlen) |
| 2215 | 2189 | { |
| 2216 | − int val; | |
| 2217 | − | |
| 2218 | 2190 | if (optlen < sizeof(int)) |
| 2219 | 2191 | return -EINVAL; |
| 2220 | − | |
| 2221 | − if (get_user(val, (int __user *)optval)) | |
| 2222 | − return -EFAULT; | |
| 2223 | − | |
| 2224 | − sctp_sk(sk)->disable_fragments = (val == 0) ? 0 : 1; | |
| 2225 | − | |
| 2192 | + sctp_sk(sk)->disable_fragments = (*val == 0) ? 0 : 1; | |
| 2226 | 2193 | return 0; |
| 2227 | 2194 | } |
| 2228 | 2195 | |
| 2229 | −static int sctp_setsockopt_events(struct sock *sk, char __user *optval, | |
| 2196 | +static int sctp_setsockopt_events(struct sock *sk, __u8 *sn_type, | |
| 2230 | 2197 | unsigned int optlen) |
| 2231 | 2198 | { |
| 2232 | − struct sctp_event_subscribe subscribe; | |
| 2233 | − __u8 *sn_type = (__u8 *)&subscribe; | |
| 2234 | 2199 | struct sctp_sock *sp = sctp_sk(sk); |
| 2235 | 2200 | struct sctp_association *asoc; |
| 2236 | 2201 | int i; |
| @@ -2238,9 +2203,6 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval, · 1 unmodified line | ||
| 2238 | 2203 | if (optlen > sizeof(struct sctp_event_subscribe)) |
| 2239 | 2204 | return -EINVAL; |
| 2240 | 2205 | |
| 2241 | − if (copy_from_user(&subscribe, optval, optlen)) | |
| 2242 | − return -EFAULT; | |
| 2243 | − | |
| 2244 | 2206 | for (i = 0; i < optlen; i++) |
| 2245 | 2207 | sctp_ulpevent_type_set(&sp->subscribe, SCTP_SN_TYPE_BASE + i, |
| 2246 | 2208 | sn_type[i]); |
| @@ -2280,7 +2242,7 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval, · 33 unmodified lines | ||
| 2280 | 2242 | * integer defining the number of seconds of idle time before an |
| 2281 | 2243 | * association is closed. |
| 2282 | 2244 | */ |
| 2283 | −static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval, | |
| 2245 | +static int sctp_setsockopt_autoclose(struct sock *sk, u32 *optval, | |
| 2284 | 2246 | unsigned int optlen) |
| 2285 | 2247 | { |
| 2286 | 2248 | struct sctp_sock *sp = sctp_sk(sk); |
| @@ -2291,9 +2253,8 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval, · 4 unmodified lines | ||
| 2291 | 2253 | return -EOPNOTSUPP; |
| 2292 | 2254 | if (optlen != sizeof(int)) |
| 2293 | 2255 | return -EINVAL; |
| 2294 | − if (copy_from_user(&sp->autoclose, optval, optlen)) | |
| 2295 | − return -EFAULT; | |
| 2296 | 2256 | |
| 2257 | + sp->autoclose = *optval; | |
| 2297 | 2258 | if (sp->autoclose > net->sctp.max_autoclose) |
| 2298 | 2259 | sp->autoclose = net->sctp.max_autoclose; |
| 2299 | 2260 | |
| @@ -2628,48 +2589,42 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params, · 328 unmodified lines | ||
| 2628 | 2589 | } |
| 2629 | 2590 | |
| 2630 | 2591 | static int sctp_setsockopt_peer_addr_params(struct sock *sk, |
| 2631 | − char __user *optval, | |
| 2592 | + struct sctp_paddrparams *params, | |
| 2632 | 2593 | unsigned int optlen) |
| 2633 | 2594 | { |
| 2634 | − struct sctp_paddrparams params; | |
| 2635 | 2595 | struct sctp_transport *trans = NULL; |
| 2636 | 2596 | struct sctp_association *asoc = NULL; |
| 2637 | 2597 | struct sctp_sock *sp = sctp_sk(sk); |
| 2638 | 2598 | int error; |
| 2639 | 2599 | int hb_change, pmtud_change, sackdelay_change; |
| 2640 | 2600 | |
| 2641 | − if (optlen == sizeof(params)) { | |
| 2642 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 2643 | − return -EFAULT; | |
| 2644 | − } else if (optlen == ALIGN(offsetof(struct sctp_paddrparams, | |
| 2601 | + if (optlen == ALIGN(offsetof(struct sctp_paddrparams, | |
| 2645 | 2602 | spp_ipv6_flowlabel), 4)) { |
| 2646 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 2647 | − return -EFAULT; | |
| 2648 | − if (params.spp_flags & (SPP_DSCP | SPP_IPV6_FLOWLABEL)) | |
| 2603 | + if (params->spp_flags & (SPP_DSCP | SPP_IPV6_FLOWLABEL)) | |
| 2649 | 2604 | return -EINVAL; |
| 2650 | − } else { | |
| 2605 | + } else if (optlen != sizeof(*params)) { | |
| 2651 | 2606 | return -EINVAL; |
| 2652 | 2607 | } |
| 2653 | 2608 | |
| 2654 | 2609 | /* Validate flags and value parameters. */ |
| 2655 | − hb_change = params.spp_flags & SPP_HB; | |
| 2656 | − pmtud_change = params.spp_flags & SPP_PMTUD; | |
| 2657 | − sackdelay_change = params.spp_flags & SPP_SACKDELAY; | |
| 2610 | + hb_change = params->spp_flags & SPP_HB; | |
| 2611 | + pmtud_change = params->spp_flags & SPP_PMTUD; | |
| 2612 | + sackdelay_change = params->spp_flags & SPP_SACKDELAY; | |
| 2658 | 2613 | |
| 2659 | 2614 | if (hb_change == SPP_HB || |
| 2660 | 2615 | pmtud_change == SPP_PMTUD || |
| 2661 | 2616 | sackdelay_change == SPP_SACKDELAY || |
| 2662 | − params.spp_sackdelay > 500 || | |
| 2663 | − (params.spp_pathmtu && | |
| 2664 | − params.spp_pathmtu < SCTP_DEFAULT_MINSEGMENT)) | |
| 2617 | + params->spp_sackdelay > 500 || | |
| 2618 | + (params->spp_pathmtu && | |
| 2619 | + params->spp_pathmtu < SCTP_DEFAULT_MINSEGMENT)) | |
| 2665 | 2620 | return -EINVAL; |
| 2666 | 2621 | |
| 2667 | 2622 | /* If an address other than INADDR_ANY is specified, and |
| 2668 | 2623 | * no transport is found, then the request is invalid. |
| 2669 | 2624 | */ |
| 2670 | − if (!sctp_is_any(sk, (union sctp_addr *)¶ms.spp_address)) { | |
| 2671 | − trans = sctp_addr_id2transport(sk, ¶ms.spp_address, | |
| 2672 | − params.spp_assoc_id); | |
| 2625 | + if (!sctp_is_any(sk, (union sctp_addr *)¶ms->spp_address)) { | |
| 2626 | + trans = sctp_addr_id2transport(sk, ¶ms->spp_address, | |
| 2627 | + params->spp_assoc_id); | |
| 2673 | 2628 | if (!trans) |
| 2674 | 2629 | return -EINVAL; |
| 2675 | 2630 | } |
| @@ -2678,19 +2633,19 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, · 2 unmodified lines | ||
| 2678 | 2633 | * socket is a one to many style socket, and an association |
| 2679 | 2634 | * was not found, then the id was invalid. |
| 2680 | 2635 | */ |
| 2681 | − asoc = sctp_id2assoc(sk, params.spp_assoc_id); | |
| 2682 | − if (!asoc && params.spp_assoc_id != SCTP_FUTURE_ASSOC && | |
| 2636 | + asoc = sctp_id2assoc(sk, params->spp_assoc_id); | |
| 2637 | + if (!asoc && params->spp_assoc_id != SCTP_FUTURE_ASSOC && | |
| 2683 | 2638 | sctp_style(sk, UDP)) |
| 2684 | 2639 | return -EINVAL; |
| 2685 | 2640 | |
| 2686 | 2641 | /* Heartbeat demand can only be sent on a transport or |
| 2687 | 2642 | * association, but not a socket. |
| 2688 | 2643 | */ |
| 2689 | − if (params.spp_flags & SPP_HB_DEMAND && !trans && !asoc) | |
| 2644 | + if (params->spp_flags & SPP_HB_DEMAND && !trans && !asoc) | |
| 2690 | 2645 | return -EINVAL; |
| 2691 | 2646 | |
| 2692 | 2647 | /* Process parameters. */ |
| 2693 | − error = sctp_apply_peer_addr_params(¶ms, trans, asoc, sp, | |
| 2648 | + error = sctp_apply_peer_addr_params(params, trans, asoc, sp, | |
| 2694 | 2649 | hb_change, pmtud_change, |
| 2695 | 2650 | sackdelay_change); |
| 2696 | 2651 | |
| @@ -2703,7 +2658,7 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, · 6 unmodified lines | ||
| 2703 | 2658 | if (!trans && asoc) { |
| 2704 | 2659 | list_for_each_entry(trans, &asoc->peer.transport_addr_list, |
| 2705 | 2660 | transports) { |
| 2706 | − sctp_apply_peer_addr_params(¶ms, trans, asoc, sp, | |
| 2661 | + sctp_apply_peer_addr_params(params, trans, asoc, sp, | |
| 2707 | 2662 | hb_change, pmtud_change, |
| 2708 | 2663 | sackdelay_change); |
| 2709 | 2664 | } |
| @@ -2796,17 +2751,14 @@ static void sctp_apply_asoc_delayed_ack(struct sctp_sack_info *params, · 86 unmodified lines | ||
| 2796 | 2751 | */ |
| 2797 | 2752 | |
| 2798 | 2753 | static int sctp_setsockopt_delayed_ack(struct sock *sk, |
| 2799 | − char __user *optval, unsigned int optlen) | |
| 2754 | + struct sctp_sack_info *params, | |
| 2755 | + unsigned int optlen) | |
| 2800 | 2756 | { |
| 2801 | 2757 | struct sctp_sock *sp = sctp_sk(sk); |
| 2802 | 2758 | struct sctp_association *asoc; |
| 2803 | − struct sctp_sack_info params; | |
| 2804 | 2759 | |
| 2805 | 2760 | if (optlen == sizeof(struct sctp_sack_info)) { |
| 2806 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 2807 | − return -EFAULT; | |
| 2808 | − | |
| 2809 | − if (params.sack_delay == 0 && params.sack_freq == 0) | |
| 2761 | + if (params->sack_delay == 0 && params->sack_freq == 0) | |
| 2810 | 2762 | return 0; |
| 2811 | 2763 | } else if (optlen == sizeof(struct sctp_assoc_value)) { |
| 2812 | 2764 | pr_warn_ratelimited(DEPRECATED |
| @@ -2814,59 +2766,57 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk, · 1 unmodified line | ||
| 2814 | 2766 | "Use of struct sctp_assoc_value in delayed_ack socket option.\n" |
| 2815 | 2767 | "Use struct sctp_sack_info instead\n", |
| 2816 | 2768 | current->comm, task_pid_nr(current)); |
| 2817 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 2818 | − return -EFAULT; | |
| 2819 | 2769 | |
| 2820 | − if (params.sack_delay == 0) | |
| 2821 | − params.sack_freq = 1; | |
| 2770 | + if (params->sack_delay == 0) | |
| 2771 | + params->sack_freq = 1; | |
| 2822 | 2772 | else |
| 2823 | − params.sack_freq = 0; | |
| 2773 | + params->sack_freq = 0; | |
| 2824 | 2774 | } else |
| 2825 | 2775 | return -EINVAL; |
| 2826 | 2776 | |
| 2827 | 2777 | /* Validate value parameter. */ |
| 2828 | − if (params.sack_delay > 500) | |
| 2778 | + if (params->sack_delay > 500) | |
| 2829 | 2779 | return -EINVAL; |
| 2830 | 2780 | |
| 2831 | 2781 | /* Get association, if sack_assoc_id != SCTP_FUTURE_ASSOC and the |
| 2832 | 2782 | * socket is a one to many style socket, and an association |
| 2833 | 2783 | * was not found, then the id was invalid. |
| 2834 | 2784 | */ |
| 2835 | − asoc = sctp_id2assoc(sk, params.sack_assoc_id); | |
| 2836 | − if (!asoc && params.sack_assoc_id > SCTP_ALL_ASSOC && | |
| 2785 | + asoc = sctp_id2assoc(sk, params->sack_assoc_id); | |
| 2786 | + if (!asoc && params->sack_assoc_id > SCTP_ALL_ASSOC && | |
| 2837 | 2787 | sctp_style(sk, UDP)) |
| 2838 | 2788 | return -EINVAL; |
| 2839 | 2789 | |
| 2840 | 2790 | if (asoc) { |
| 2841 | − sctp_apply_asoc_delayed_ack(¶ms, asoc); | |
| 2791 | + sctp_apply_asoc_delayed_ack(params, asoc); | |
| 2842 | 2792 | |
| 2843 | 2793 | return 0; |
| 2844 | 2794 | } |
| 2845 | 2795 | |
| 2846 | 2796 | if (sctp_style(sk, TCP)) |
| 2847 | − params.sack_assoc_id = SCTP_FUTURE_ASSOC; | |
| 2797 | + params->sack_assoc_id = SCTP_FUTURE_ASSOC; | |
| 2848 | 2798 | |
| 2849 | − if (params.sack_assoc_id == SCTP_FUTURE_ASSOC || | |
| 2850 | − params.sack_assoc_id == SCTP_ALL_ASSOC) { | |
| 2851 | − if (params.sack_delay) { | |
| 2852 | − sp->sackdelay = params.sack_delay; | |
| 2799 | + if (params->sack_assoc_id == SCTP_FUTURE_ASSOC || | |
| 2800 | + params->sack_assoc_id == SCTP_ALL_ASSOC) { | |
| 2801 | + if (params->sack_delay) { | |
| 2802 | + sp->sackdelay = params->sack_delay; | |
| 2853 | 2803 | sp->param_flags = |
| 2854 | 2804 | sctp_spp_sackdelay_enable(sp->param_flags); |
| 2855 | 2805 | } |
| 2856 | − if (params.sack_freq == 1) { | |
| 2806 | + if (params->sack_freq == 1) { | |
| 2857 | 2807 | sp->param_flags = |
| 2858 | 2808 | sctp_spp_sackdelay_disable(sp->param_flags); |
| 2859 | − } else if (params.sack_freq > 1) { | |
| 2860 | − sp->sackfreq = params.sack_freq; | |
| 2809 | + } else if (params->sack_freq > 1) { | |
| 2810 | + sp->sackfreq = params->sack_freq; | |
| 2861 | 2811 | sp->param_flags = |
| 2862 | 2812 | sctp_spp_sackdelay_enable(sp->param_flags); |
| 2863 | 2813 | } |
| 2864 | 2814 | } |
| 2865 | 2815 | |
| 2866 | − if (params.sack_assoc_id == SCTP_CURRENT_ASSOC || | |
| 2867 | − params.sack_assoc_id == SCTP_ALL_ASSOC) | |
| 2816 | + if (params->sack_assoc_id == SCTP_CURRENT_ASSOC || | |
| 2817 | + params->sack_assoc_id == SCTP_ALL_ASSOC) | |
| 2868 | 2818 | list_for_each_entry(asoc, &sp->ep->asocs, asocs) |
| 2869 | − sctp_apply_asoc_delayed_ack(¶ms, asoc); | |
| 2819 | + sctp_apply_asoc_delayed_ack(params, asoc); | |
| 2870 | 2820 | |
| 2871 | 2821 | return 0; |
| 2872 | 2822 | } |
| @@ -2882,24 +2832,22 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk, · 9 unmodified lines | ||
| 2882 | 2832 | * by the change). With TCP-style sockets, this option is inherited by |
| 2883 | 2833 | * sockets derived from a listener socket. |
| 2884 | 2834 | */ |
| 2885 | −static int sctp_setsockopt_initmsg(struct sock *sk, char __user *optval, unsigned int optlen) | |
| 2835 | +static int sctp_setsockopt_initmsg(struct sock *sk, struct sctp_initmsg *sinit, | |
| 2836 | + unsigned int optlen) | |
| 2886 | 2837 | { |
| 2887 | − struct sctp_initmsg sinit; | |
| 2888 | 2838 | struct sctp_sock *sp = sctp_sk(sk); |
| 2889 | 2839 | |
| 2890 | 2840 | if (optlen != sizeof(struct sctp_initmsg)) |
| 2891 | 2841 | return -EINVAL; |
| 2892 | − if (copy_from_user(&sinit, optval, optlen)) | |
| 2893 | − return -EFAULT; | |
| 2894 | 2842 | |
| 2895 | − if (sinit.sinit_num_ostreams) | |
| 2896 | − sp->initmsg.sinit_num_ostreams = sinit.sinit_num_ostreams; | |
| 2897 | − if (sinit.sinit_max_instreams) | |
| 2898 | − sp->initmsg.sinit_max_instreams = sinit.sinit_max_instreams; | |
| 2899 | − if (sinit.sinit_max_attempts) | |
| 2900 | − sp->initmsg.sinit_max_attempts = sinit.sinit_max_attempts; | |
| 2901 | − if (sinit.sinit_max_init_timeo) | |
| 2902 | − sp->initmsg.sinit_max_init_timeo = sinit.sinit_max_init_timeo; | |
| 2843 | + if (sinit->sinit_num_ostreams) | |
| 2844 | + sp->initmsg.sinit_num_ostreams = sinit->sinit_num_ostreams; | |
| 2845 | + if (sinit->sinit_max_instreams) | |
| 2846 | + sp->initmsg.sinit_max_instreams = sinit->sinit_max_instreams; | |
| 2847 | + if (sinit->sinit_max_attempts) | |
| 2848 | + sp->initmsg.sinit_max_attempts = sinit->sinit_max_attempts; | |
| 2849 | + if (sinit->sinit_max_init_timeo) | |
| 2850 | + sp->initmsg.sinit_max_init_timeo = sinit->sinit_max_init_timeo; | |
| 2903 | 2851 | |
| 2904 | 2852 | return 0; |
| 2905 | 2853 | } |
| @@ -2919,57 +2867,54 @@ static int sctp_setsockopt_initmsg(struct sock *sk, char __user *optval, unsigne · 13 unmodified lines | ||
| 2919 | 2867 | * to this call if the caller is using the UDP model. |
| 2920 | 2868 | */ |
| 2921 | 2869 | static int sctp_setsockopt_default_send_param(struct sock *sk, |
| 2922 | − char __user *optval, | |
| 2870 | + struct sctp_sndrcvinfo *info, | |
| 2923 | 2871 | unsigned int optlen) |
| 2924 | 2872 | { |
| 2925 | 2873 | struct sctp_sock *sp = sctp_sk(sk); |
| 2926 | 2874 | struct sctp_association *asoc; |
| 2927 | − struct sctp_sndrcvinfo info; | |
| 2928 | 2875 | |
| 2929 | − if (optlen != sizeof(info)) | |
| 2876 | + if (optlen != sizeof(*info)) | |
| 2930 | 2877 | return -EINVAL; |
| 2931 | − if (copy_from_user(&info, optval, optlen)) | |
| 2932 | − return -EFAULT; | |
| 2933 | − if (info.sinfo_flags & | |
| 2878 | + if (info->sinfo_flags & | |
| 2934 | 2879 | ~(SCTP_UNORDERED | SCTP_ADDR_OVER | |
| 2935 | 2880 | SCTP_ABORT | SCTP_EOF)) |
| 2936 | 2881 | return -EINVAL; |
| 2937 | 2882 | |
| 2938 | − asoc = sctp_id2assoc(sk, info.sinfo_assoc_id); | |
| 2939 | − if (!asoc && info.sinfo_assoc_id > SCTP_ALL_ASSOC && | |
| 2883 | + asoc = sctp_id2assoc(sk, info->sinfo_assoc_id); | |
| 2884 | + if (!asoc && info->sinfo_assoc_id > SCTP_ALL_ASSOC && | |
| 2940 | 2885 | sctp_style(sk, UDP)) |
| 2941 | 2886 | return -EINVAL; |
| 2942 | 2887 | |
| 2943 | 2888 | if (asoc) { |
| 2944 | − asoc->default_stream = info.sinfo_stream; | |
| 2945 | − asoc->default_flags = info.sinfo_flags; | |
| 2946 | − asoc->default_ppid = info.sinfo_ppid; | |
| 2947 | − asoc->default_context = info.sinfo_context; | |
| 2948 | − asoc->default_timetolive = info.sinfo_timetolive; | |
| 2889 | + asoc->default_stream = info->sinfo_stream; | |
| 2890 | + asoc->default_flags = info->sinfo_flags; | |
| 2891 | + asoc->default_ppid = info->sinfo_ppid; | |
| 2892 | + asoc->default_context = info->sinfo_context; | |
| 2893 | + asoc->default_timetolive = info->sinfo_timetolive; | |
| 2949 | 2894 | |
| 2950 | 2895 | return 0; |
| 2951 | 2896 | } |
| 2952 | 2897 | |
| 2953 | 2898 | if (sctp_style(sk, TCP)) |
| 2954 | − info.sinfo_assoc_id = SCTP_FUTURE_ASSOC; | |
| 2899 | + info->sinfo_assoc_id = SCTP_FUTURE_ASSOC; | |
| 2955 | 2900 | |
| 2956 | − if (info.sinfo_assoc_id == SCTP_FUTURE_ASSOC || | |
| 2957 | − info.sinfo_assoc_id == SCTP_ALL_ASSOC) { | |
| 2958 | − sp->default_stream = info.sinfo_stream; | |
| 2959 | − sp->default_flags = info.sinfo_flags; | |
| 2960 | − sp->default_ppid = info.sinfo_ppid; | |
| 2961 | − sp->default_context = info.sinfo_context; | |
| 2962 | − sp->default_timetolive = info.sinfo_timetolive; | |
| 2901 | + if (info->sinfo_assoc_id == SCTP_FUTURE_ASSOC || | |
| 2902 | + info->sinfo_assoc_id == SCTP_ALL_ASSOC) { | |
| 2903 | + sp->default_stream = info->sinfo_stream; | |
| 2904 | + sp->default_flags = info->sinfo_flags; | |
| 2905 | + sp->default_ppid = info->sinfo_ppid; | |
| 2906 | + sp->default_context = info->sinfo_context; | |
| 2907 | + sp->default_timetolive = info->sinfo_timetolive; | |
| 2963 | 2908 | } |
| 2964 | 2909 | |
| 2965 | − if (info.sinfo_assoc_id == SCTP_CURRENT_ASSOC || | |
| 2966 | − info.sinfo_assoc_id == SCTP_ALL_ASSOC) { | |
| 2910 | + if (info->sinfo_assoc_id == SCTP_CURRENT_ASSOC || | |
| 2911 | + info->sinfo_assoc_id == SCTP_ALL_ASSOC) { | |
| 2967 | 2912 | list_for_each_entry(asoc, &sp->ep->asocs, asocs) { |
| 2968 | − asoc->default_stream = info.sinfo_stream; | |
| 2969 | − asoc->default_flags = info.sinfo_flags; | |
| 2970 | − asoc->default_ppid = info.sinfo_ppid; | |
| 2971 | − asoc->default_context = info.sinfo_context; | |
| 2972 | − asoc->default_timetolive = info.sinfo_timetolive; | |
| 2913 | + asoc->default_stream = info->sinfo_stream; | |
| 2914 | + asoc->default_flags = info->sinfo_flags; | |
| 2915 | + asoc->default_ppid = info->sinfo_ppid; | |
| 2916 | + asoc->default_context = info->sinfo_context; | |
| 2917 | + asoc->default_timetolive = info->sinfo_timetolive; | |
| 2973 | 2918 | } |
| 2974 | 2919 | } |
| 2975 | 2920 | |
| @@ -2980,54 +2925,51 @@ static int sctp_setsockopt_default_send_param(struct sock *sk, · 4 unmodified lines | ||
| 2980 | 2925 | * (SCTP_DEFAULT_SNDINFO) |
| 2981 | 2926 | */ |
| 2982 | 2927 | static int sctp_setsockopt_default_sndinfo(struct sock *sk, |
| 2983 | − char __user *optval, | |
| 2928 | + struct sctp_sndinfo *info, | |
| 2984 | 2929 | unsigned int optlen) |
| 2985 | 2930 | { |
| 2986 | 2931 | struct sctp_sock *sp = sctp_sk(sk); |
| 2987 | 2932 | struct sctp_association *asoc; |
| 2988 | − struct sctp_sndinfo info; | |
| 2989 | 2933 | |
| 2990 | − if (optlen != sizeof(info)) | |
| 2934 | + if (optlen != sizeof(*info)) | |
| 2991 | 2935 | return -EINVAL; |
| 2992 | − if (copy_from_user(&info, optval, optlen)) | |
| 2993 | − return -EFAULT; | |
| 2994 | − if (info.snd_flags & | |
| 2936 | + if (info->snd_flags & | |
| 2995 | 2937 | ~(SCTP_UNORDERED | SCTP_ADDR_OVER | |
| 2996 | 2938 | SCTP_ABORT | SCTP_EOF)) |
| 2997 | 2939 | return -EINVAL; |
| 2998 | 2940 | |
| 2999 | − asoc = sctp_id2assoc(sk, info.snd_assoc_id); | |
| 3000 | − if (!asoc && info.snd_assoc_id > SCTP_ALL_ASSOC && | |
| 2941 | + asoc = sctp_id2assoc(sk, info->snd_assoc_id); | |
| 2942 | + if (!asoc && info->snd_assoc_id > SCTP_ALL_ASSOC && | |
| 3001 | 2943 | sctp_style(sk, UDP)) |
| 3002 | 2944 | return -EINVAL; |
| 3003 | 2945 | |
| 3004 | 2946 | if (asoc) { |
| 3005 | − asoc->default_stream = info.snd_sid; | |
| 3006 | − asoc->default_flags = info.snd_flags; | |
| 3007 | − asoc->default_ppid = info.snd_ppid; | |
| 3008 | − asoc->default_context = info.snd_context; | |
| 2947 | + asoc->default_stream = info->snd_sid; | |
| 2948 | + asoc->default_flags = info->snd_flags; | |
| 2949 | + asoc->default_ppid = info->snd_ppid; | |
| 2950 | + asoc->default_context = info->snd_context; | |
| 3009 | 2951 | |
| 3010 | 2952 | return 0; |
| 3011 | 2953 | } |
| 3012 | 2954 | |
| 3013 | 2955 | if (sctp_style(sk, TCP)) |
| 3014 | − info.snd_assoc_id = SCTP_FUTURE_ASSOC; | |
| 2956 | + info->snd_assoc_id = SCTP_FUTURE_ASSOC; | |
| 3015 | 2957 | |
| 3016 | − if (info.snd_assoc_id == SCTP_FUTURE_ASSOC || | |
| 3017 | − info.snd_assoc_id == SCTP_ALL_ASSOC) { | |
| 3018 | − sp->default_stream = info.snd_sid; | |
| 3019 | − sp->default_flags = info.snd_flags; | |
| 3020 | − sp->default_ppid = info.snd_ppid; | |
| 3021 | − sp->default_context = info.snd_context; | |
| 2958 | + if (info->snd_assoc_id == SCTP_FUTURE_ASSOC || | |
| 2959 | + info->snd_assoc_id == SCTP_ALL_ASSOC) { | |
| 2960 | + sp->default_stream = info->snd_sid; | |
| 2961 | + sp->default_flags = info->snd_flags; | |
| 2962 | + sp->default_ppid = info->snd_ppid; | |
| 2963 | + sp->default_context = info->snd_context; | |
| 3022 | 2964 | } |
| 3023 | 2965 | |
| 3024 | − if (info.snd_assoc_id == SCTP_CURRENT_ASSOC || | |
| 3025 | − info.snd_assoc_id == SCTP_ALL_ASSOC) { | |
| 2966 | + if (info->snd_assoc_id == SCTP_CURRENT_ASSOC || | |
| 2967 | + info->snd_assoc_id == SCTP_ALL_ASSOC) { | |
| 3026 | 2968 | list_for_each_entry(asoc, &sp->ep->asocs, asocs) { |
| 3027 | − asoc->default_stream = info.snd_sid; | |
| 3028 | − asoc->default_flags = info.snd_flags; | |
| 3029 | − asoc->default_ppid = info.snd_ppid; | |
| 3030 | − asoc->default_context = info.snd_context; | |
| 2969 | + asoc->default_stream = info->snd_sid; | |
| 2970 | + asoc->default_flags = info->snd_flags; | |
| 2971 | + asoc->default_ppid = info->snd_ppid; | |
| 2972 | + asoc->default_context = info->snd_context; | |
| 3031 | 2973 | } |
| 3032 | 2974 | } |
| 3033 | 2975 | |
| @@ -3040,10 +2982,9 @@ static int sctp_setsockopt_default_sndinfo(struct sock *sk, · 6 unmodified lines | ||
| 3040 | 2982 | * the association primary. The enclosed address must be one of the |
| 3041 | 2983 | * association peer's addresses. |
| 3042 | 2984 | */ |
| 3043 | −static int sctp_setsockopt_primary_addr(struct sock *sk, char __user *optval, | |
| 2985 | +static int sctp_setsockopt_primary_addr(struct sock *sk, struct sctp_prim *prim, | |
| 3044 | 2986 | unsigned int optlen) |
| 3045 | 2987 | { |
| 3046 | − struct sctp_prim prim; | |
| 3047 | 2988 | struct sctp_transport *trans; |
| 3048 | 2989 | struct sctp_af *af; |
| 3049 | 2990 | int err; |
| @@ -3051,21 +2992,18 @@ static int sctp_setsockopt_primary_addr(struct sock *sk, char __user *optval, · 1 unmodified line | ||
| 3051 | 2992 | if (optlen != sizeof(struct sctp_prim)) |
| 3052 | 2993 | return -EINVAL; |
| 3053 | 2994 | |
| 3054 | − if (copy_from_user(&prim, optval, sizeof(struct sctp_prim))) | |
| 3055 | − return -EFAULT; | |
| 3056 | − | |
| 3057 | 2995 | /* Allow security module to validate address but need address len. */ |
| 3058 | − af = sctp_get_af_specific(prim.ssp_addr.ss_family); | |
| 2996 | + af = sctp_get_af_specific(prim->ssp_addr.ss_family); | |
| 3059 | 2997 | if (!af) |
| 3060 | 2998 | return -EINVAL; |
| 3061 | 2999 | |
| 3062 | 3000 | err = security_sctp_bind_connect(sk, SCTP_PRIMARY_ADDR, |
| 3063 | − (struct sockaddr *)&prim.ssp_addr, | |
| 3001 | + (struct sockaddr *)&prim->ssp_addr, | |
| 3064 | 3002 | af->sockaddr_len); |
| 3065 | 3003 | if (err) |
| 3066 | 3004 | return err; |
| 3067 | 3005 | |
| 3068 | − trans = sctp_addr_id2transport(sk, &prim.ssp_addr, prim.ssp_assoc_id); | |
| 3006 | + trans = sctp_addr_id2transport(sk, &prim->ssp_addr, prim->ssp_assoc_id); | |
| 3069 | 3007 | if (!trans) |
| 3070 | 3008 | return -EINVAL; |
| 3071 | 3009 | |
| @@ -3082,17 +3020,12 @@ static int sctp_setsockopt_primary_addr(struct sock *sk, char __user *optval, · 10 unmodified lines | ||
| 3082 | 3020 | * introduced, at the cost of more packets in the network. Expects an |
| 3083 | 3021 | * integer boolean flag. |
| 3084 | 3022 | */ |
| 3085 | −static int sctp_setsockopt_nodelay(struct sock *sk, char __user *optval, | |
| 3023 | +static int sctp_setsockopt_nodelay(struct sock *sk, int *val, | |
| 3086 | 3024 | unsigned int optlen) |
| 3087 | 3025 | { |
| 3088 | − int val; | |
| 3089 | − | |
| 3090 | 3026 | if (optlen < sizeof(int)) |
| 3091 | 3027 | return -EINVAL; |
| 3092 | − if (get_user(val, (int __user *)optval)) | |
| 3093 | − return -EFAULT; | |
| 3094 | − | |
| 3095 | − sctp_sk(sk)->nodelay = (val == 0) ? 0 : 1; | |
| 3028 | + sctp_sk(sk)->nodelay = (*val == 0) ? 0 : 1; | |
| 3096 | 3029 | return 0; |
| 3097 | 3030 | } |
| 3098 | 3031 | |
| @@ -3108,9 +3041,10 @@ static int sctp_setsockopt_nodelay(struct sock *sk, char __user *optval, · 9 unmodified lines | ||
| 3108 | 3041 | * be changed. |
| 3109 | 3042 | * |
| 3110 | 3043 | */ |
| 3111 | −static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigned int optlen) | |
| 3044 | +static int sctp_setsockopt_rtoinfo(struct sock *sk, | |
| 3045 | + struct sctp_rtoinfo *rtoinfo, | |
| 3046 | + unsigned int optlen) | |
| 3112 | 3047 | { |
| 3113 | − struct sctp_rtoinfo rtoinfo; | |
| 3114 | 3048 | struct sctp_association *asoc; |
| 3115 | 3049 | unsigned long rto_min, rto_max; |
| 3116 | 3050 | struct sctp_sock *sp = sctp_sk(sk); |
| @@ -3118,18 +3052,15 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne · 1 unmodified line | ||
| 3118 | 3052 | if (optlen != sizeof (struct sctp_rtoinfo)) |
| 3119 | 3053 | return -EINVAL; |
| 3120 | 3054 | |
| 3121 | − if (copy_from_user(&rtoinfo, optval, optlen)) | |
| 3122 | − return -EFAULT; | |
| 3123 | − | |
| 3124 | − asoc = sctp_id2assoc(sk, rtoinfo.srto_assoc_id); | |
| 3055 | + asoc = sctp_id2assoc(sk, rtoinfo->srto_assoc_id); | |
| 3125 | 3056 | |
| 3126 | 3057 | /* Set the values to the specific association */ |
| 3127 | − if (!asoc && rtoinfo.srto_assoc_id != SCTP_FUTURE_ASSOC && | |
| 3058 | + if (!asoc && rtoinfo->srto_assoc_id != SCTP_FUTURE_ASSOC && | |
| 3128 | 3059 | sctp_style(sk, UDP)) |
| 3129 | 3060 | return -EINVAL; |
| 3130 | 3061 | |
| 3131 | − rto_max = rtoinfo.srto_max; | |
| 3132 | − rto_min = rtoinfo.srto_min; | |
| 3062 | + rto_max = rtoinfo->srto_max; | |
| 3063 | + rto_min = rtoinfo->srto_min; | |
| 3133 | 3064 | |
| 3134 | 3065 | if (rto_max) |
| 3135 | 3066 | rto_max = asoc ? msecs_to_jiffies(rto_max) : rto_max; |
| @@ -3145,17 +3076,17 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne · 9 unmodified lines | ||
| 3145 | 3076 | return -EINVAL; |
| 3146 | 3077 | |
| 3147 | 3078 | if (asoc) { |
| 3148 | − if (rtoinfo.srto_initial != 0) | |
| 3079 | + if (rtoinfo->srto_initial != 0) | |
| 3149 | 3080 | asoc->rto_initial = |
| 3150 | − msecs_to_jiffies(rtoinfo.srto_initial); | |
| 3081 | + msecs_to_jiffies(rtoinfo->srto_initial); | |
| 3151 | 3082 | asoc->rto_max = rto_max; |
| 3152 | 3083 | asoc->rto_min = rto_min; |
| 3153 | 3084 | } else { |
| 3154 | 3085 | /* If there is no association or the association-id = 0 |
| 3155 | 3086 | * set the values to the endpoint. |
| 3156 | 3087 | */ |
| 3157 | − if (rtoinfo.srto_initial != 0) | |
| 3158 | − sp->rtoinfo.srto_initial = rtoinfo.srto_initial; | |
| 3088 | + if (rtoinfo->srto_initial != 0) | |
| 3089 | + sp->rtoinfo.srto_initial = rtoinfo->srto_initial; | |
| 3159 | 3090 | sp->rtoinfo.srto_max = rto_max; |
| 3160 | 3091 | sp->rtoinfo.srto_min = rto_min; |
| 3161 | 3092 | } |
| @@ -3174,26 +3105,25 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne · 12 unmodified lines | ||
| 3174 | 3105 | * See [SCTP] for more information. |
| 3175 | 3106 | * |
| 3176 | 3107 | */ |
| 3177 | −static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsigned int optlen) | |
| 3108 | +static int sctp_setsockopt_associnfo(struct sock *sk, | |
| 3109 | + struct sctp_assocparams *assocparams, | |
| 3110 | + unsigned int optlen) | |
| 3178 | 3111 | { |
| 3179 | 3112 | |
| 3180 | − struct sctp_assocparams assocparams; | |
| 3181 | 3113 | struct sctp_association *asoc; |
| 3182 | 3114 | |
| 3183 | 3115 | if (optlen != sizeof(struct sctp_assocparams)) |
| 3184 | 3116 | return -EINVAL; |
| 3185 | − if (copy_from_user(&assocparams, optval, optlen)) | |
| 3186 | − return -EFAULT; | |
| 3187 | 3117 | |
| 3188 | − asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id); | |
| 3118 | + asoc = sctp_id2assoc(sk, assocparams->sasoc_assoc_id); | |
| 3189 | 3119 | |
| 3190 | − if (!asoc && assocparams.sasoc_assoc_id != SCTP_FUTURE_ASSOC && | |
| 3120 | + if (!asoc && assocparams->sasoc_assoc_id != SCTP_FUTURE_ASSOC && | |
| 3191 | 3121 | sctp_style(sk, UDP)) |
| 3192 | 3122 | return -EINVAL; |
| 3193 | 3123 | |
| 3194 | 3124 | /* Set the values to the specific association */ |
| 3195 | 3125 | if (asoc) { |
| 3196 | − if (assocparams.sasoc_asocmaxrxt != 0) { | |
| 3126 | + if (assocparams->sasoc_asocmaxrxt != 0) { | |
| 3197 | 3127 | __u32 path_sum = 0; |
| 3198 | 3128 | int paths = 0; |
| 3199 | 3129 | struct sctp_transport *peer_addr; |
| @@ -3210,24 +3140,25 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsig · 10 unmodified lines | ||
| 3210 | 3140 | * then one path. |
| 3211 | 3141 | */ |
| 3212 | 3142 | if (paths > 1 && |
| 3213 | − assocparams.sasoc_asocmaxrxt > path_sum) | |
| 3143 | + assocparams->sasoc_asocmaxrxt > path_sum) | |
| 3214 | 3144 | return -EINVAL; |
| 3215 | 3145 | |
| 3216 | − asoc->max_retrans = assocparams.sasoc_asocmaxrxt; | |
| 3146 | + asoc->max_retrans = assocparams->sasoc_asocmaxrxt; | |
| 3217 | 3147 | } |
| 3218 | 3148 | |
| 3219 | − if (assocparams.sasoc_cookie_life != 0) | |
| 3220 | − asoc->cookie_life = ms_to_ktime(assocparams.sasoc_cookie_life); | |
| 3149 | + if (assocparams->sasoc_cookie_life != 0) | |
| 3150 | + asoc->cookie_life = | |
| 3151 | + ms_to_ktime(assocparams->sasoc_cookie_life); | |
| 3221 | 3152 | } else { |
| 3222 | 3153 | /* Set the values to the endpoint */ |
| 3223 | 3154 | struct sctp_sock *sp = sctp_sk(sk); |
| 3224 | 3155 | |
| 3225 | − if (assocparams.sasoc_asocmaxrxt != 0) | |
| 3156 | + if (assocparams->sasoc_asocmaxrxt != 0) | |
| 3226 | 3157 | sp->assocparams.sasoc_asocmaxrxt = |
| 3227 | − assocparams.sasoc_asocmaxrxt; | |
| 3228 | − if (assocparams.sasoc_cookie_life != 0) | |
| 3158 | + assocparams->sasoc_asocmaxrxt; | |
| 3159 | + if (assocparams->sasoc_cookie_life != 0) | |
| 3229 | 3160 | sp->assocparams.sasoc_cookie_life = |
| 3230 | − assocparams.sasoc_cookie_life; | |
| 3161 | + assocparams->sasoc_cookie_life; | |
| 3231 | 3162 | } |
| 3232 | 3163 | return 0; |
| 3233 | 3164 | } |
| @@ -3242,16 +3173,14 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsig · 8 unmodified lines | ||
| 3242 | 3173 | * addresses and a user will receive both PF_INET6 and PF_INET type |
| 3243 | 3174 | * addresses on the socket. |
| 3244 | 3175 | */ |
| 3245 | −static int sctp_setsockopt_mappedv4(struct sock *sk, char __user *optval, unsigned int optlen) | |
| 3176 | +static int sctp_setsockopt_mappedv4(struct sock *sk, int *val, | |
| 3177 | + unsigned int optlen) | |
| 3246 | 3178 | { |
| 3247 | − int val; | |
| 3248 | 3179 | struct sctp_sock *sp = sctp_sk(sk); |
| 3249 | 3180 | |
| 3250 | 3181 | if (optlen < sizeof(int)) |
| 3251 | 3182 | return -EINVAL; |
| 3252 | − if (get_user(val, (int __user *)optval)) | |
| 3253 | − return -EFAULT; | |
| 3254 | − if (val) | |
| 3183 | + if (*val) | |
| 3255 | 3184 | sp->v4mapped = 1; |
| 3256 | 3185 | else |
| 3257 | 3186 | sp->v4mapped = 0; |
| @@ -3286,11 +3215,13 @@ static int sctp_setsockopt_mappedv4(struct sock *sk, char __user *optval, unsign · 28 unmodified lines | ||
| 3286 | 3215 | * changed (effecting future associations only). |
| 3287 | 3216 | * assoc_value: This parameter specifies the maximum size in bytes. |
| 3288 | 3217 | */ |
| 3289 | −static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned int optlen) | |
| 3218 | +static int sctp_setsockopt_maxseg(struct sock *sk, | |
| 3219 | + struct sctp_assoc_value *params, | |
| 3220 | + unsigned int optlen) | |
| 3290 | 3221 | { |
| 3291 | 3222 | struct sctp_sock *sp = sctp_sk(sk); |
| 3292 | − struct sctp_assoc_value params; | |
| 3293 | 3223 | struct sctp_association *asoc; |
| 3224 | + sctp_assoc_t assoc_id; | |
| 3294 | 3225 | int val; |
| 3295 | 3226 | |
| 3296 | 3227 | if (optlen == sizeof(int)) { |
| @@ -3299,19 +3230,17 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned · 2 unmodified lines | ||
| 3299 | 3230 | "Use of int in maxseg socket option.\n" |
| 3300 | 3231 | "Use struct sctp_assoc_value instead\n", |
| 3301 | 3232 | current->comm, task_pid_nr(current)); |
| 3302 | − if (copy_from_user(&val, optval, optlen)) | |
| 3303 | − return -EFAULT; | |
| 3304 | − params.assoc_id = SCTP_FUTURE_ASSOC; | |
| 3233 | + assoc_id = SCTP_FUTURE_ASSOC; | |
| 3234 | + val = *(int *)params; | |
| 3305 | 3235 | } else if (optlen == sizeof(struct sctp_assoc_value)) { |
| 3306 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 3307 | − return -EFAULT; | |
| 3308 | − val = params.assoc_value; | |
| 3236 | + assoc_id = params->assoc_id; | |
| 3237 | + val = params->assoc_value; | |
| 3309 | 3238 | } else { |
| 3310 | 3239 | return -EINVAL; |
| 3311 | 3240 | } |
| 3312 | 3241 | |
| 3313 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 3314 | − if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && | |
| 3242 | + asoc = sctp_id2assoc(sk, assoc_id); | |
| 3243 | + if (!asoc && assoc_id != SCTP_FUTURE_ASSOC && | |
| 3315 | 3244 | sctp_style(sk, UDP)) |
| 3316 | 3245 | return -EINVAL; |
| 3317 | 3246 | |
| @@ -3346,12 +3275,12 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned · 28 unmodified lines | ||
| 3346 | 3275 | * locally bound addresses. The following structure is used to make a |
| 3347 | 3276 | * set primary request: |
| 3348 | 3277 | */ |
| 3349 | −static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval, | |
| 3278 | +static int sctp_setsockopt_peer_primary_addr(struct sock *sk, | |
| 3279 | + struct sctp_setpeerprim *prim, | |
| 3350 | 3280 | unsigned int optlen) |
| 3351 | 3281 | { |
| 3352 | 3282 | struct sctp_sock *sp; |
| 3353 | 3283 | struct sctp_association *asoc = NULL; |
| 3354 | − struct sctp_setpeerprim prim; | |
| 3355 | 3284 | struct sctp_chunk *chunk; |
| 3356 | 3285 | struct sctp_af *af; |
| 3357 | 3286 | int err; |
| @@ -3364,10 +3293,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva · 6 unmodified lines | ||
| 3364 | 3293 | if (optlen != sizeof(struct sctp_setpeerprim)) |
| 3365 | 3294 | return -EINVAL; |
| 3366 | 3295 | |
| 3367 | − if (copy_from_user(&prim, optval, optlen)) | |
| 3368 | − return -EFAULT; | |
| 3369 | − | |
| 3370 | − asoc = sctp_id2assoc(sk, prim.sspp_assoc_id); | |
| 3296 | + asoc = sctp_id2assoc(sk, prim->sspp_assoc_id); | |
| 3371 | 3297 | if (!asoc) |
| 3372 | 3298 | return -EINVAL; |
| 3373 | 3299 | |
| @@ -3380,26 +3306,26 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva · 6 unmodified lines | ||
| 3380 | 3306 | if (!sctp_state(asoc, ESTABLISHED)) |
| 3381 | 3307 | return -ENOTCONN; |
| 3382 | 3308 | |
| 3383 | − af = sctp_get_af_specific(prim.sspp_addr.ss_family); | |
| 3309 | + af = sctp_get_af_specific(prim->sspp_addr.ss_family); | |
| 3384 | 3310 | if (!af) |
| 3385 | 3311 | return -EINVAL; |
| 3386 | 3312 | |
| 3387 | − if (!af->addr_valid((union sctp_addr *)&prim.sspp_addr, sp, NULL)) | |
| 3313 | + if (!af->addr_valid((union sctp_addr *)&prim->sspp_addr, sp, NULL)) | |
| 3388 | 3314 | return -EADDRNOTAVAIL; |
| 3389 | 3315 | |
| 3390 | − if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr)) | |
| 3316 | + if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim->sspp_addr)) | |
| 3391 | 3317 | return -EADDRNOTAVAIL; |
| 3392 | 3318 | |
| 3393 | 3319 | /* Allow security module to validate address. */ |
| 3394 | 3320 | err = security_sctp_bind_connect(sk, SCTP_SET_PEER_PRIMARY_ADDR, |
| 3395 | − (struct sockaddr *)&prim.sspp_addr, | |
| 3321 | + (struct sockaddr *)&prim->sspp_addr, | |
| 3396 | 3322 | af->sockaddr_len); |
| 3397 | 3323 | if (err) |
| 3398 | 3324 | return err; |
| 3399 | 3325 | |
| 3400 | 3326 | /* Create an ASCONF chunk with SET_PRIMARY parameter */ |
| 3401 | 3327 | chunk = sctp_make_asconf_set_prim(asoc, |
| 3402 | − (union sctp_addr *)&prim.sspp_addr); | |
| 3328 | + (union sctp_addr *)&prim->sspp_addr); | |
| 3403 | 3329 | if (!chunk) |
| 3404 | 3330 | return -ENOMEM; |
| 3405 | 3331 | |
| @@ -3410,17 +3336,14 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva · 4 unmodified lines | ||
| 3410 | 3336 | return err; |
| 3411 | 3337 | } |
| 3412 | 3338 | |
| 3413 | −static int sctp_setsockopt_adaptation_layer(struct sock *sk, char __user *optval, | |
| 3339 | +static int sctp_setsockopt_adaptation_layer(struct sock *sk, | |
| 3340 | + struct sctp_setadaptation *adapt, | |
| 3414 | 3341 | unsigned int optlen) |
| 3415 | 3342 | { |
| 3416 | − struct sctp_setadaptation adaptation; | |
| 3417 | − | |
| 3418 | 3343 | if (optlen != sizeof(struct sctp_setadaptation)) |
| 3419 | 3344 | return -EINVAL; |
| 3420 | − if (copy_from_user(&adaptation, optval, optlen)) | |
| 3421 | − return -EFAULT; | |
| 3422 | 3345 | |
| 3423 | − sctp_sk(sk)->adaptation_ind = adaptation.ssb_adaptation_ind; | |
| 3346 | + sctp_sk(sk)->adaptation_ind = adapt->ssb_adaptation_ind; | |
| 3424 | 3347 | |
| 3425 | 3348 | return 0; |
| 3426 | 3349 | } |
| @@ -3439,40 +3362,38 @@ static int sctp_setsockopt_adaptation_layer(struct sock *sk, char __user *optval · 12 unmodified lines | ||
| 3439 | 3362 | * received messages from the peer and does not effect the value that is |
| 3440 | 3363 | * saved with outbound messages. |
| 3441 | 3364 | */ |
| 3442 | −static int sctp_setsockopt_context(struct sock *sk, char __user *optval, | |
| 3365 | +static int sctp_setsockopt_context(struct sock *sk, | |
| 3366 | + struct sctp_assoc_value *params, | |
| 3443 | 3367 | unsigned int optlen) |
| 3444 | 3368 | { |
| 3445 | 3369 | struct sctp_sock *sp = sctp_sk(sk); |
| 3446 | − struct sctp_assoc_value params; | |
| 3447 | 3370 | struct sctp_association *asoc; |
| 3448 | 3371 | |
| 3449 | 3372 | if (optlen != sizeof(struct sctp_assoc_value)) |
| 3450 | 3373 | return -EINVAL; |
| 3451 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 3452 | − return -EFAULT; | |
| 3453 | 3374 | |
| 3454 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 3455 | − if (!asoc && params.assoc_id > SCTP_ALL_ASSOC && | |
| 3375 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 3376 | + if (!asoc && params->assoc_id > SCTP_ALL_ASSOC && | |
| 3456 | 3377 | sctp_style(sk, UDP)) |
| 3457 | 3378 | return -EINVAL; |
| 3458 | 3379 | |
| 3459 | 3380 | if (asoc) { |
| 3460 | − asoc->default_rcv_context = params.assoc_value; | |
| 3381 | + asoc->default_rcv_context = params->assoc_value; | |
| 3461 | 3382 | |
| 3462 | 3383 | return 0; |
| 3463 | 3384 | } |
| 3464 | 3385 | |
| 3465 | 3386 | if (sctp_style(sk, TCP)) |
| 3466 | − params.assoc_id = SCTP_FUTURE_ASSOC; | |
| 3387 | + params->assoc_id = SCTP_FUTURE_ASSOC; | |
| 3467 | 3388 | |
| 3468 | − if (params.assoc_id == SCTP_FUTURE_ASSOC || | |
| 3469 | − params.assoc_id == SCTP_ALL_ASSOC) | |
| 3470 | − sp->default_rcv_context = params.assoc_value; | |
| 3389 | + if (params->assoc_id == SCTP_FUTURE_ASSOC || | |
| 3390 | + params->assoc_id == SCTP_ALL_ASSOC) | |
| 3391 | + sp->default_rcv_context = params->assoc_value; | |
| 3471 | 3392 | |
| 3472 | − if (params.assoc_id == SCTP_CURRENT_ASSOC || | |
| 3473 | − params.assoc_id == SCTP_ALL_ASSOC) | |
| 3393 | + if (params->assoc_id == SCTP_CURRENT_ASSOC || | |
| 3394 | + params->assoc_id == SCTP_ALL_ASSOC) | |
| 3474 | 3395 | list_for_each_entry(asoc, &sp->ep->asocs, asocs) |
| 3475 | − asoc->default_rcv_context = params.assoc_value; | |
| 3396 | + asoc->default_rcv_context = params->assoc_value; | |
| 3476 | 3397 | |
| 3477 | 3398 | return 0; |
| 3478 | 3399 | } |
| @@ -3501,18 +3422,13 @@ static int sctp_setsockopt_context(struct sock *sk, char __user *optval, · 22 unmodified lines | ||
| 3501 | 3422 | * application using the one to many model may become confused and act |
| 3502 | 3423 | * incorrectly. |
| 3503 | 3424 | */ |
| 3504 | −static int sctp_setsockopt_fragment_interleave(struct sock *sk, | |
| 3505 | − char __user *optval, | |
| 3425 | +static int sctp_setsockopt_fragment_interleave(struct sock *sk, int *val, | |
| 3506 | 3426 | unsigned int optlen) |
| 3507 | 3427 | { |
| 3508 | − int val; | |
| 3509 | − | |
| 3510 | 3428 | if (optlen != sizeof(int)) |
| 3511 | 3429 | return -EINVAL; |
| 3512 | − if (get_user(val, (int __user *)optval)) | |
| 3513 | − return -EFAULT; | |
| 3514 | 3430 | |
| 3515 | − sctp_sk(sk)->frag_interleave = !!val; | |
| 3431 | + sctp_sk(sk)->frag_interleave = !!*val; | |
| 3516 | 3432 | |
| 3517 | 3433 | if (!sctp_sk(sk)->frag_interleave) |
| 3518 | 3434 | sctp_sk(sk)->ep->intl_enable = 0; |
| @@ -3537,24 +3453,19 @@ static int sctp_setsockopt_fragment_interleave(struct sock *sk, · 18 unmodified lines | ||
| 3537 | 3453 | * call as long as the user provided buffer is large enough to hold the |
| 3538 | 3454 | * message. |
| 3539 | 3455 | */ |
| 3540 | −static int sctp_setsockopt_partial_delivery_point(struct sock *sk, | |
| 3541 | − char __user *optval, | |
| 3456 | +static int sctp_setsockopt_partial_delivery_point(struct sock *sk, u32 *val, | |
| 3542 | 3457 | unsigned int optlen) |
| 3543 | 3458 | { |
| 3544 | − u32 val; | |
| 3545 | − | |
| 3546 | 3459 | if (optlen != sizeof(u32)) |
| 3547 | 3460 | return -EINVAL; |
| 3548 | − if (get_user(val, (int __user *)optval)) | |
| 3549 | − return -EFAULT; | |
| 3550 | 3461 | |
| 3551 | 3462 | /* Note: We double the receive buffer from what the user sets |
| 3552 | 3463 | * it to be, also initial rwnd is based on rcvbuf/2. |
| 3553 | 3464 | */ |
| 3554 | − if (val > (sk->sk_rcvbuf >> 1)) | |
| 3465 | + if (*val > (sk->sk_rcvbuf >> 1)) | |
| 3555 | 3466 | return -EINVAL; |
| 3556 | 3467 | |
| 3557 | − sctp_sk(sk)->pd_point = val; | |
| 3468 | + sctp_sk(sk)->pd_point = *val; | |
| 3558 | 3469 | |
| 3559 | 3470 | return 0; /* is this the right error code? */ |
| 3560 | 3471 | } |
| @@ -3571,12 +3482,13 @@ static int sctp_setsockopt_partial_delivery_point(struct sock *sk, · 10 unmodified lines | ||
| 3571 | 3482 | * future associations inheriting the socket value. |
| 3572 | 3483 | */ |
| 3573 | 3484 | static int sctp_setsockopt_maxburst(struct sock *sk, |
| 3574 | − char __user *optval, | |
| 3485 | + struct sctp_assoc_value *params, | |
| 3575 | 3486 | unsigned int optlen) |
| 3576 | 3487 | { |
| 3577 | 3488 | struct sctp_sock *sp = sctp_sk(sk); |
| 3578 | − struct sctp_assoc_value params; | |
| 3579 | 3489 | struct sctp_association *asoc; |
| 3490 | + sctp_assoc_t assoc_id; | |
| 3491 | + u32 assoc_value; | |
| 3580 | 3492 | |
| 3581 | 3493 | if (optlen == sizeof(int)) { |
| 3582 | 3494 | pr_warn_ratelimited(DEPRECATED |
| @@ -3584,37 +3496,33 @@ static int sctp_setsockopt_maxburst(struct sock *sk, · 1 unmodified line | ||
| 3584 | 3496 | "Use of int in max_burst socket option deprecated.\n" |
| 3585 | 3497 | "Use struct sctp_assoc_value instead\n", |
| 3586 | 3498 | current->comm, task_pid_nr(current)); |
| 3587 | − if (copy_from_user(¶ms.assoc_value, optval, optlen)) | |
| 3588 | − return -EFAULT; | |
| 3589 | − params.assoc_id = SCTP_FUTURE_ASSOC; | |
| 3499 | + assoc_id = SCTP_FUTURE_ASSOC; | |
| 3500 | + assoc_value = *((int *)params); | |
| 3590 | 3501 | } else if (optlen == sizeof(struct sctp_assoc_value)) { |
| 3591 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 3592 | − return -EFAULT; | |
| 3502 | + assoc_id = params->assoc_id; | |
| 3503 | + assoc_value = params->assoc_value; | |
| 3593 | 3504 | } else |
| 3594 | 3505 | return -EINVAL; |
| 3595 | 3506 | |
| 3596 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 3597 | − if (!asoc && params.assoc_id > SCTP_ALL_ASSOC && | |
| 3598 | − sctp_style(sk, UDP)) | |
| 3507 | + asoc = sctp_id2assoc(sk, assoc_id); | |
| 3508 | + if (!asoc && assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP)) | |
| 3599 | 3509 | return -EINVAL; |
| 3600 | 3510 | |
| 3601 | 3511 | if (asoc) { |
| 3602 | − asoc->max_burst = params.assoc_value; | |
| 3512 | + asoc->max_burst = assoc_value; | |
| 3603 | 3513 | |
| 3604 | 3514 | return 0; |
| 3605 | 3515 | } |
| 3606 | 3516 | |
| 3607 | 3517 | if (sctp_style(sk, TCP)) |
| 3608 | − params.assoc_id = SCTP_FUTURE_ASSOC; | |
| 3518 | + assoc_id = SCTP_FUTURE_ASSOC; | |
| 3609 | 3519 | |
| 3610 | − if (params.assoc_id == SCTP_FUTURE_ASSOC || | |
| 3611 | − params.assoc_id == SCTP_ALL_ASSOC) | |
| 3612 | − sp->max_burst = params.assoc_value; | |
| 3520 | + if (assoc_id == SCTP_FUTURE_ASSOC || assoc_id == SCTP_ALL_ASSOC) | |
| 3521 | + sp->max_burst = assoc_value; | |
| 3613 | 3522 | |
| 3614 | − if (params.assoc_id == SCTP_CURRENT_ASSOC || | |
| 3615 | − params.assoc_id == SCTP_ALL_ASSOC) | |
| 3523 | + if (assoc_id == SCTP_CURRENT_ASSOC || assoc_id == SCTP_ALL_ASSOC) | |
| 3616 | 3524 | list_for_each_entry(asoc, &sp->ep->asocs, asocs) |
| 3617 | − asoc->max_burst = params.assoc_value; | |
| 3525 | + asoc->max_burst = assoc_value; | |
| 3618 | 3526 | |
| 3619 | 3527 | return 0; |
| 3620 | 3528 | } |
| @@ -3627,21 +3535,18 @@ static int sctp_setsockopt_maxburst(struct sock *sk, · 6 unmodified lines | ||
| 3627 | 3535 | * will only effect future associations on the socket. |
| 3628 | 3536 | */ |
| 3629 | 3537 | static int sctp_setsockopt_auth_chunk(struct sock *sk, |
| 3630 | − char __user *optval, | |
| 3538 | + struct sctp_authchunk *val, | |
| 3631 | 3539 | unsigned int optlen) |
| 3632 | 3540 | { |
| 3633 | 3541 | struct sctp_endpoint *ep = sctp_sk(sk)->ep; |
| 3634 | − struct sctp_authchunk val; | |
| 3635 | 3542 | |
| 3636 | 3543 | if (!ep->auth_enable) |
| 3637 | 3544 | return -EACCES; |
| 3638 | 3545 | |
| 3639 | 3546 | if (optlen != sizeof(struct sctp_authchunk)) |
| 3640 | 3547 | return -EINVAL; |
| 3641 | − if (copy_from_user(&val, optval, optlen)) | |
| 3642 | − return -EFAULT; | |
| 3643 | 3548 | |
| 3644 | − switch (val.sauth_chunk) { | |
| 3549 | + switch (val->sauth_chunk) { | |
| 3645 | 3550 | case SCTP_CID_INIT: |
| 3646 | 3551 | case SCTP_CID_INIT_ACK: |
| 3647 | 3552 | case SCTP_CID_SHUTDOWN_COMPLETE: |
| @@ -3650,7 +3555,7 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, · 2 unmodified lines | ||
| 3650 | 3555 | } |
| 3651 | 3556 | |
| 3652 | 3557 | /* add this chunk id to the endpoint */ |
| 3653 | − return sctp_auth_ep_add_chunkid(ep, val.sauth_chunk); | |
| 3558 | + return sctp_auth_ep_add_chunkid(ep, val->sauth_chunk); | |
| 3654 | 3559 | } |
| 3655 | 3560 | |
| 3656 | 3561 | /* |
| @@ -3660,13 +3565,11 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, · 3 unmodified lines | ||
| 3660 | 3565 | * endpoint requires the peer to use. |
| 3661 | 3566 | */ |
| 3662 | 3567 | static int sctp_setsockopt_hmac_ident(struct sock *sk, |
| 3663 | − char __user *optval, | |
| 3568 | + struct sctp_hmacalgo *hmacs, | |
| 3664 | 3569 | unsigned int optlen) |
| 3665 | 3570 | { |
| 3666 | 3571 | struct sctp_endpoint *ep = sctp_sk(sk)->ep; |
| 3667 | − struct sctp_hmacalgo *hmacs; | |
| 3668 | 3572 | u32 idents; |
| 3669 | − int err; | |
| 3670 | 3573 | |
| 3671 | 3574 | if (!ep->auth_enable) |
| 3672 | 3575 | return -EACCES; |
| @@ -3676,21 +3579,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, · 3 unmodified lines | ||
| 3676 | 3579 | optlen = min_t(unsigned int, optlen, sizeof(struct sctp_hmacalgo) + |
| 3677 | 3580 | SCTP_AUTH_NUM_HMACS * sizeof(u16)); |
| 3678 | 3581 | |
| 3679 | − hmacs = memdup_user(optval, optlen); | |
| 3680 | − if (IS_ERR(hmacs)) | |
| 3681 | − return PTR_ERR(hmacs); | |
| 3682 | − | |
| 3683 | 3582 | idents = hmacs->shmac_num_idents; |
| 3684 | 3583 | if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || |
| 3685 | − (idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo))) { | |
| 3686 | − err = -EINVAL; | |
| 3687 | − goto out; | |
| 3688 | − } | |
| 3584 | + (idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo))) | |
| 3585 | + return -EINVAL; | |
| 3689 | 3586 | |
| 3690 | − err = sctp_auth_ep_set_hmacs(ep, hmacs); | |
| 3691 | −out: | |
| 3692 | − kfree(hmacs); | |
| 3693 | − return err; | |
| 3587 | + return sctp_auth_ep_set_hmacs(ep, hmacs); | |
| 3694 | 3588 | } |
| 3695 | 3589 | |
| 3696 | 3590 | /* |
| @@ -3700,11 +3594,10 @@ out: · 3 unmodified lines | ||
| 3700 | 3594 | * association shared key. |
| 3701 | 3595 | */ |
| 3702 | 3596 | static int sctp_setsockopt_auth_key(struct sock *sk, |
| 3703 | − char __user *optval, | |
| 3597 | + struct sctp_authkey *authkey, | |
| 3704 | 3598 | unsigned int optlen) |
| 3705 | 3599 | { |
| 3706 | 3600 | struct sctp_endpoint *ep = sctp_sk(sk)->ep; |
| 3707 | − struct sctp_authkey *authkey; | |
| 3708 | 3601 | struct sctp_association *asoc; |
| 3709 | 3602 | int ret = -EINVAL; |
| 3710 | 3603 | |
| @@ -3715,10 +3608,6 @@ static int sctp_setsockopt_auth_key(struct sock *sk, · 4 unmodified lines | ||
| 3715 | 3608 | */ |
| 3716 | 3609 | optlen = min_t(unsigned int, optlen, USHRT_MAX + sizeof(*authkey)); |
| 3717 | 3610 | |
| 3718 | − authkey = memdup_user(optval, optlen); | |
| 3719 | − if (IS_ERR(authkey)) | |
| 3720 | − return PTR_ERR(authkey); | |
| 3721 | − | |
| 3722 | 3611 | if (authkey->sca_keylength > optlen - sizeof(*authkey)) |
| 3723 | 3612 | goto out; |
| 3724 | 3613 | |
| @@ -3755,7 +3644,7 @@ static int sctp_setsockopt_auth_key(struct sock *sk, · 30 unmodified lines | ||
| 3755 | 3644 | } |
| 3756 | 3645 | |
| 3757 | 3646 | out: |
| 3758 | − kzfree(authkey); | |
| 3647 | + memzero_explicit(authkey, optlen); | |
| 3759 | 3648 | return ret; |
| 3760 | 3649 | } |
| 3761 | 3650 | |
| @@ -3766,42 +3655,39 @@ out: · 4 unmodified lines | ||
| 3766 | 3655 | * the association shared key. |
| 3767 | 3656 | */ |
| 3768 | 3657 | static int sctp_setsockopt_active_key(struct sock *sk, |
| 3769 | − char __user *optval, | |
| 3658 | + struct sctp_authkeyid *val, | |
| 3770 | 3659 | unsigned int optlen) |
| 3771 | 3660 | { |
| 3772 | 3661 | struct sctp_endpoint *ep = sctp_sk(sk)->ep; |
| 3773 | 3662 | struct sctp_association *asoc; |
| 3774 | − struct sctp_authkeyid val; | |
| 3775 | 3663 | int ret = 0; |
| 3776 | 3664 | |
| 3777 | 3665 | if (optlen != sizeof(struct sctp_authkeyid)) |
| 3778 | 3666 | return -EINVAL; |
| 3779 | − if (copy_from_user(&val, optval, optlen)) | |
| 3780 | − return -EFAULT; | |
| 3781 | 3667 | |
| 3782 | − asoc = sctp_id2assoc(sk, val.scact_assoc_id); | |
| 3783 | − if (!asoc && val.scact_assoc_id > SCTP_ALL_ASSOC && | |
| 3668 | + asoc = sctp_id2assoc(sk, val->scact_assoc_id); | |
| 3669 | + if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC && | |
| 3784 | 3670 | sctp_style(sk, UDP)) |
| 3785 | 3671 | return -EINVAL; |
| 3786 | 3672 | |
| 3787 | 3673 | if (asoc) |
| 3788 | − return sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); | |
| 3674 | + return sctp_auth_set_active_key(ep, asoc, val->scact_keynumber); | |
| 3789 | 3675 | |
| 3790 | 3676 | if (sctp_style(sk, TCP)) |
| 3791 | − val.scact_assoc_id = SCTP_FUTURE_ASSOC; | |
| 3677 | + val->scact_assoc_id = SCTP_FUTURE_ASSOC; | |
| 3792 | 3678 | |
| 3793 | − if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | |
| 3794 | − val.scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3795 | − ret = sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); | |
| 3679 | + if (val->scact_assoc_id == SCTP_FUTURE_ASSOC || | |
| 3680 | + val->scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3681 | + ret = sctp_auth_set_active_key(ep, asoc, val->scact_keynumber); | |
| 3796 | 3682 | if (ret) |
| 3797 | 3683 | return ret; |
| 3798 | 3684 | } |
| 3799 | 3685 | |
| 3800 | − if (val.scact_assoc_id == SCTP_CURRENT_ASSOC || | |
| 3801 | − val.scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3686 | + if (val->scact_assoc_id == SCTP_CURRENT_ASSOC || | |
| 3687 | + val->scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3802 | 3688 | list_for_each_entry(asoc, &ep->asocs, asocs) { |
| 3803 | 3689 | int res = sctp_auth_set_active_key(ep, asoc, |
| 3804 | − val.scact_keynumber); | |
| 3690 | + val->scact_keynumber); | |
| 3805 | 3691 | |
| 3806 | 3692 | if (res && !ret) |
| 3807 | 3693 | ret = res; |
| @@ -3817,42 +3703,39 @@ static int sctp_setsockopt_active_key(struct sock *sk, · 9 unmodified lines | ||
| 3817 | 3703 | * This set option will delete a shared secret key from use. |
| 3818 | 3704 | */ |
| 3819 | 3705 | static int sctp_setsockopt_del_key(struct sock *sk, |
| 3820 | − char __user *optval, | |
| 3706 | + struct sctp_authkeyid *val, | |
| 3821 | 3707 | unsigned int optlen) |
| 3822 | 3708 | { |
| 3823 | 3709 | struct sctp_endpoint *ep = sctp_sk(sk)->ep; |
| 3824 | 3710 | struct sctp_association *asoc; |
| 3825 | − struct sctp_authkeyid val; | |
| 3826 | 3711 | int ret = 0; |
| 3827 | 3712 | |
| 3828 | 3713 | if (optlen != sizeof(struct sctp_authkeyid)) |
| 3829 | 3714 | return -EINVAL; |
| 3830 | − if (copy_from_user(&val, optval, optlen)) | |
| 3831 | − return -EFAULT; | |
| 3832 | 3715 | |
| 3833 | − asoc = sctp_id2assoc(sk, val.scact_assoc_id); | |
| 3834 | − if (!asoc && val.scact_assoc_id > SCTP_ALL_ASSOC && | |
| 3716 | + asoc = sctp_id2assoc(sk, val->scact_assoc_id); | |
| 3717 | + if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC && | |
| 3835 | 3718 | sctp_style(sk, UDP)) |
| 3836 | 3719 | return -EINVAL; |
| 3837 | 3720 | |
| 3838 | 3721 | if (asoc) |
| 3839 | − return sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); | |
| 3722 | + return sctp_auth_del_key_id(ep, asoc, val->scact_keynumber); | |
| 3840 | 3723 | |
| 3841 | 3724 | if (sctp_style(sk, TCP)) |
| 3842 | − val.scact_assoc_id = SCTP_FUTURE_ASSOC; | |
| 3725 | + val->scact_assoc_id = SCTP_FUTURE_ASSOC; | |
| 3843 | 3726 | |
| 3844 | − if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | |
| 3845 | − val.scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3846 | − ret = sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); | |
| 3727 | + if (val->scact_assoc_id == SCTP_FUTURE_ASSOC || | |
| 3728 | + val->scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3729 | + ret = sctp_auth_del_key_id(ep, asoc, val->scact_keynumber); | |
| 3847 | 3730 | if (ret) |
| 3848 | 3731 | return ret; |
| 3849 | 3732 | } |
| 3850 | 3733 | |
| 3851 | − if (val.scact_assoc_id == SCTP_CURRENT_ASSOC || | |
| 3852 | − val.scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3734 | + if (val->scact_assoc_id == SCTP_CURRENT_ASSOC || | |
| 3735 | + val->scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3853 | 3736 | list_for_each_entry(asoc, &ep->asocs, asocs) { |
| 3854 | 3737 | int res = sctp_auth_del_key_id(ep, asoc, |
| 3855 | − val.scact_keynumber); | |
| 3738 | + val->scact_keynumber); | |
| 3856 | 3739 | |
| 3857 | 3740 | if (res && !ret) |
| 3858 | 3741 | ret = res; |
| @@ -3867,42 +3750,40 @@ static int sctp_setsockopt_del_key(struct sock *sk, · 8 unmodified lines | ||
| 3867 | 3750 | * |
| 3868 | 3751 | * This set option will deactivate a shared secret key. |
| 3869 | 3752 | */ |
| 3870 | −static int sctp_setsockopt_deactivate_key(struct sock *sk, char __user *optval, | |
| 3753 | +static int sctp_setsockopt_deactivate_key(struct sock *sk, | |
| 3754 | + struct sctp_authkeyid *val, | |
| 3871 | 3755 | unsigned int optlen) |
| 3872 | 3756 | { |
| 3873 | 3757 | struct sctp_endpoint *ep = sctp_sk(sk)->ep; |
| 3874 | 3758 | struct sctp_association *asoc; |
| 3875 | − struct sctp_authkeyid val; | |
| 3876 | 3759 | int ret = 0; |
| 3877 | 3760 | |
| 3878 | 3761 | if (optlen != sizeof(struct sctp_authkeyid)) |
| 3879 | 3762 | return -EINVAL; |
| 3880 | − if (copy_from_user(&val, optval, optlen)) | |
| 3881 | − return -EFAULT; | |
| 3882 | 3763 | |
| 3883 | − asoc = sctp_id2assoc(sk, val.scact_assoc_id); | |
| 3884 | − if (!asoc && val.scact_assoc_id > SCTP_ALL_ASSOC && | |
| 3764 | + asoc = sctp_id2assoc(sk, val->scact_assoc_id); | |
| 3765 | + if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC && | |
| 3885 | 3766 | sctp_style(sk, UDP)) |
| 3886 | 3767 | return -EINVAL; |
| 3887 | 3768 | |
| 3888 | 3769 | if (asoc) |
| 3889 | − return sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); | |
| 3770 | + return sctp_auth_deact_key_id(ep, asoc, val->scact_keynumber); | |
| 3890 | 3771 | |
| 3891 | 3772 | if (sctp_style(sk, TCP)) |
| 3892 | − val.scact_assoc_id = SCTP_FUTURE_ASSOC; | |
| 3773 | + val->scact_assoc_id = SCTP_FUTURE_ASSOC; | |
| 3893 | 3774 | |
| 3894 | − if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | |
| 3895 | − val.scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3896 | − ret = sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); | |
| 3775 | + if (val->scact_assoc_id == SCTP_FUTURE_ASSOC || | |
| 3776 | + val->scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3777 | + ret = sctp_auth_deact_key_id(ep, asoc, val->scact_keynumber); | |
| 3897 | 3778 | if (ret) |
| 3898 | 3779 | return ret; |
| 3899 | 3780 | } |
| 3900 | 3781 | |
| 3901 | − if (val.scact_assoc_id == SCTP_CURRENT_ASSOC || | |
| 3902 | − val.scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3782 | + if (val->scact_assoc_id == SCTP_CURRENT_ASSOC || | |
| 3783 | + val->scact_assoc_id == SCTP_ALL_ASSOC) { | |
| 3903 | 3784 | list_for_each_entry(asoc, &ep->asocs, asocs) { |
| 3904 | 3785 | int res = sctp_auth_deact_key_id(ep, asoc, |
| 3905 | − val.scact_keynumber); | |
| 3786 | + val->scact_keynumber); | |
| 3906 | 3787 | |
| 3907 | 3788 | if (res && !ret) |
| 3908 | 3789 | ret = res; |
| @@ -3926,26 +3807,23 @@ static int sctp_setsockopt_deactivate_key(struct sock *sk, char __user *optval, · 17 unmodified lines | ||
| 3926 | 3807 | * Note. In this implementation, socket operation overrides default parameter |
| 3927 | 3808 | * being set by sysctl as well as FreeBSD implementation |
| 3928 | 3809 | */ |
| 3929 | −static int sctp_setsockopt_auto_asconf(struct sock *sk, char __user *optval, | |
| 3810 | +static int sctp_setsockopt_auto_asconf(struct sock *sk, int *val, | |
| 3930 | 3811 | unsigned int optlen) |
| 3931 | 3812 | { |
| 3932 | − int val; | |
| 3933 | 3813 | struct sctp_sock *sp = sctp_sk(sk); |
| 3934 | 3814 | |
| 3935 | 3815 | if (optlen < sizeof(int)) |
| 3936 | 3816 | return -EINVAL; |
| 3937 | − if (get_user(val, (int __user *)optval)) | |
| 3938 | − return -EFAULT; | |
| 3939 | − if (!sctp_is_ep_boundall(sk) && val) | |
| 3817 | + if (!sctp_is_ep_boundall(sk) && *val) | |
| 3940 | 3818 | return -EINVAL; |
| 3941 | − if ((val && sp->do_auto_asconf) || (!val && !sp->do_auto_asconf)) | |
| 3819 | + if ((*val && sp->do_auto_asconf) || (!*val && !sp->do_auto_asconf)) | |
| 3942 | 3820 | return 0; |
| 3943 | 3821 | |
| 3944 | 3822 | spin_lock_bh(&sock_net(sk)->sctp.addr_wq_lock); |
| 3945 | − if (val == 0 && sp->do_auto_asconf) { | |
| 3823 | + if (*val == 0 && sp->do_auto_asconf) { | |
| 3946 | 3824 | list_del(&sp->auto_asconf_list); |
| 3947 | 3825 | sp->do_auto_asconf = 0; |
| 3948 | − } else if (val && !sp->do_auto_asconf) { | |
| 3826 | + } else if (*val && !sp->do_auto_asconf) { | |
| 3949 | 3827 | list_add_tail(&sp->auto_asconf_list, |
| 3950 | 3828 | &sock_net(sk)->sctp.auto_asconf_splist); |
| 3951 | 3829 | sp->do_auto_asconf = 1; |
| @@ -3962,176 +3840,154 @@ static int sctp_setsockopt_auto_asconf(struct sock *sk, char __user *optval, · 10 unmodified lines | ||
| 3962 | 3840 | * http://www.ietf.org/id/draft-nishida-tsvwg-sctp-failover-05.txt |
| 3963 | 3841 | */ |
| 3964 | 3842 | static int sctp_setsockopt_paddr_thresholds(struct sock *sk, |
| 3965 | − char __user *optval, | |
| 3843 | + struct sctp_paddrthlds_v2 *val, | |
| 3966 | 3844 | unsigned int optlen, bool v2) |
| 3967 | 3845 | { |
| 3968 | − struct sctp_paddrthlds_v2 val; | |
| 3969 | 3846 | struct sctp_transport *trans; |
| 3970 | 3847 | struct sctp_association *asoc; |
| 3971 | 3848 | int len; |
| 3972 | 3849 | |
| 3973 | − len = v2 ? sizeof(val) : sizeof(struct sctp_paddrthlds); | |
| 3850 | + len = v2 ? sizeof(*val) : sizeof(struct sctp_paddrthlds); | |
| 3974 | 3851 | if (optlen < len) |
| 3975 | 3852 | return -EINVAL; |
| 3976 | − if (copy_from_user(&val, optval, len)) | |
| 3977 | − return -EFAULT; | |
| 3978 | 3853 | |
| 3979 | − if (v2 && val.spt_pathpfthld > val.spt_pathcpthld) | |
| 3854 | + if (v2 && val->spt_pathpfthld > val->spt_pathcpthld) | |
| 3980 | 3855 | return -EINVAL; |
| 3981 | 3856 | |
| 3982 | − if (!sctp_is_any(sk, (const union sctp_addr *)&val.spt_address)) { | |
| 3983 | − trans = sctp_addr_id2transport(sk, &val.spt_address, | |
| 3984 | − val.spt_assoc_id); | |
| 3857 | + if (!sctp_is_any(sk, (const union sctp_addr *)&val->spt_address)) { | |
| 3858 | + trans = sctp_addr_id2transport(sk, &val->spt_address, | |
| 3859 | + val->spt_assoc_id); | |
| 3985 | 3860 | if (!trans) |
| 3986 | 3861 | return -ENOENT; |
| 3987 | 3862 | |
| 3988 | − if (val.spt_pathmaxrxt) | |
| 3989 | − trans->pathmaxrxt = val.spt_pathmaxrxt; | |
| 3863 | + if (val->spt_pathmaxrxt) | |
| 3864 | + trans->pathmaxrxt = val->spt_pathmaxrxt; | |
| 3990 | 3865 | if (v2) |
| 3991 | − trans->ps_retrans = val.spt_pathcpthld; | |
| 3992 | − trans->pf_retrans = val.spt_pathpfthld; | |
| 3866 | + trans->ps_retrans = val->spt_pathcpthld; | |
| 3867 | + trans->pf_retrans = val->spt_pathpfthld; | |
| 3993 | 3868 | |
| 3994 | 3869 | return 0; |
| 3995 | 3870 | } |
| 3996 | 3871 | |
| 3997 | − asoc = sctp_id2assoc(sk, val.spt_assoc_id); | |
| 3998 | − if (!asoc && val.spt_assoc_id != SCTP_FUTURE_ASSOC && | |
| 3872 | + asoc = sctp_id2assoc(sk, val->spt_assoc_id); | |
| 3873 | + if (!asoc && val->spt_assoc_id != SCTP_FUTURE_ASSOC && | |
| 3999 | 3874 | sctp_style(sk, UDP)) |
| 4000 | 3875 | return -EINVAL; |
| 4001 | 3876 | |
| 4002 | 3877 | if (asoc) { |
| 4003 | 3878 | list_for_each_entry(trans, &asoc->peer.transport_addr_list, |
| 4004 | 3879 | transports) { |
| 4005 | − if (val.spt_pathmaxrxt) | |
| 4006 | − trans->pathmaxrxt = val.spt_pathmaxrxt; | |
| 3880 | + if (val->spt_pathmaxrxt) | |
| 3881 | + trans->pathmaxrxt = val->spt_pathmaxrxt; | |
| 4007 | 3882 | if (v2) |
| 4008 | − trans->ps_retrans = val.spt_pathcpthld; | |
| 4009 | − trans->pf_retrans = val.spt_pathpfthld; | |
| 3883 | + trans->ps_retrans = val->spt_pathcpthld; | |
| 3884 | + trans->pf_retrans = val->spt_pathpfthld; | |
| 4010 | 3885 | } |
| 4011 | 3886 | |
| 4012 | − if (val.spt_pathmaxrxt) | |
| 4013 | − asoc->pathmaxrxt = val.spt_pathmaxrxt; | |
| 3887 | + if (val->spt_pathmaxrxt) | |
| 3888 | + asoc->pathmaxrxt = val->spt_pathmaxrxt; | |
| 4014 | 3889 | if (v2) |
| 4015 | − asoc->ps_retrans = val.spt_pathcpthld; | |
| 4016 | − asoc->pf_retrans = val.spt_pathpfthld; | |
| 3890 | + asoc->ps_retrans = val->spt_pathcpthld; | |
| 3891 | + asoc->pf_retrans = val->spt_pathpfthld; | |
| 4017 | 3892 | } else { |
| 4018 | 3893 | struct sctp_sock *sp = sctp_sk(sk); |
| 4019 | 3894 | |
| 4020 | − if (val.spt_pathmaxrxt) | |
| 4021 | − sp->pathmaxrxt = val.spt_pathmaxrxt; | |
| 3895 | + if (val->spt_pathmaxrxt) | |
| 3896 | + sp->pathmaxrxt = val->spt_pathmaxrxt; | |
| 4022 | 3897 | if (v2) |
| 4023 | − sp->ps_retrans = val.spt_pathcpthld; | |
| 4024 | − sp->pf_retrans = val.spt_pathpfthld; | |
| 3898 | + sp->ps_retrans = val->spt_pathcpthld; | |
| 3899 | + sp->pf_retrans = val->spt_pathpfthld; | |
| 4025 | 3900 | } |
| 4026 | 3901 | |
| 4027 | 3902 | return 0; |
| 4028 | 3903 | } |
| 4029 | 3904 | |
| 4030 | −static int sctp_setsockopt_recvrcvinfo(struct sock *sk, | |
| 4031 | − char __user *optval, | |
| 3905 | +static int sctp_setsockopt_recvrcvinfo(struct sock *sk, int *val, | |
| 4032 | 3906 | unsigned int optlen) |
| 4033 | 3907 | { |
| 4034 | − int val; | |
| 4035 | − | |
| 4036 | 3908 | if (optlen < sizeof(int)) |
| 4037 | 3909 | return -EINVAL; |
| 4038 | − if (get_user(val, (int __user *) optval)) | |
| 4039 | − return -EFAULT; | |
| 4040 | 3910 | |
| 4041 | − sctp_sk(sk)->recvrcvinfo = (val == 0) ? 0 : 1; | |
| 3911 | + sctp_sk(sk)->recvrcvinfo = (*val == 0) ? 0 : 1; | |
| 4042 | 3912 | |
| 4043 | 3913 | return 0; |
| 4044 | 3914 | } |
| 4045 | 3915 | |
| 4046 | −static int sctp_setsockopt_recvnxtinfo(struct sock *sk, | |
| 4047 | − char __user *optval, | |
| 3916 | +static int sctp_setsockopt_recvnxtinfo(struct sock *sk, int *val, | |
| 4048 | 3917 | unsigned int optlen) |
| 4049 | 3918 | { |
| 4050 | − int val; | |
| 4051 | − | |
| 4052 | 3919 | if (optlen < sizeof(int)) |
| 4053 | 3920 | return -EINVAL; |
| 4054 | − if (get_user(val, (int __user *) optval)) | |
| 4055 | − return -EFAULT; | |
| 4056 | 3921 | |
| 4057 | − sctp_sk(sk)->recvnxtinfo = (val == 0) ? 0 : 1; | |
| 3922 | + sctp_sk(sk)->recvnxtinfo = (*val == 0) ? 0 : 1; | |
| 4058 | 3923 | |
| 4059 | 3924 | return 0; |
| 4060 | 3925 | } |
| 4061 | 3926 | |
| 4062 | 3927 | static int sctp_setsockopt_pr_supported(struct sock *sk, |
| 4063 | − char __user *optval, | |
| 3928 | + struct sctp_assoc_value *params, | |
| 4064 | 3929 | unsigned int optlen) |
| 4065 | 3930 | { |
| 4066 | − struct sctp_assoc_value params; | |
| 4067 | 3931 | struct sctp_association *asoc; |
| 4068 | 3932 | |
| 4069 | − if (optlen != sizeof(params)) | |
| 3933 | + if (optlen != sizeof(*params)) | |
| 4070 | 3934 | return -EINVAL; |
| 4071 | 3935 | |
| 4072 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 4073 | − return -EFAULT; | |
| 4074 | − | |
| 4075 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4076 | − if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && | |
| 3936 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 3937 | + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && | |
| 4077 | 3938 | sctp_style(sk, UDP)) |
| 4078 | 3939 | return -EINVAL; |
| 4079 | 3940 | |
| 4080 | − sctp_sk(sk)->ep->prsctp_enable = !!params.assoc_value; | |
| 3941 | + sctp_sk(sk)->ep->prsctp_enable = !!params->assoc_value; | |
| 4081 | 3942 | |
| 4082 | 3943 | return 0; |
| 4083 | 3944 | } |
| 4084 | 3945 | |
| 4085 | 3946 | static int sctp_setsockopt_default_prinfo(struct sock *sk, |
| 4086 | − char __user *optval, | |
| 3947 | + struct sctp_default_prinfo *info, | |
| 4087 | 3948 | unsigned int optlen) |
| 4088 | 3949 | { |
| 4089 | 3950 | struct sctp_sock *sp = sctp_sk(sk); |
| 4090 | − struct sctp_default_prinfo info; | |
| 4091 | 3951 | struct sctp_association *asoc; |
| 4092 | 3952 | int retval = -EINVAL; |
| 4093 | 3953 | |
| 4094 | − if (optlen != sizeof(info)) | |
| 4095 | − goto out; | |
| 4096 | − | |
| 4097 | − if (copy_from_user(&info, optval, sizeof(info))) { | |
| 4098 | − retval = -EFAULT; | |
| 3954 | + if (optlen != sizeof(*info)) | |
| 4099 | 3955 | goto out; |
| 4100 | − } | |
| 4101 | 3956 | |
| 4102 | − if (info.pr_policy & ~SCTP_PR_SCTP_MASK) | |
| 3957 | + if (info->pr_policy & ~SCTP_PR_SCTP_MASK) | |
| 4103 | 3958 | goto out; |
| 4104 | 3959 | |
| 4105 | − if (info.pr_policy == SCTP_PR_SCTP_NONE) | |
| 4106 | − info.pr_value = 0; | |
| 3960 | + if (info->pr_policy == SCTP_PR_SCTP_NONE) | |
| 3961 | + info->pr_value = 0; | |
| 4107 | 3962 | |
| 4108 | − asoc = sctp_id2assoc(sk, info.pr_assoc_id); | |
| 4109 | − if (!asoc && info.pr_assoc_id > SCTP_ALL_ASSOC && | |
| 3963 | + asoc = sctp_id2assoc(sk, info->pr_assoc_id); | |
| 3964 | + if (!asoc && info->pr_assoc_id > SCTP_ALL_ASSOC && | |
| 4110 | 3965 | sctp_style(sk, UDP)) |
| 4111 | 3966 | goto out; |
| 4112 | 3967 | |
| 4113 | 3968 | retval = 0; |
| 4114 | 3969 | |
| 4115 | 3970 | if (asoc) { |
| 4116 | − SCTP_PR_SET_POLICY(asoc->default_flags, info.pr_policy); | |
| 4117 | − asoc->default_timetolive = info.pr_value; | |
| 3971 | + SCTP_PR_SET_POLICY(asoc->default_flags, info->pr_policy); | |
| 3972 | + asoc->default_timetolive = info->pr_value; | |
| 4118 | 3973 | goto out; |
| 4119 | 3974 | } |
| 4120 | 3975 | |
| 4121 | 3976 | if (sctp_style(sk, TCP)) |
| 4122 | − info.pr_assoc_id = SCTP_FUTURE_ASSOC; | |
| 3977 | + info->pr_assoc_id = SCTP_FUTURE_ASSOC; | |
| 4123 | 3978 | |
| 4124 | − if (info.pr_assoc_id == SCTP_FUTURE_ASSOC || | |
| 4125 | − info.pr_assoc_id == SCTP_ALL_ASSOC) { | |
| 4126 | − SCTP_PR_SET_POLICY(sp->default_flags, info.pr_policy); | |
| 4127 | − sp->default_timetolive = info.pr_value; | |
| 3979 | + if (info->pr_assoc_id == SCTP_FUTURE_ASSOC || | |
| 3980 | + info->pr_assoc_id == SCTP_ALL_ASSOC) { | |
| 3981 | + SCTP_PR_SET_POLICY(sp->default_flags, info->pr_policy); | |
| 3982 | + sp->default_timetolive = info->pr_value; | |
| 4128 | 3983 | } |
| 4129 | 3984 | |
| 4130 | − if (info.pr_assoc_id == SCTP_CURRENT_ASSOC || | |
| 4131 | − info.pr_assoc_id == SCTP_ALL_ASSOC) { | |
| 3985 | + if (info->pr_assoc_id == SCTP_CURRENT_ASSOC || | |
| 3986 | + info->pr_assoc_id == SCTP_ALL_ASSOC) { | |
| 4132 | 3987 | list_for_each_entry(asoc, &sp->ep->asocs, asocs) { |
| 4133 | − SCTP_PR_SET_POLICY(asoc->default_flags, info.pr_policy); | |
| 4134 | − asoc->default_timetolive = info.pr_value; | |
| 3988 | + SCTP_PR_SET_POLICY(asoc->default_flags, | |
| 3989 | + info->pr_policy); | |
| 3990 | + asoc->default_timetolive = info->pr_value; | |
| 4135 | 3991 | } |
| 4136 | 3992 | } |
| 4137 | 3993 | |
| @@ -4140,27 +3996,21 @@ out: · 2 unmodified lines | ||
| 4140 | 3996 | } |
| 4141 | 3997 | |
| 4142 | 3998 | static int sctp_setsockopt_reconfig_supported(struct sock *sk, |
| 4143 | − char __user *optval, | |
| 3999 | + struct sctp_assoc_value *params, | |
| 4144 | 4000 | unsigned int optlen) |
| 4145 | 4001 | { |
| 4146 | − struct sctp_assoc_value params; | |
| 4147 | 4002 | struct sctp_association *asoc; |
| 4148 | 4003 | int retval = -EINVAL; |
| 4149 | 4004 | |
| 4150 | − if (optlen != sizeof(params)) | |
| 4005 | + if (optlen != sizeof(*params)) | |
| 4151 | 4006 | goto out; |
| 4152 | 4007 | |
| 4153 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4154 | − retval = -EFAULT; | |
| 4155 | − goto out; | |
| 4156 | − } | |
| 4157 | − | |
| 4158 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4159 | − if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && | |
| 4008 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 4009 | + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && | |
| 4160 | 4010 | sctp_style(sk, UDP)) |
| 4161 | 4011 | goto out; |
| 4162 | 4012 | |
| 4163 | − sctp_sk(sk)->ep->reconf_enable = !!params.assoc_value; | |
| 4013 | + sctp_sk(sk)->ep->reconf_enable = !!params->assoc_value; | |
| 4164 | 4014 | |
| 4165 | 4015 | retval = 0; |
| 4166 | 4016 | |
| @@ -4169,60 +4019,52 @@ out: · 2 unmodified lines | ||
| 4169 | 4019 | } |
| 4170 | 4020 | |
| 4171 | 4021 | static int sctp_setsockopt_enable_strreset(struct sock *sk, |
| 4172 | − char __user *optval, | |
| 4022 | + struct sctp_assoc_value *params, | |
| 4173 | 4023 | unsigned int optlen) |
| 4174 | 4024 | { |
| 4175 | 4025 | struct sctp_endpoint *ep = sctp_sk(sk)->ep; |
| 4176 | − struct sctp_assoc_value params; | |
| 4177 | 4026 | struct sctp_association *asoc; |
| 4178 | 4027 | int retval = -EINVAL; |
| 4179 | 4028 | |
| 4180 | − if (optlen != sizeof(params)) | |
| 4181 | − goto out; | |
| 4182 | − | |
| 4183 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4184 | − retval = -EFAULT; | |
| 4029 | + if (optlen != sizeof(*params)) | |
| 4185 | 4030 | goto out; |
| 4186 | − } | |
| 4187 | 4031 | |
| 4188 | − if (params.assoc_value & (~SCTP_ENABLE_STRRESET_MASK)) | |
| 4032 | + if (params->assoc_value & (~SCTP_ENABLE_STRRESET_MASK)) | |
| 4189 | 4033 | goto out; |
| 4190 | 4034 | |
| 4191 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4192 | − if (!asoc && params.assoc_id > SCTP_ALL_ASSOC && | |
| 4035 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 4036 | + if (!asoc && params->assoc_id > SCTP_ALL_ASSOC && | |
| 4193 | 4037 | sctp_style(sk, UDP)) |
| 4194 | 4038 | goto out; |
| 4195 | 4039 | |
| 4196 | 4040 | retval = 0; |
| 4197 | 4041 | |
| 4198 | 4042 | if (asoc) { |
| 4199 | − asoc->strreset_enable = params.assoc_value; | |
| 4043 | + asoc->strreset_enable = params->assoc_value; | |
| 4200 | 4044 | goto out; |
| 4201 | 4045 | } |
| 4202 | 4046 | |
| 4203 | 4047 | if (sctp_style(sk, TCP)) |
| 4204 | − params.assoc_id = SCTP_FUTURE_ASSOC; | |
| 4048 | + params->assoc_id = SCTP_FUTURE_ASSOC; | |
| 4205 | 4049 | |
| 4206 | − if (params.assoc_id == SCTP_FUTURE_ASSOC || | |
| 4207 | − params.assoc_id == SCTP_ALL_ASSOC) | |
| 4208 | − ep->strreset_enable = params.assoc_value; | |
| 4050 | + if (params->assoc_id == SCTP_FUTURE_ASSOC || | |
| 4051 | + params->assoc_id == SCTP_ALL_ASSOC) | |
| 4052 | + ep->strreset_enable = params->assoc_value; | |
| 4209 | 4053 | |
| 4210 | − if (params.assoc_id == SCTP_CURRENT_ASSOC || | |
| 4211 | − params.assoc_id == SCTP_ALL_ASSOC) | |
| 4054 | + if (params->assoc_id == SCTP_CURRENT_ASSOC || | |
| 4055 | + params->assoc_id == SCTP_ALL_ASSOC) | |
| 4212 | 4056 | list_for_each_entry(asoc, &ep->asocs, asocs) |
| 4213 | − asoc->strreset_enable = params.assoc_value; | |
| 4057 | + asoc->strreset_enable = params->assoc_value; | |
| 4214 | 4058 | |
| 4215 | 4059 | out: |
| 4216 | 4060 | return retval; |
| 4217 | 4061 | } |
| 4218 | 4062 | |
| 4219 | 4063 | static int sctp_setsockopt_reset_streams(struct sock *sk, |
| 4220 | − char __user *optval, | |
| 4064 | + struct sctp_reset_streams *params, | |
| 4221 | 4065 | unsigned int optlen) |
| 4222 | 4066 | { |
| 4223 | − struct sctp_reset_streams *params; | |
| 4224 | 4067 | struct sctp_association *asoc; |
| 4225 | − int retval = -EINVAL; | |
| 4226 | 4068 | |
| 4227 | 4069 | if (optlen < sizeof(*params)) |
| 4228 | 4070 | return -EINVAL; |
| @@ -4230,116 +4072,82 @@ static int sctp_setsockopt_reset_streams(struct sock *sk, · 1 unmodified line | ||
| 4230 | 4072 | optlen = min_t(unsigned int, optlen, USHRT_MAX + |
| 4231 | 4073 | sizeof(__u16) * sizeof(*params)); |
| 4232 | 4074 | |
| 4233 | − params = memdup_user(optval, optlen); | |
| 4234 | − if (IS_ERR(params)) | |
| 4235 | − return PTR_ERR(params); | |
| 4236 | − | |
| 4237 | 4075 | if (params->srs_number_streams * sizeof(__u16) > |
| 4238 | 4076 | optlen - sizeof(*params)) |
| 4239 | − goto out; | |
| 4077 | + return -EINVAL; | |
| 4240 | 4078 | |
| 4241 | 4079 | asoc = sctp_id2assoc(sk, params->srs_assoc_id); |
| 4242 | 4080 | if (!asoc) |
| 4243 | − goto out; | |
| 4244 | − | |
| 4245 | − retval = sctp_send_reset_streams(asoc, params); | |
| 4081 | + return -EINVAL; | |
| 4246 | 4082 | |
| 4247 | −out: | |
| 4248 | − kfree(params); | |
| 4249 | − return retval; | |
| 4083 | + return sctp_send_reset_streams(asoc, params); | |
| 4250 | 4084 | } |
| 4251 | 4085 | |
| 4252 | −static int sctp_setsockopt_reset_assoc(struct sock *sk, | |
| 4253 | − char __user *optval, | |
| 4086 | +static int sctp_setsockopt_reset_assoc(struct sock *sk, sctp_assoc_t *associd, | |
| 4254 | 4087 | unsigned int optlen) |
| 4255 | 4088 | { |
| 4256 | 4089 | struct sctp_association *asoc; |
| 4257 | − sctp_assoc_t associd; | |
| 4258 | − int retval = -EINVAL; | |
| 4259 | − | |
| 4260 | − if (optlen != sizeof(associd)) | |
| 4261 | − goto out; | |
| 4262 | 4090 | |
| 4263 | − if (copy_from_user(&associd, optval, optlen)) { | |
| 4264 | − retval = -EFAULT; | |
| 4265 | − goto out; | |
| 4266 | − } | |
| 4091 | + if (optlen != sizeof(*associd)) | |
| 4092 | + return -EINVAL; | |
| 4267 | 4093 | |
| 4268 | − asoc = sctp_id2assoc(sk, associd); | |
| 4094 | + asoc = sctp_id2assoc(sk, *associd); | |
| 4269 | 4095 | if (!asoc) |
| 4270 | − goto out; | |
| 4271 | − | |
| 4272 | − retval = sctp_send_reset_assoc(asoc); | |
| 4096 | + return -EINVAL; | |
| 4273 | 4097 | |
| 4274 | −out: | |
| 4275 | − return retval; | |
| 4098 | + return sctp_send_reset_assoc(asoc); | |
| 4276 | 4099 | } |
| 4277 | 4100 | |
| 4278 | 4101 | static int sctp_setsockopt_add_streams(struct sock *sk, |
| 4279 | − char __user *optval, | |
| 4102 | + struct sctp_add_streams *params, | |
| 4280 | 4103 | unsigned int optlen) |
| 4281 | 4104 | { |
| 4282 | 4105 | struct sctp_association *asoc; |
| 4283 | − struct sctp_add_streams params; | |
| 4284 | − int retval = -EINVAL; | |
| 4285 | 4106 | |
| 4286 | − if (optlen != sizeof(params)) | |
| 4287 | − goto out; | |
| 4288 | − | |
| 4289 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4290 | − retval = -EFAULT; | |
| 4291 | − goto out; | |
| 4292 | − } | |
| 4107 | + if (optlen != sizeof(*params)) | |
| 4108 | + return -EINVAL; | |
| 4293 | 4109 | |
| 4294 | − asoc = sctp_id2assoc(sk, params.sas_assoc_id); | |
| 4110 | + asoc = sctp_id2assoc(sk, params->sas_assoc_id); | |
| 4295 | 4111 | if (!asoc) |
| 4296 | − goto out; | |
| 4297 | − | |
| 4298 | − retval = sctp_send_add_streams(asoc, ¶ms); | |
| 4112 | + return -EINVAL; | |
| 4299 | 4113 | |
| 4300 | −out: | |
| 4301 | − return retval; | |
| 4114 | + return sctp_send_add_streams(asoc, params); | |
| 4302 | 4115 | } |
| 4303 | 4116 | |
| 4304 | 4117 | static int sctp_setsockopt_scheduler(struct sock *sk, |
| 4305 | − char __user *optval, | |
| 4118 | + struct sctp_assoc_value *params, | |
| 4306 | 4119 | unsigned int optlen) |
| 4307 | 4120 | { |
| 4308 | 4121 | struct sctp_sock *sp = sctp_sk(sk); |
| 4309 | 4122 | struct sctp_association *asoc; |
| 4310 | − struct sctp_assoc_value params; | |
| 4311 | 4123 | int retval = 0; |
| 4312 | 4124 | |
| 4313 | − if (optlen < sizeof(params)) | |
| 4125 | + if (optlen < sizeof(*params)) | |
| 4314 | 4126 | return -EINVAL; |
| 4315 | 4127 | |
| 4316 | − optlen = sizeof(params); | |
| 4317 | − if (copy_from_user(¶ms, optval, optlen)) | |
| 4318 | − return -EFAULT; | |
| 4319 | − | |
| 4320 | − if (params.assoc_value > SCTP_SS_MAX) | |
| 4128 | + if (params->assoc_value > SCTP_SS_MAX) | |
| 4321 | 4129 | return -EINVAL; |
| 4322 | 4130 | |
| 4323 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4324 | − if (!asoc && params.assoc_id > SCTP_ALL_ASSOC && | |
| 4131 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 4132 | + if (!asoc && params->assoc_id > SCTP_ALL_ASSOC && | |
| 4325 | 4133 | sctp_style(sk, UDP)) |
| 4326 | 4134 | return -EINVAL; |
| 4327 | 4135 | |
| 4328 | 4136 | if (asoc) |
| 4329 | − return sctp_sched_set_sched(asoc, params.assoc_value); | |
| 4137 | + return sctp_sched_set_sched(asoc, params->assoc_value); | |
| 4330 | 4138 | |
| 4331 | 4139 | if (sctp_style(sk, TCP)) |
| 4332 | − params.assoc_id = SCTP_FUTURE_ASSOC; | |
| 4140 | + params->assoc_id = SCTP_FUTURE_ASSOC; | |
| 4333 | 4141 | |
| 4334 | − if (params.assoc_id == SCTP_FUTURE_ASSOC || | |
| 4335 | − params.assoc_id == SCTP_ALL_ASSOC) | |
| 4336 | − sp->default_ss = params.assoc_value; | |
| 4142 | + if (params->assoc_id == SCTP_FUTURE_ASSOC || | |
| 4143 | + params->assoc_id == SCTP_ALL_ASSOC) | |
| 4144 | + sp->default_ss = params->assoc_value; | |
| 4337 | 4145 | |
| 4338 | − if (params.assoc_id == SCTP_CURRENT_ASSOC || | |
| 4339 | − params.assoc_id == SCTP_ALL_ASSOC) { | |
| 4146 | + if (params->assoc_id == SCTP_CURRENT_ASSOC || | |
| 4147 | + params->assoc_id == SCTP_ALL_ASSOC) { | |
| 4340 | 4148 | list_for_each_entry(asoc, &sp->ep->asocs, asocs) { |
| 4341 | 4149 | int ret = sctp_sched_set_sched(asoc, |
| 4342 | − params.assoc_value); | |
| 4150 | + params->assoc_value); | |
| 4343 | 4151 | |
| 4344 | 4152 | if (ret && !retval) |
| 4345 | 4153 | retval = ret; |
| @@ -4350,38 +4158,32 @@ static int sctp_setsockopt_scheduler(struct sock *sk, · 4 unmodified lines | ||
| 4350 | 4158 | } |
| 4351 | 4159 | |
| 4352 | 4160 | static int sctp_setsockopt_scheduler_value(struct sock *sk, |
| 4353 | − char __user *optval, | |
| 4161 | + struct sctp_stream_value *params, | |
| 4354 | 4162 | unsigned int optlen) |
| 4355 | 4163 | { |
| 4356 | − struct sctp_stream_value params; | |
| 4357 | 4164 | struct sctp_association *asoc; |
| 4358 | 4165 | int retval = -EINVAL; |
| 4359 | 4166 | |
| 4360 | − if (optlen < sizeof(params)) | |
| 4361 | − goto out; | |
| 4362 | − | |
| 4363 | − optlen = sizeof(params); | |
| 4364 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4365 | − retval = -EFAULT; | |
| 4167 | + if (optlen < sizeof(*params)) | |
| 4366 | 4168 | goto out; |
| 4367 | − } | |
| 4368 | 4169 | |
| 4369 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4370 | − if (!asoc && params.assoc_id != SCTP_CURRENT_ASSOC && | |
| 4170 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 4171 | + if (!asoc && params->assoc_id != SCTP_CURRENT_ASSOC && | |
| 4371 | 4172 | sctp_style(sk, UDP)) |
| 4372 | 4173 | goto out; |
| 4373 | 4174 | |
| 4374 | 4175 | if (asoc) { |
| 4375 | − retval = sctp_sched_set_value(asoc, params.stream_id, | |
| 4376 | − params.stream_value, GFP_KERNEL); | |
| 4176 | + retval = sctp_sched_set_value(asoc, params->stream_id, | |
| 4177 | + params->stream_value, GFP_KERNEL); | |
| 4377 | 4178 | goto out; |
| 4378 | 4179 | } |
| 4379 | 4180 | |
| 4380 | 4181 | retval = 0; |
| 4381 | 4182 | |
| 4382 | 4183 | list_for_each_entry(asoc, &sctp_sk(sk)->ep->asocs, asocs) { |
| 4383 | − int ret = sctp_sched_set_value(asoc, params.stream_id, | |
| 4384 | − params.stream_value, GFP_KERNEL); | |
| 4184 | + int ret = sctp_sched_set_value(asoc, params->stream_id, | |
| 4185 | + params->stream_value, | |
| 4186 | + GFP_KERNEL); | |
| 4385 | 4187 | if (ret && !retval) /* try to return the 1st error. */ |
| 4386 | 4188 | retval = ret; |
| 4387 | 4189 | } |
| @@ -4391,46 +4193,30 @@ out: · 3 unmodified lines | ||
| 4391 | 4193 | } |
| 4392 | 4194 | |
| 4393 | 4195 | static int sctp_setsockopt_interleaving_supported(struct sock *sk, |
| 4394 | − char __user *optval, | |
| 4196 | + struct sctp_assoc_value *p, | |
| 4395 | 4197 | unsigned int optlen) |
| 4396 | 4198 | { |
| 4397 | 4199 | struct sctp_sock *sp = sctp_sk(sk); |
| 4398 | − struct sctp_assoc_value params; | |
| 4399 | 4200 | struct sctp_association *asoc; |
| 4400 | − int retval = -EINVAL; | |
| 4401 | 4201 | |
| 4402 | − if (optlen < sizeof(params)) | |
| 4403 | − goto out; | |
| 4404 | − | |
| 4405 | − optlen = sizeof(params); | |
| 4406 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4407 | − retval = -EFAULT; | |
| 4408 | − goto out; | |
| 4409 | − } | |
| 4202 | + if (optlen < sizeof(*p)) | |
| 4203 | + return -EINVAL; | |
| 4410 | 4204 | |
| 4411 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4412 | − if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && | |
| 4413 | − sctp_style(sk, UDP)) | |
| 4414 | − goto out; | |
| 4205 | + asoc = sctp_id2assoc(sk, p->assoc_id); | |
| 4206 | + if (!asoc && p->assoc_id != SCTP_FUTURE_ASSOC && sctp_style(sk, UDP)) | |
| 4207 | + return -EINVAL; | |
| 4415 | 4208 | |
| 4416 | 4209 | if (!sock_net(sk)->sctp.intl_enable || !sp->frag_interleave) { |
| 4417 | − retval = -EPERM; | |
| 4418 | − goto out; | |
| 4210 | + return -EPERM; | |
| 4419 | 4211 | } |
| 4420 | 4212 | |
| 4421 | − sp->ep->intl_enable = !!params.assoc_value; | |
| 4422 | − | |
| 4423 | − retval = 0; | |
| 4424 | − | |
| 4425 | −out: | |
| 4426 | − return retval; | |
| 4213 | + sp->ep->intl_enable = !!p->assoc_value; | |
| 4214 | + return 0; | |
| 4427 | 4215 | } |
| 4428 | 4216 | |
| 4429 | −static int sctp_setsockopt_reuse_port(struct sock *sk, char __user *optval, | |
| 4217 | +static int sctp_setsockopt_reuse_port(struct sock *sk, int *val, | |
| 4430 | 4218 | unsigned int optlen) |
| 4431 | 4219 | { |
| 4432 | − int val; | |
| 4433 | − | |
| 4434 | 4220 | if (!sctp_style(sk, TCP)) |
| 4435 | 4221 | return -EOPNOTSUPP; |
| 4436 | 4222 | |
| @@ -4440,10 +4226,7 @@ static int sctp_setsockopt_reuse_port(struct sock *sk, char __user *optval, · 3 unmodified lines | ||
| 4440 | 4226 | if (optlen < sizeof(int)) |
| 4441 | 4227 | return -EINVAL; |
| 4442 | 4228 | |
| 4443 | − if (get_user(val, (int __user *)optval)) | |
| 4444 | − return -EFAULT; | |
| 4445 | − | |
| 4446 | − sctp_sk(sk)->reuse = !!val; | |
| 4229 | + sctp_sk(sk)->reuse = !!*val; | |
| 4447 | 4230 | |
| 4448 | 4231 | return 0; |
| 4449 | 4232 | } |
| @@ -4469,45 +4252,40 @@ static int sctp_assoc_ulpevent_type_set(struct sctp_event *param, · 19 unmodified lines | ||
| 4469 | 4252 | return 0; |
| 4470 | 4253 | } |
| 4471 | 4254 | |
| 4472 | −static int sctp_setsockopt_event(struct sock *sk, char __user *optval, | |
| 4255 | +static int sctp_setsockopt_event(struct sock *sk, struct sctp_event *param, | |
| 4473 | 4256 | unsigned int optlen) |
| 4474 | 4257 | { |
| 4475 | 4258 | struct sctp_sock *sp = sctp_sk(sk); |
| 4476 | 4259 | struct sctp_association *asoc; |
| 4477 | − struct sctp_event param; | |
| 4478 | 4260 | int retval = 0; |
| 4479 | 4261 | |
| 4480 | − if (optlen < sizeof(param)) | |
| 4262 | + if (optlen < sizeof(*param)) | |
| 4481 | 4263 | return -EINVAL; |
| 4482 | 4264 | |
| 4483 | − optlen = sizeof(param); | |
| 4484 | − if (copy_from_user(¶m, optval, optlen)) | |
| 4485 | − return -EFAULT; | |
| 4486 | − | |
| 4487 | − if (param.se_type < SCTP_SN_TYPE_BASE || | |
| 4488 | − param.se_type > SCTP_SN_TYPE_MAX) | |
| 4265 | + if (param->se_type < SCTP_SN_TYPE_BASE || | |
| 4266 | + param->se_type > SCTP_SN_TYPE_MAX) | |
| 4489 | 4267 | return -EINVAL; |
| 4490 | 4268 | |
| 4491 | − asoc = sctp_id2assoc(sk, param.se_assoc_id); | |
| 4492 | − if (!asoc && param.se_assoc_id > SCTP_ALL_ASSOC && | |
| 4269 | + asoc = sctp_id2assoc(sk, param->se_assoc_id); | |
| 4270 | + if (!asoc && param->se_assoc_id > SCTP_ALL_ASSOC && | |
| 4493 | 4271 | sctp_style(sk, UDP)) |
| 4494 | 4272 | return -EINVAL; |
| 4495 | 4273 | |
| 4496 | 4274 | if (asoc) |
| 4497 | − return sctp_assoc_ulpevent_type_set(¶m, asoc); | |
| 4275 | + return sctp_assoc_ulpevent_type_set(param, asoc); | |
| 4498 | 4276 | |
| 4499 | 4277 | if (sctp_style(sk, TCP)) |
| 4500 | − param.se_assoc_id = SCTP_FUTURE_ASSOC; | |
| 4278 | + param->se_assoc_id = SCTP_FUTURE_ASSOC; | |
| 4501 | 4279 | |
| 4502 | − if (param.se_assoc_id == SCTP_FUTURE_ASSOC || | |
| 4503 | − param.se_assoc_id == SCTP_ALL_ASSOC) | |
| 4280 | + if (param->se_assoc_id == SCTP_FUTURE_ASSOC || | |
| 4281 | + param->se_assoc_id == SCTP_ALL_ASSOC) | |
| 4504 | 4282 | sctp_ulpevent_type_set(&sp->subscribe, |
| 4505 | − param.se_type, param.se_on); | |
| 4283 | + param->se_type, param->se_on); | |
| 4506 | 4284 | |
| 4507 | − if (param.se_assoc_id == SCTP_CURRENT_ASSOC || | |
| 4508 | − param.se_assoc_id == SCTP_ALL_ASSOC) { | |
| 4285 | + if (param->se_assoc_id == SCTP_CURRENT_ASSOC || | |
| 4286 | + param->se_assoc_id == SCTP_ALL_ASSOC) { | |
| 4509 | 4287 | list_for_each_entry(asoc, &sp->ep->asocs, asocs) { |
| 4510 | − int ret = sctp_assoc_ulpevent_type_set(¶m, asoc); | |
| 4288 | + int ret = sctp_assoc_ulpevent_type_set(param, asoc); | |
| 4511 | 4289 | |
| 4512 | 4290 | if (ret && !retval) |
| 4513 | 4291 | retval = ret; |
| @@ -4518,29 +4296,23 @@ static int sctp_setsockopt_event(struct sock *sk, char __user *optval, · 4 unmodified lines | ||
| 4518 | 4296 | } |
| 4519 | 4297 | |
| 4520 | 4298 | static int sctp_setsockopt_asconf_supported(struct sock *sk, |
| 4521 | − char __user *optval, | |
| 4299 | + struct sctp_assoc_value *params, | |
| 4522 | 4300 | unsigned int optlen) |
| 4523 | 4301 | { |
| 4524 | − struct sctp_assoc_value params; | |
| 4525 | 4302 | struct sctp_association *asoc; |
| 4526 | 4303 | struct sctp_endpoint *ep; |
| 4527 | 4304 | int retval = -EINVAL; |
| 4528 | 4305 | |
| 4529 | − if (optlen != sizeof(params)) | |
| 4530 | − goto out; | |
| 4531 | − | |
| 4532 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4533 | − retval = -EFAULT; | |
| 4306 | + if (optlen != sizeof(*params)) | |
| 4534 | 4307 | goto out; |
| 4535 | − } | |
| 4536 | 4308 | |
| 4537 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4538 | − if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && | |
| 4309 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 4310 | + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && | |
| 4539 | 4311 | sctp_style(sk, UDP)) |
| 4540 | 4312 | goto out; |
| 4541 | 4313 | |
| 4542 | 4314 | ep = sctp_sk(sk)->ep; |
| 4543 | − ep->asconf_enable = !!params.assoc_value; | |
| 4315 | + ep->asconf_enable = !!params->assoc_value; | |
| 4544 | 4316 | |
| 4545 | 4317 | if (ep->asconf_enable && ep->auth_enable) { |
| 4546 | 4318 | sctp_auth_ep_add_chunkid(ep, SCTP_CID_ASCONF); |
| @@ -4554,29 +4326,23 @@ out: · 7 unmodified lines | ||
| 4554 | 4326 | } |
| 4555 | 4327 | |
| 4556 | 4328 | static int sctp_setsockopt_auth_supported(struct sock *sk, |
| 4557 | − char __user *optval, | |
| 4329 | + struct sctp_assoc_value *params, | |
| 4558 | 4330 | unsigned int optlen) |
| 4559 | 4331 | { |
| 4560 | − struct sctp_assoc_value params; | |
| 4561 | 4332 | struct sctp_association *asoc; |
| 4562 | 4333 | struct sctp_endpoint *ep; |
| 4563 | 4334 | int retval = -EINVAL; |
| 4564 | 4335 | |
| 4565 | − if (optlen != sizeof(params)) | |
| 4566 | − goto out; | |
| 4567 | − | |
| 4568 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4569 | − retval = -EFAULT; | |
| 4336 | + if (optlen != sizeof(*params)) | |
| 4570 | 4337 | goto out; |
| 4571 | − } | |
| 4572 | 4338 | |
| 4573 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4574 | − if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && | |
| 4339 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 4340 | + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && | |
| 4575 | 4341 | sctp_style(sk, UDP)) |
| 4576 | 4342 | goto out; |
| 4577 | 4343 | |
| 4578 | 4344 | ep = sctp_sk(sk)->ep; |
| 4579 | − if (params.assoc_value) { | |
| 4345 | + if (params->assoc_value) { | |
| 4580 | 4346 | retval = sctp_auth_init(ep, GFP_KERNEL); |
| 4581 | 4347 | if (retval) |
| 4582 | 4348 | goto out; |
| @@ -4586,7 +4352,7 @@ static int sctp_setsockopt_auth_supported(struct sock *sk, · 3 unmodified lines | ||
| 4586 | 4352 | } |
| 4587 | 4353 | } |
| 4588 | 4354 | |
| 4589 | − ep->auth_enable = !!params.assoc_value; | |
| 4355 | + ep->auth_enable = !!params->assoc_value; | |
| 4590 | 4356 | retval = 0; |
| 4591 | 4357 | |
| 4592 | 4358 | out: |
| @@ -4594,27 +4360,21 @@ out: · 1 unmodified line | ||
| 4594 | 4360 | } |
| 4595 | 4361 | |
| 4596 | 4362 | static int sctp_setsockopt_ecn_supported(struct sock *sk, |
| 4597 | − char __user *optval, | |
| 4363 | + struct sctp_assoc_value *params, | |
| 4598 | 4364 | unsigned int optlen) |
| 4599 | 4365 | { |
| 4600 | − struct sctp_assoc_value params; | |
| 4601 | 4366 | struct sctp_association *asoc; |
| 4602 | 4367 | int retval = -EINVAL; |
| 4603 | 4368 | |
| 4604 | − if (optlen != sizeof(params)) | |
| 4369 | + if (optlen != sizeof(*params)) | |
| 4605 | 4370 | goto out; |
| 4606 | 4371 | |
| 4607 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4608 | − retval = -EFAULT; | |
| 4609 | − goto out; | |
| 4610 | − } | |
| 4611 | − | |
| 4612 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4613 | − if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && | |
| 4372 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 4373 | + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && | |
| 4614 | 4374 | sctp_style(sk, UDP)) |
| 4615 | 4375 | goto out; |
| 4616 | 4376 | |
| 4617 | − sctp_sk(sk)->ep->ecn_enable = !!params.assoc_value; | |
| 4377 | + sctp_sk(sk)->ep->ecn_enable = !!params->assoc_value; | |
| 4618 | 4378 | retval = 0; |
| 4619 | 4379 | |
| 4620 | 4380 | out: |
| @@ -4622,33 +4382,27 @@ out: · 1 unmodified line | ||
| 4622 | 4382 | } |
| 4623 | 4383 | |
| 4624 | 4384 | static int sctp_setsockopt_pf_expose(struct sock *sk, |
| 4625 | − char __user *optval, | |
| 4385 | + struct sctp_assoc_value *params, | |
| 4626 | 4386 | unsigned int optlen) |
| 4627 | 4387 | { |
| 4628 | − struct sctp_assoc_value params; | |
| 4629 | 4388 | struct sctp_association *asoc; |
| 4630 | 4389 | int retval = -EINVAL; |
| 4631 | 4390 | |
| 4632 | − if (optlen != sizeof(params)) | |
| 4391 | + if (optlen != sizeof(*params)) | |
| 4633 | 4392 | goto out; |
| 4634 | 4393 | |
| 4635 | − if (copy_from_user(¶ms, optval, optlen)) { | |
| 4636 | − retval = -EFAULT; | |
| 4394 | + if (params->assoc_value > SCTP_PF_EXPOSE_MAX) | |
| 4637 | 4395 | goto out; |
| 4638 | − } | |
| 4639 | 4396 | |
| 4640 | − if (params.assoc_value > SCTP_PF_EXPOSE_MAX) | |
| 4641 | − goto out; | |
| 4642 | − | |
| 4643 | − asoc = sctp_id2assoc(sk, params.assoc_id); | |
| 4644 | − if (!asoc && params.assoc_id != SCTP_FUTURE_ASSOC && | |
| 4397 | + asoc = sctp_id2assoc(sk, params->assoc_id); | |
| 4398 | + if (!asoc && params->assoc_id != SCTP_FUTURE_ASSOC && | |
| 4645 | 4399 | sctp_style(sk, UDP)) |
| 4646 | 4400 | goto out; |
| 4647 | 4401 | |
| 4648 | 4402 | if (asoc) |
| 4649 | − asoc->pf_expose = params.assoc_value; | |
| 4403 | + asoc->pf_expose = params->assoc_value; | |
| 4650 | 4404 | else |
| 4651 | − sctp_sk(sk)->pf_expose = params.assoc_value; | |
| 4405 | + sctp_sk(sk)->pf_expose = params->assoc_value; | |
| 4652 | 4406 | retval = 0; |
| 4653 | 4407 | |
| 4654 | 4408 | out: |
| @@ -4677,6 +4431,7 @@ out: · 22 unmodified lines | ||
| 4677 | 4431 | static int sctp_setsockopt(struct sock *sk, int level, int optname, |
| 4678 | 4432 | char __user *optval, unsigned int optlen) |
| 4679 | 4433 | { |
| 4434 | + void *kopt = NULL; | |
| 4680 | 4435 | int retval = 0; |
| 4681 | 4436 | |
| 4682 | 4437 | pr_debug("%s: sk:%p, optname:%d\n", __func__, sk, optname); |
| @@ -4689,8 +4444,14 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, · 6 unmodified lines | ||
| 4689 | 4444 | */ |
| 4690 | 4445 | if (level != SOL_SCTP) { |
| 4691 | 4446 | struct sctp_af *af = sctp_sk(sk)->pf->af; |
| 4692 | − retval = af->setsockopt(sk, level, optname, optval, optlen); | |
| 4693 | − goto out_nounlock; | |
| 4447 | + | |
| 4448 | + return af->setsockopt(sk, level, optname, optval, optlen); | |
| 4449 | + } | |
| 4450 | + | |
| 4451 | + if (optlen > 0) { | |
| 4452 | + kopt = memdup_user(optval, optlen); | |
| 4453 | + if (IS_ERR(kopt)) | |
| 4454 | + return PTR_ERR(kopt); | |
| 4694 | 4455 | } |
| 4695 | 4456 | |
| 4696 | 4457 | lock_sock(sk); |
| @@ -4698,179 +4459,174 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, · 1 unmodified line | ||
| 4698 | 4459 | switch (optname) { |
| 4699 | 4460 | case SCTP_SOCKOPT_BINDX_ADD: |
| 4700 | 4461 | /* 'optlen' is the size of the addresses buffer. */ |
| 4701 | − retval = sctp_setsockopt_bindx(sk, (struct sockaddr __user *)optval, | |
| 4702 | − optlen, SCTP_BINDX_ADD_ADDR); | |
| 4462 | + retval = sctp_setsockopt_bindx(sk, kopt, optlen, | |
| 4463 | + SCTP_BINDX_ADD_ADDR); | |
| 4703 | 4464 | break; |
| 4704 | 4465 | |
| 4705 | 4466 | case SCTP_SOCKOPT_BINDX_REM: |
| 4706 | 4467 | /* 'optlen' is the size of the addresses buffer. */ |
| 4707 | − retval = sctp_setsockopt_bindx(sk, (struct sockaddr __user *)optval, | |
| 4708 | − optlen, SCTP_BINDX_REM_ADDR); | |
| 4468 | + retval = sctp_setsockopt_bindx(sk, kopt, optlen, | |
| 4469 | + SCTP_BINDX_REM_ADDR); | |
| 4709 | 4470 | break; |
| 4710 | 4471 | |
| 4711 | 4472 | case SCTP_SOCKOPT_CONNECTX_OLD: |
| 4712 | 4473 | /* 'optlen' is the size of the addresses buffer. */ |
| 4713 | − retval = sctp_setsockopt_connectx_old(sk, | |
| 4714 | − (struct sockaddr __user *)optval, | |
| 4715 | − optlen); | |
| 4474 | + retval = sctp_setsockopt_connectx_old(sk, kopt, optlen); | |
| 4716 | 4475 | break; |
| 4717 | 4476 | |
| 4718 | 4477 | case SCTP_SOCKOPT_CONNECTX: |
| 4719 | 4478 | /* 'optlen' is the size of the addresses buffer. */ |
| 4720 | − retval = sctp_setsockopt_connectx(sk, | |
| 4721 | − (struct sockaddr __user *)optval, | |
| 4722 | − optlen); | |
| 4479 | + retval = sctp_setsockopt_connectx(sk, kopt, optlen); | |
| 4723 | 4480 | break; |
| 4724 | 4481 | |
| 4725 | 4482 | case SCTP_DISABLE_FRAGMENTS: |
| 4726 | − retval = sctp_setsockopt_disable_fragments(sk, optval, optlen); | |
| 4483 | + retval = sctp_setsockopt_disable_fragments(sk, kopt, optlen); | |
| 4727 | 4484 | break; |
| 4728 | 4485 | |
| 4729 | 4486 | case SCTP_EVENTS: |
| 4730 | − retval = sctp_setsockopt_events(sk, optval, optlen); | |
| 4487 | + retval = sctp_setsockopt_events(sk, kopt, optlen); | |
| 4731 | 4488 | break; |
| 4732 | 4489 | |
| 4733 | 4490 | case SCTP_AUTOCLOSE: |
| 4734 | − retval = sctp_setsockopt_autoclose(sk, optval, optlen); | |
| 4491 | + retval = sctp_setsockopt_autoclose(sk, kopt, optlen); | |
| 4735 | 4492 | break; |
| 4736 | 4493 | |
| 4737 | 4494 | case SCTP_PEER_ADDR_PARAMS: |
| 4738 | − retval = sctp_setsockopt_peer_addr_params(sk, optval, optlen); | |
| 4495 | + retval = sctp_setsockopt_peer_addr_params(sk, kopt, optlen); | |
| 4739 | 4496 | break; |
| 4740 | 4497 | |
| 4741 | 4498 | case SCTP_DELAYED_SACK: |
| 4742 | − retval = sctp_setsockopt_delayed_ack(sk, optval, optlen); | |
| 4499 | + retval = sctp_setsockopt_delayed_ack(sk, kopt, optlen); | |
| 4743 | 4500 | break; |
| 4744 | 4501 | case SCTP_PARTIAL_DELIVERY_POINT: |
| 4745 | − retval = sctp_setsockopt_partial_delivery_point(sk, optval, optlen); | |
| 4502 | + retval = sctp_setsockopt_partial_delivery_point(sk, kopt, optlen); | |
| 4746 | 4503 | break; |
| 4747 | 4504 | |
| 4748 | 4505 | case SCTP_INITMSG: |
| 4749 | − retval = sctp_setsockopt_initmsg(sk, optval, optlen); | |
| 4506 | + retval = sctp_setsockopt_initmsg(sk, kopt, optlen); | |
| 4750 | 4507 | break; |
| 4751 | 4508 | case SCTP_DEFAULT_SEND_PARAM: |
| 4752 | − retval = sctp_setsockopt_default_send_param(sk, optval, | |
| 4753 | − optlen); | |
| 4509 | + retval = sctp_setsockopt_default_send_param(sk, kopt, optlen); | |
| 4754 | 4510 | break; |
| 4755 | 4511 | case SCTP_DEFAULT_SNDINFO: |
| 4756 | − retval = sctp_setsockopt_default_sndinfo(sk, optval, optlen); | |
| 4512 | + retval = sctp_setsockopt_default_sndinfo(sk, kopt, optlen); | |
| 4757 | 4513 | break; |
| 4758 | 4514 | case SCTP_PRIMARY_ADDR: |
| 4759 | − retval = sctp_setsockopt_primary_addr(sk, optval, optlen); | |
| 4515 | + retval = sctp_setsockopt_primary_addr(sk, kopt, optlen); | |
| 4760 | 4516 | break; |
| 4761 | 4517 | case SCTP_SET_PEER_PRIMARY_ADDR: |
| 4762 | − retval = sctp_setsockopt_peer_primary_addr(sk, optval, optlen); | |
| 4518 | + retval = sctp_setsockopt_peer_primary_addr(sk, kopt, optlen); | |
| 4763 | 4519 | break; |
| 4764 | 4520 | case SCTP_NODELAY: |
| 4765 | − retval = sctp_setsockopt_nodelay(sk, optval, optlen); | |
| 4521 | + retval = sctp_setsockopt_nodelay(sk, kopt, optlen); | |
| 4766 | 4522 | break; |
| 4767 | 4523 | case SCTP_RTOINFO: |
| 4768 | − retval = sctp_setsockopt_rtoinfo(sk, optval, optlen); | |
| 4524 | + retval = sctp_setsockopt_rtoinfo(sk, kopt, optlen); | |
| 4769 | 4525 | break; |
| 4770 | 4526 | case SCTP_ASSOCINFO: |
| 4771 | − retval = sctp_setsockopt_associnfo(sk, optval, optlen); | |
| 4527 | + retval = sctp_setsockopt_associnfo(sk, kopt, optlen); | |
| 4772 | 4528 | break; |
| 4773 | 4529 | case SCTP_I_WANT_MAPPED_V4_ADDR: |
| 4774 | − retval = sctp_setsockopt_mappedv4(sk, optval, optlen); | |
| 4530 | + retval = sctp_setsockopt_mappedv4(sk, kopt, optlen); | |
| 4775 | 4531 | break; |
| 4776 | 4532 | case SCTP_MAXSEG: |
| 4777 | − retval = sctp_setsockopt_maxseg(sk, optval, optlen); | |
| 4533 | + retval = sctp_setsockopt_maxseg(sk, kopt, optlen); | |
| 4778 | 4534 | break; |
| 4779 | 4535 | case SCTP_ADAPTATION_LAYER: |
| 4780 | − retval = sctp_setsockopt_adaptation_layer(sk, optval, optlen); | |
| 4536 | + retval = sctp_setsockopt_adaptation_layer(sk, kopt, optlen); | |
| 4781 | 4537 | break; |
| 4782 | 4538 | case SCTP_CONTEXT: |
| 4783 | − retval = sctp_setsockopt_context(sk, optval, optlen); | |
| 4539 | + retval = sctp_setsockopt_context(sk, kopt, optlen); | |
| 4784 | 4540 | break; |
| 4785 | 4541 | case SCTP_FRAGMENT_INTERLEAVE: |
| 4786 | − retval = sctp_setsockopt_fragment_interleave(sk, optval, optlen); | |
| 4542 | + retval = sctp_setsockopt_fragment_interleave(sk, kopt, optlen); | |
| 4787 | 4543 | break; |
| 4788 | 4544 | case SCTP_MAX_BURST: |
| 4789 | − retval = sctp_setsockopt_maxburst(sk, optval, optlen); | |
| 4545 | + retval = sctp_setsockopt_maxburst(sk, kopt, optlen); | |
| 4790 | 4546 | break; |
| 4791 | 4547 | case SCTP_AUTH_CHUNK: |
| 4792 | − retval = sctp_setsockopt_auth_chunk(sk, optval, optlen); | |
| 4548 | + retval = sctp_setsockopt_auth_chunk(sk, kopt, optlen); | |
| 4793 | 4549 | break; |
| 4794 | 4550 | case SCTP_HMAC_IDENT: |
| 4795 | − retval = sctp_setsockopt_hmac_ident(sk, optval, optlen); | |
| 4551 | + retval = sctp_setsockopt_hmac_ident(sk, kopt, optlen); | |
| 4796 | 4552 | break; |
| 4797 | 4553 | case SCTP_AUTH_KEY: |
| 4798 | − retval = sctp_setsockopt_auth_key(sk, optval, optlen); | |
| 4554 | + retval = sctp_setsockopt_auth_key(sk, kopt, optlen); | |
| 4799 | 4555 | break; |
| 4800 | 4556 | case SCTP_AUTH_ACTIVE_KEY: |
| 4801 | − retval = sctp_setsockopt_active_key(sk, optval, optlen); | |
| 4557 | + retval = sctp_setsockopt_active_key(sk, kopt, optlen); | |
| 4802 | 4558 | break; |
| 4803 | 4559 | case SCTP_AUTH_DELETE_KEY: |
| 4804 | − retval = sctp_setsockopt_del_key(sk, optval, optlen); | |
| 4560 | + retval = sctp_setsockopt_del_key(sk, kopt, optlen); | |
| 4805 | 4561 | break; |
| 4806 | 4562 | case SCTP_AUTH_DEACTIVATE_KEY: |
| 4807 | − retval = sctp_setsockopt_deactivate_key(sk, optval, optlen); | |
| 4563 | + retval = sctp_setsockopt_deactivate_key(sk, kopt, optlen); | |
| 4808 | 4564 | break; |
| 4809 | 4565 | case SCTP_AUTO_ASCONF: |
| 4810 | − retval = sctp_setsockopt_auto_asconf(sk, optval, optlen); | |
| 4566 | + retval = sctp_setsockopt_auto_asconf(sk, kopt, optlen); | |
| 4811 | 4567 | break; |
| 4812 | 4568 | case SCTP_PEER_ADDR_THLDS: |
| 4813 | − retval = sctp_setsockopt_paddr_thresholds(sk, optval, optlen, | |
| 4569 | + retval = sctp_setsockopt_paddr_thresholds(sk, kopt, optlen, | |
| 4814 | 4570 | false); |
| 4815 | 4571 | break; |
| 4816 | 4572 | case SCTP_PEER_ADDR_THLDS_V2: |
| 4817 | − retval = sctp_setsockopt_paddr_thresholds(sk, optval, optlen, | |
| 4573 | + retval = sctp_setsockopt_paddr_thresholds(sk, kopt, optlen, | |
| 4818 | 4574 | true); |
| 4819 | 4575 | break; |
| 4820 | 4576 | case SCTP_RECVRCVINFO: |
| 4821 | − retval = sctp_setsockopt_recvrcvinfo(sk, optval, optlen); | |
| 4577 | + retval = sctp_setsockopt_recvrcvinfo(sk, kopt, optlen); | |
| 4822 | 4578 | break; |
| 4823 | 4579 | case SCTP_RECVNXTINFO: |
| 4824 | − retval = sctp_setsockopt_recvnxtinfo(sk, optval, optlen); | |
| 4580 | + retval = sctp_setsockopt_recvnxtinfo(sk, kopt, optlen); | |
| 4825 | 4581 | break; |
| 4826 | 4582 | case SCTP_PR_SUPPORTED: |
| 4827 | − retval = sctp_setsockopt_pr_supported(sk, optval, optlen); | |
| 4583 | + retval = sctp_setsockopt_pr_supported(sk, kopt, optlen); | |
| 4828 | 4584 | break; |
| 4829 | 4585 | case SCTP_DEFAULT_PRINFO: |
| 4830 | − retval = sctp_setsockopt_default_prinfo(sk, optval, optlen); | |
| 4586 | + retval = sctp_setsockopt_default_prinfo(sk, kopt, optlen); | |
| 4831 | 4587 | break; |
| 4832 | 4588 | case SCTP_RECONFIG_SUPPORTED: |
| 4833 | − retval = sctp_setsockopt_reconfig_supported(sk, optval, optlen); | |
| 4589 | + retval = sctp_setsockopt_reconfig_supported(sk, kopt, optlen); | |
| 4834 | 4590 | break; |
| 4835 | 4591 | case SCTP_ENABLE_STREAM_RESET: |
| 4836 | − retval = sctp_setsockopt_enable_strreset(sk, optval, optlen); | |
| 4592 | + retval = sctp_setsockopt_enable_strreset(sk, kopt, optlen); | |
| 4837 | 4593 | break; |
| 4838 | 4594 | case SCTP_RESET_STREAMS: |
| 4839 | − retval = sctp_setsockopt_reset_streams(sk, optval, optlen); | |
| 4595 | + retval = sctp_setsockopt_reset_streams(sk, kopt, optlen); | |
| 4840 | 4596 | break; |
| 4841 | 4597 | case SCTP_RESET_ASSOC: |
| 4842 | − retval = sctp_setsockopt_reset_assoc(sk, optval, optlen); | |
| 4598 | + retval = sctp_setsockopt_reset_assoc(sk, kopt, optlen); | |
| 4843 | 4599 | break; |
| 4844 | 4600 | case SCTP_ADD_STREAMS: |
| 4845 | − retval = sctp_setsockopt_add_streams(sk, optval, optlen); | |
| 4601 | + retval = sctp_setsockopt_add_streams(sk, kopt, optlen); | |
| 4846 | 4602 | break; |
| 4847 | 4603 | case SCTP_STREAM_SCHEDULER: |
| 4848 | − retval = sctp_setsockopt_scheduler(sk, optval, optlen); | |
| 4604 | + retval = sctp_setsockopt_scheduler(sk, kopt, optlen); | |
| 4849 | 4605 | break; |
| 4850 | 4606 | case SCTP_STREAM_SCHEDULER_VALUE: |
| 4851 | − retval = sctp_setsockopt_scheduler_value(sk, optval, optlen); | |
| 4607 | + retval = sctp_setsockopt_scheduler_value(sk, kopt, optlen); | |
| 4852 | 4608 | break; |
| 4853 | 4609 | case SCTP_INTERLEAVING_SUPPORTED: |
| 4854 | − retval = sctp_setsockopt_interleaving_supported(sk, optval, | |
| 4610 | + retval = sctp_setsockopt_interleaving_supported(sk, kopt, | |
| 4855 | 4611 | optlen); |
| 4856 | 4612 | break; |
| 4857 | 4613 | case SCTP_REUSE_PORT: |
| 4858 | − retval = sctp_setsockopt_reuse_port(sk, optval, optlen); | |
| 4614 | + retval = sctp_setsockopt_reuse_port(sk, kopt, optlen); | |
| 4859 | 4615 | break; |
| 4860 | 4616 | case SCTP_EVENT: |
| 4861 | − retval = sctp_setsockopt_event(sk, optval, optlen); | |
| 4617 | + retval = sctp_setsockopt_event(sk, kopt, optlen); | |
| 4862 | 4618 | break; |
| 4863 | 4619 | case SCTP_ASCONF_SUPPORTED: |
| 4864 | − retval = sctp_setsockopt_asconf_supported(sk, optval, optlen); | |
| 4620 | + retval = sctp_setsockopt_asconf_supported(sk, kopt, optlen); | |
| 4865 | 4621 | break; |
| 4866 | 4622 | case SCTP_AUTH_SUPPORTED: |
| 4867 | − retval = sctp_setsockopt_auth_supported(sk, optval, optlen); | |
| 4623 | + retval = sctp_setsockopt_auth_supported(sk, kopt, optlen); | |
| 4868 | 4624 | break; |
| 4869 | 4625 | case SCTP_ECN_SUPPORTED: |
| 4870 | − retval = sctp_setsockopt_ecn_supported(sk, optval, optlen); | |
| 4626 | + retval = sctp_setsockopt_ecn_supported(sk, kopt, optlen); | |
| 4871 | 4627 | break; |
| 4872 | 4628 | case SCTP_EXPOSE_POTENTIALLY_FAILED_STATE: |
| 4873 | − retval = sctp_setsockopt_pf_expose(sk, optval, optlen); | |
| 4629 | + retval = sctp_setsockopt_pf_expose(sk, kopt, optlen); | |
| 4874 | 4630 | break; |
| 4875 | 4631 | default: |
| 4876 | 4632 | retval = -ENOPROTOOPT; |
| @@ -4878,8 +4634,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, · 1 unmodified line | ||
| 4878 | 4634 | } |
| 4879 | 4635 | |
| 4880 | 4636 | release_sock(sk); |
| 4881 | − | |
| 4882 | −out_nounlock: | |
| 4637 | + kfree(kopt); | |
| 4883 | 4638 | return retval; |
| 4884 | 4639 | } |
| 4885 | 4640 | |