diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/sctp/socket.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index deb82e35a107..5c9980ae36bb 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -3215,14 +3215,9 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, | |||
3215 | if (optlen < sizeof(struct sctp_hmacalgo)) | 3215 | if (optlen < sizeof(struct sctp_hmacalgo)) |
3216 | return -EINVAL; | 3216 | return -EINVAL; |
3217 | 3217 | ||
3218 | hmacs = kmalloc(optlen, GFP_KERNEL); | 3218 | hmacs= memdup_user(optval, optlen); |
3219 | if (!hmacs) | 3219 | if (IS_ERR(hmacs)) |
3220 | return -ENOMEM; | 3220 | return PTR_ERR(hmacs); |
3221 | |||
3222 | if (copy_from_user(hmacs, optval, optlen)) { | ||
3223 | err = -EFAULT; | ||
3224 | goto out; | ||
3225 | } | ||
3226 | 3221 | ||
3227 | idents = hmacs->shmac_num_idents; | 3222 | idents = hmacs->shmac_num_idents; |
3228 | if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || | 3223 | if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || |
@@ -3257,14 +3252,9 @@ static int sctp_setsockopt_auth_key(struct sock *sk, | |||
3257 | if (optlen <= sizeof(struct sctp_authkey)) | 3252 | if (optlen <= sizeof(struct sctp_authkey)) |
3258 | return -EINVAL; | 3253 | return -EINVAL; |
3259 | 3254 | ||
3260 | authkey = kmalloc(optlen, GFP_KERNEL); | 3255 | authkey= memdup_user(optval, optlen); |
3261 | if (!authkey) | 3256 | if (IS_ERR(authkey)) |
3262 | return -ENOMEM; | 3257 | return PTR_ERR(authkey); |
3263 | |||
3264 | if (copy_from_user(authkey, optval, optlen)) { | ||
3265 | ret = -EFAULT; | ||
3266 | goto out; | ||
3267 | } | ||
3268 | 3258 | ||
3269 | if (authkey->sca_keylength > optlen - sizeof(struct sctp_authkey)) { | 3259 | if (authkey->sca_keylength > optlen - sizeof(struct sctp_authkey)) { |
3270 | ret = -EINVAL; | 3260 | ret = -EINVAL; |