diff options
-rw-r--r-- | net/sctp/socket.c | 73 |
1 files changed, 60 insertions, 13 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 939892691a26..d994d822900d 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -2933,17 +2933,39 @@ static int sctp_setsockopt_maxburst(struct sock *sk, | |||
2933 | char __user *optval, | 2933 | char __user *optval, |
2934 | int optlen) | 2934 | int optlen) |
2935 | { | 2935 | { |
2936 | struct sctp_assoc_value params; | ||
2937 | struct sctp_sock *sp; | ||
2938 | struct sctp_association *asoc; | ||
2936 | int val; | 2939 | int val; |
2940 | int assoc_id = 0; | ||
2937 | 2941 | ||
2938 | if (optlen != sizeof(int)) | 2942 | if (optlen < sizeof(int)) |
2939 | return -EINVAL; | 2943 | return -EINVAL; |
2940 | if (get_user(val, (int __user *)optval)) | ||
2941 | return -EFAULT; | ||
2942 | 2944 | ||
2943 | if (val < 0) | 2945 | if (optlen == sizeof(int)) { |
2946 | printk(KERN_WARNING | ||
2947 | "SCTP: Use of int in max_burst socket option deprecated\n"); | ||
2948 | printk(KERN_WARNING | ||
2949 | "SCTP: Use struct sctp_assoc_value instead\n"); | ||
2950 | if (copy_from_user(&val, optval, optlen)) | ||
2951 | return -EFAULT; | ||
2952 | } else if (optlen == sizeof(struct sctp_assoc_value)) { | ||
2953 | if (copy_from_user(¶ms, optval, optlen)) | ||
2954 | return -EFAULT; | ||
2955 | val = params.assoc_value; | ||
2956 | assoc_id = params.assoc_id; | ||
2957 | } else | ||
2944 | return -EINVAL; | 2958 | return -EINVAL; |
2945 | 2959 | ||
2946 | sctp_sk(sk)->max_burst = val; | 2960 | sp = sctp_sk(sk); |
2961 | |||
2962 | if (assoc_id != 0) { | ||
2963 | asoc = sctp_id2assoc(sk, assoc_id); | ||
2964 | if (!asoc) | ||
2965 | return -EINVAL; | ||
2966 | asoc->max_burst = val; | ||
2967 | } else | ||
2968 | sp->max_burst = val; | ||
2947 | 2969 | ||
2948 | return 0; | 2970 | return 0; |
2949 | } | 2971 | } |
@@ -5005,20 +5027,45 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len, | |||
5005 | char __user *optval, | 5027 | char __user *optval, |
5006 | int __user *optlen) | 5028 | int __user *optlen) |
5007 | { | 5029 | { |
5008 | int val; | 5030 | struct sctp_assoc_value params; |
5031 | struct sctp_sock *sp; | ||
5032 | struct sctp_association *asoc; | ||
5009 | 5033 | ||
5010 | if (len < sizeof(int)) | 5034 | if (len < sizeof(int)) |
5011 | return -EINVAL; | 5035 | return -EINVAL; |
5012 | 5036 | ||
5013 | len = sizeof(int); | 5037 | if (len == sizeof(int)) { |
5038 | printk(KERN_WARNING | ||
5039 | "SCTP: Use of int in max_burst socket option deprecated\n"); | ||
5040 | printk(KERN_WARNING | ||
5041 | "SCTP: Use struct sctp_assoc_value instead\n"); | ||
5042 | params.assoc_id = 0; | ||
5043 | } else if (len == sizeof (struct sctp_assoc_value)) { | ||
5044 | if (copy_from_user(¶ms, optval, len)) | ||
5045 | return -EFAULT; | ||
5046 | } else | ||
5047 | return -EINVAL; | ||
5014 | 5048 | ||
5015 | val = sctp_sk(sk)->max_burst; | 5049 | sp = sctp_sk(sk); |
5016 | if (put_user(len, optlen)) | 5050 | |
5017 | return -EFAULT; | 5051 | if (params.assoc_id != 0) { |
5018 | if (copy_to_user(optval, &val, len)) | 5052 | asoc = sctp_id2assoc(sk, params.assoc_id); |
5019 | return -EFAULT; | 5053 | if (!asoc) |
5054 | return -EINVAL; | ||
5055 | params.assoc_value = asoc->max_burst; | ||
5056 | } else | ||
5057 | params.assoc_value = sp->max_burst; | ||
5058 | |||
5059 | if (len == sizeof(int)) { | ||
5060 | if (copy_to_user(optval, ¶ms.assoc_value, len)) | ||
5061 | return -EFAULT; | ||
5062 | } else { | ||
5063 | if (copy_to_user(optval, ¶ms, len)) | ||
5064 | return -EFAULT; | ||
5065 | } | ||
5066 | |||
5067 | return 0; | ||
5020 | 5068 | ||
5021 | return -ENOTSUPP; | ||
5022 | } | 5069 | } |
5023 | 5070 | ||
5024 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, | 5071 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, |