aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorShan Wei <shanwei@cn.fujitsu.com>2011-04-18 15:13:18 -0400
committerDavid S. Miller <davem@davemloft.net>2011-04-20 00:45:20 -0400
commit934253a7b4ab4151037ea9532552628723a14442 (patch)
tree34958bbe96f709ff06c7e9ea77d44b96da3986d7 /net/sctp/socket.c
parent66009927f1e7374afdc6f9fdd25c493ee4eadf7c (diff)
sctp: use memdup_user to copy data from userspace
Use common function to simply code. Signed-off-by: Shan Wei <shanwei@cn.fujitsu.com> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c22
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;