diff options
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r-- | net/sctp/socket.c | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 6140471efd4b..9874e60c9b0d 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -999,7 +999,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, | |||
999 | if (unlikely(addrs_size <= 0)) | 999 | if (unlikely(addrs_size <= 0)) |
1000 | return -EINVAL; | 1000 | return -EINVAL; |
1001 | 1001 | ||
1002 | kaddrs = vmemdup_user(addrs, addrs_size); | 1002 | kaddrs = memdup_user(addrs, addrs_size); |
1003 | if (unlikely(IS_ERR(kaddrs))) | 1003 | if (unlikely(IS_ERR(kaddrs))) |
1004 | return PTR_ERR(kaddrs); | 1004 | return PTR_ERR(kaddrs); |
1005 | 1005 | ||
@@ -1007,7 +1007,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, | |||
1007 | addr_buf = kaddrs; | 1007 | addr_buf = kaddrs; |
1008 | while (walk_size < addrs_size) { | 1008 | while (walk_size < addrs_size) { |
1009 | if (walk_size + sizeof(sa_family_t) > addrs_size) { | 1009 | if (walk_size + sizeof(sa_family_t) > addrs_size) { |
1010 | kvfree(kaddrs); | 1010 | kfree(kaddrs); |
1011 | return -EINVAL; | 1011 | return -EINVAL; |
1012 | } | 1012 | } |
1013 | 1013 | ||
@@ -1018,7 +1018,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, | |||
1018 | * causes the address buffer to overflow return EINVAL. | 1018 | * causes the address buffer to overflow return EINVAL. |
1019 | */ | 1019 | */ |
1020 | if (!af || (walk_size + af->sockaddr_len) > addrs_size) { | 1020 | if (!af || (walk_size + af->sockaddr_len) > addrs_size) { |
1021 | kvfree(kaddrs); | 1021 | kfree(kaddrs); |
1022 | return -EINVAL; | 1022 | return -EINVAL; |
1023 | } | 1023 | } |
1024 | addrcnt++; | 1024 | addrcnt++; |
@@ -1054,7 +1054,7 @@ static int sctp_setsockopt_bindx(struct sock *sk, | |||
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | out: | 1056 | out: |
1057 | kvfree(kaddrs); | 1057 | kfree(kaddrs); |
1058 | 1058 | ||
1059 | return err; | 1059 | return err; |
1060 | } | 1060 | } |
@@ -1329,7 +1329,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk, | |||
1329 | if (unlikely(addrs_size <= 0)) | 1329 | if (unlikely(addrs_size <= 0)) |
1330 | return -EINVAL; | 1330 | return -EINVAL; |
1331 | 1331 | ||
1332 | kaddrs = vmemdup_user(addrs, addrs_size); | 1332 | kaddrs = memdup_user(addrs, addrs_size); |
1333 | if (unlikely(IS_ERR(kaddrs))) | 1333 | if (unlikely(IS_ERR(kaddrs))) |
1334 | return PTR_ERR(kaddrs); | 1334 | return PTR_ERR(kaddrs); |
1335 | 1335 | ||
@@ -1349,7 +1349,7 @@ static int __sctp_setsockopt_connectx(struct sock *sk, | |||
1349 | err = __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id); | 1349 | err = __sctp_connect(sk, kaddrs, addrs_size, flags, assoc_id); |
1350 | 1350 | ||
1351 | out_free: | 1351 | out_free: |
1352 | kvfree(kaddrs); | 1352 | kfree(kaddrs); |
1353 | 1353 | ||
1354 | return err; | 1354 | return err; |
1355 | } | 1355 | } |
@@ -2920,6 +2920,9 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk, | |||
2920 | return 0; | 2920 | return 0; |
2921 | } | 2921 | } |
2922 | 2922 | ||
2923 | if (sctp_style(sk, TCP)) | ||
2924 | params.sack_assoc_id = SCTP_FUTURE_ASSOC; | ||
2925 | |||
2923 | if (params.sack_assoc_id == SCTP_FUTURE_ASSOC || | 2926 | if (params.sack_assoc_id == SCTP_FUTURE_ASSOC || |
2924 | params.sack_assoc_id == SCTP_ALL_ASSOC) { | 2927 | params.sack_assoc_id == SCTP_ALL_ASSOC) { |
2925 | if (params.sack_delay) { | 2928 | if (params.sack_delay) { |
@@ -3024,6 +3027,9 @@ static int sctp_setsockopt_default_send_param(struct sock *sk, | |||
3024 | return 0; | 3027 | return 0; |
3025 | } | 3028 | } |
3026 | 3029 | ||
3030 | if (sctp_style(sk, TCP)) | ||
3031 | info.sinfo_assoc_id = SCTP_FUTURE_ASSOC; | ||
3032 | |||
3027 | if (info.sinfo_assoc_id == SCTP_FUTURE_ASSOC || | 3033 | if (info.sinfo_assoc_id == SCTP_FUTURE_ASSOC || |
3028 | info.sinfo_assoc_id == SCTP_ALL_ASSOC) { | 3034 | info.sinfo_assoc_id == SCTP_ALL_ASSOC) { |
3029 | sp->default_stream = info.sinfo_stream; | 3035 | sp->default_stream = info.sinfo_stream; |
@@ -3081,6 +3087,9 @@ static int sctp_setsockopt_default_sndinfo(struct sock *sk, | |||
3081 | return 0; | 3087 | return 0; |
3082 | } | 3088 | } |
3083 | 3089 | ||
3090 | if (sctp_style(sk, TCP)) | ||
3091 | info.snd_assoc_id = SCTP_FUTURE_ASSOC; | ||
3092 | |||
3084 | if (info.snd_assoc_id == SCTP_FUTURE_ASSOC || | 3093 | if (info.snd_assoc_id == SCTP_FUTURE_ASSOC || |
3085 | info.snd_assoc_id == SCTP_ALL_ASSOC) { | 3094 | info.snd_assoc_id == SCTP_ALL_ASSOC) { |
3086 | sp->default_stream = info.snd_sid; | 3095 | sp->default_stream = info.snd_sid; |
@@ -3531,6 +3540,9 @@ static int sctp_setsockopt_context(struct sock *sk, char __user *optval, | |||
3531 | return 0; | 3540 | return 0; |
3532 | } | 3541 | } |
3533 | 3542 | ||
3543 | if (sctp_style(sk, TCP)) | ||
3544 | params.assoc_id = SCTP_FUTURE_ASSOC; | ||
3545 | |||
3534 | if (params.assoc_id == SCTP_FUTURE_ASSOC || | 3546 | if (params.assoc_id == SCTP_FUTURE_ASSOC || |
3535 | params.assoc_id == SCTP_ALL_ASSOC) | 3547 | params.assoc_id == SCTP_ALL_ASSOC) |
3536 | sp->default_rcv_context = params.assoc_value; | 3548 | sp->default_rcv_context = params.assoc_value; |
@@ -3670,6 +3682,9 @@ static int sctp_setsockopt_maxburst(struct sock *sk, | |||
3670 | return 0; | 3682 | return 0; |
3671 | } | 3683 | } |
3672 | 3684 | ||
3685 | if (sctp_style(sk, TCP)) | ||
3686 | params.assoc_id = SCTP_FUTURE_ASSOC; | ||
3687 | |||
3673 | if (params.assoc_id == SCTP_FUTURE_ASSOC || | 3688 | if (params.assoc_id == SCTP_FUTURE_ASSOC || |
3674 | params.assoc_id == SCTP_ALL_ASSOC) | 3689 | params.assoc_id == SCTP_ALL_ASSOC) |
3675 | sp->max_burst = params.assoc_value; | 3690 | sp->max_burst = params.assoc_value; |
@@ -3798,6 +3813,9 @@ static int sctp_setsockopt_auth_key(struct sock *sk, | |||
3798 | goto out; | 3813 | goto out; |
3799 | } | 3814 | } |
3800 | 3815 | ||
3816 | if (sctp_style(sk, TCP)) | ||
3817 | authkey->sca_assoc_id = SCTP_FUTURE_ASSOC; | ||
3818 | |||
3801 | if (authkey->sca_assoc_id == SCTP_FUTURE_ASSOC || | 3819 | if (authkey->sca_assoc_id == SCTP_FUTURE_ASSOC || |
3802 | authkey->sca_assoc_id == SCTP_ALL_ASSOC) { | 3820 | authkey->sca_assoc_id == SCTP_ALL_ASSOC) { |
3803 | ret = sctp_auth_set_key(ep, asoc, authkey); | 3821 | ret = sctp_auth_set_key(ep, asoc, authkey); |
@@ -3853,6 +3871,9 @@ static int sctp_setsockopt_active_key(struct sock *sk, | |||
3853 | if (asoc) | 3871 | if (asoc) |
3854 | return sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); | 3872 | return sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); |
3855 | 3873 | ||
3874 | if (sctp_style(sk, TCP)) | ||
3875 | val.scact_assoc_id = SCTP_FUTURE_ASSOC; | ||
3876 | |||
3856 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | 3877 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || |
3857 | val.scact_assoc_id == SCTP_ALL_ASSOC) { | 3878 | val.scact_assoc_id == SCTP_ALL_ASSOC) { |
3858 | ret = sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); | 3879 | ret = sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); |
@@ -3904,6 +3925,9 @@ static int sctp_setsockopt_del_key(struct sock *sk, | |||
3904 | if (asoc) | 3925 | if (asoc) |
3905 | return sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); | 3926 | return sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); |
3906 | 3927 | ||
3928 | if (sctp_style(sk, TCP)) | ||
3929 | val.scact_assoc_id = SCTP_FUTURE_ASSOC; | ||
3930 | |||
3907 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | 3931 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || |
3908 | val.scact_assoc_id == SCTP_ALL_ASSOC) { | 3932 | val.scact_assoc_id == SCTP_ALL_ASSOC) { |
3909 | ret = sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); | 3933 | ret = sctp_auth_del_key_id(ep, asoc, val.scact_keynumber); |
@@ -3954,6 +3978,9 @@ static int sctp_setsockopt_deactivate_key(struct sock *sk, char __user *optval, | |||
3954 | if (asoc) | 3978 | if (asoc) |
3955 | return sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); | 3979 | return sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); |
3956 | 3980 | ||
3981 | if (sctp_style(sk, TCP)) | ||
3982 | val.scact_assoc_id = SCTP_FUTURE_ASSOC; | ||
3983 | |||
3957 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || | 3984 | if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || |
3958 | val.scact_assoc_id == SCTP_ALL_ASSOC) { | 3985 | val.scact_assoc_id == SCTP_ALL_ASSOC) { |
3959 | ret = sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); | 3986 | ret = sctp_auth_deact_key_id(ep, asoc, val.scact_keynumber); |
@@ -4169,6 +4196,9 @@ static int sctp_setsockopt_default_prinfo(struct sock *sk, | |||
4169 | goto out; | 4196 | goto out; |
4170 | } | 4197 | } |
4171 | 4198 | ||
4199 | if (sctp_style(sk, TCP)) | ||
4200 | info.pr_assoc_id = SCTP_FUTURE_ASSOC; | ||
4201 | |||
4172 | if (info.pr_assoc_id == SCTP_FUTURE_ASSOC || | 4202 | if (info.pr_assoc_id == SCTP_FUTURE_ASSOC || |
4173 | info.pr_assoc_id == SCTP_ALL_ASSOC) { | 4203 | info.pr_assoc_id == SCTP_ALL_ASSOC) { |
4174 | SCTP_PR_SET_POLICY(sp->default_flags, info.pr_policy); | 4204 | SCTP_PR_SET_POLICY(sp->default_flags, info.pr_policy); |
@@ -4251,6 +4281,9 @@ static int sctp_setsockopt_enable_strreset(struct sock *sk, | |||
4251 | goto out; | 4281 | goto out; |
4252 | } | 4282 | } |
4253 | 4283 | ||
4284 | if (sctp_style(sk, TCP)) | ||
4285 | params.assoc_id = SCTP_FUTURE_ASSOC; | ||
4286 | |||
4254 | if (params.assoc_id == SCTP_FUTURE_ASSOC || | 4287 | if (params.assoc_id == SCTP_FUTURE_ASSOC || |
4255 | params.assoc_id == SCTP_ALL_ASSOC) | 4288 | params.assoc_id == SCTP_ALL_ASSOC) |
4256 | ep->strreset_enable = params.assoc_value; | 4289 | ep->strreset_enable = params.assoc_value; |
@@ -4376,6 +4409,9 @@ static int sctp_setsockopt_scheduler(struct sock *sk, | |||
4376 | if (asoc) | 4409 | if (asoc) |
4377 | return sctp_sched_set_sched(asoc, params.assoc_value); | 4410 | return sctp_sched_set_sched(asoc, params.assoc_value); |
4378 | 4411 | ||
4412 | if (sctp_style(sk, TCP)) | ||
4413 | params.assoc_id = SCTP_FUTURE_ASSOC; | ||
4414 | |||
4379 | if (params.assoc_id == SCTP_FUTURE_ASSOC || | 4415 | if (params.assoc_id == SCTP_FUTURE_ASSOC || |
4380 | params.assoc_id == SCTP_ALL_ASSOC) | 4416 | params.assoc_id == SCTP_ALL_ASSOC) |
4381 | sp->default_ss = params.assoc_value; | 4417 | sp->default_ss = params.assoc_value; |
@@ -4541,6 +4577,9 @@ static int sctp_setsockopt_event(struct sock *sk, char __user *optval, | |||
4541 | if (asoc) | 4577 | if (asoc) |
4542 | return sctp_assoc_ulpevent_type_set(¶m, asoc); | 4578 | return sctp_assoc_ulpevent_type_set(¶m, asoc); |
4543 | 4579 | ||
4580 | if (sctp_style(sk, TCP)) | ||
4581 | param.se_assoc_id = SCTP_FUTURE_ASSOC; | ||
4582 | |||
4544 | if (param.se_assoc_id == SCTP_FUTURE_ASSOC || | 4583 | if (param.se_assoc_id == SCTP_FUTURE_ASSOC || |
4545 | param.se_assoc_id == SCTP_ALL_ASSOC) | 4584 | param.se_assoc_id == SCTP_ALL_ASSOC) |
4546 | sctp_ulpevent_type_set(&sp->subscribe, | 4585 | sctp_ulpevent_type_set(&sp->subscribe, |
@@ -9169,7 +9208,7 @@ static inline void sctp_copy_descendant(struct sock *sk_to, | |||
9169 | { | 9208 | { |
9170 | int ancestor_size = sizeof(struct inet_sock) + | 9209 | int ancestor_size = sizeof(struct inet_sock) + |
9171 | sizeof(struct sctp_sock) - | 9210 | sizeof(struct sctp_sock) - |
9172 | offsetof(struct sctp_sock, auto_asconf_list); | 9211 | offsetof(struct sctp_sock, pd_lobby); |
9173 | 9212 | ||
9174 | if (sk_from->sk_family == PF_INET6) | 9213 | if (sk_from->sk_family == PF_INET6) |
9175 | ancestor_size += sizeof(struct ipv6_pinfo); | 9214 | ancestor_size += sizeof(struct ipv6_pinfo); |
@@ -9253,7 +9292,6 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk, | |||
9253 | * 2) Peeling off partial delivery; keep pd_lobby in new pd_lobby. | 9292 | * 2) Peeling off partial delivery; keep pd_lobby in new pd_lobby. |
9254 | * 3) Peeling off non-partial delivery; move pd_lobby to receive_queue. | 9293 | * 3) Peeling off non-partial delivery; move pd_lobby to receive_queue. |
9255 | */ | 9294 | */ |
9256 | skb_queue_head_init(&newsp->pd_lobby); | ||
9257 | atomic_set(&sctp_sk(newsk)->pd_mode, assoc->ulpq.pd_mode); | 9295 | atomic_set(&sctp_sk(newsk)->pd_mode, assoc->ulpq.pd_mode); |
9258 | 9296 | ||
9259 | if (atomic_read(&sctp_sk(oldsk)->pd_mode)) { | 9297 | if (atomic_read(&sctp_sk(oldsk)->pd_mode)) { |