Commit 5b864c8d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

sctp: pass a kernel pointer to sctp_setsockopt_associnfo

Use the kernel pointer that sctp_setsockopt has available instead of
directly handling the user pointer.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent af5ae60e
...@@ -3105,26 +3105,25 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, ...@@ -3105,26 +3105,25 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk,
* See [SCTP] for more information. * See [SCTP] for more information.
* *
*/ */
static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsigned int optlen) static int sctp_setsockopt_associnfo(struct sock *sk,
struct sctp_assocparams *assocparams,
unsigned int optlen)
{ {
struct sctp_assocparams assocparams;
struct sctp_association *asoc; struct sctp_association *asoc;
if (optlen != sizeof(struct sctp_assocparams)) if (optlen != sizeof(struct sctp_assocparams))
return -EINVAL; return -EINVAL;
if (copy_from_user(&assocparams, optval, optlen))
return -EFAULT;
asoc = sctp_id2assoc(sk, assocparams.sasoc_assoc_id); asoc = sctp_id2assoc(sk, assocparams->sasoc_assoc_id);
if (!asoc && assocparams.sasoc_assoc_id != SCTP_FUTURE_ASSOC && if (!asoc && assocparams->sasoc_assoc_id != SCTP_FUTURE_ASSOC &&
sctp_style(sk, UDP)) sctp_style(sk, UDP))
return -EINVAL; return -EINVAL;
/* Set the values to the specific association */ /* Set the values to the specific association */
if (asoc) { if (asoc) {
if (assocparams.sasoc_asocmaxrxt != 0) { if (assocparams->sasoc_asocmaxrxt != 0) {
__u32 path_sum = 0; __u32 path_sum = 0;
int paths = 0; int paths = 0;
struct sctp_transport *peer_addr; struct sctp_transport *peer_addr;
...@@ -3141,24 +3140,25 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsig ...@@ -3141,24 +3140,25 @@ static int sctp_setsockopt_associnfo(struct sock *sk, char __user *optval, unsig
* then one path. * then one path.
*/ */
if (paths > 1 && if (paths > 1 &&
assocparams.sasoc_asocmaxrxt > path_sum) assocparams->sasoc_asocmaxrxt > path_sum)
return -EINVAL; return -EINVAL;
asoc->max_retrans = assocparams.sasoc_asocmaxrxt; asoc->max_retrans = assocparams->sasoc_asocmaxrxt;
} }
if (assocparams.sasoc_cookie_life != 0) if (assocparams->sasoc_cookie_life != 0)
asoc->cookie_life = ms_to_ktime(assocparams.sasoc_cookie_life); asoc->cookie_life =
ms_to_ktime(assocparams->sasoc_cookie_life);
} else { } else {
/* Set the values to the endpoint */ /* Set the values to the endpoint */
struct sctp_sock *sp = sctp_sk(sk); struct sctp_sock *sp = sctp_sk(sk);
if (assocparams.sasoc_asocmaxrxt != 0) if (assocparams->sasoc_asocmaxrxt != 0)
sp->assocparams.sasoc_asocmaxrxt = sp->assocparams.sasoc_asocmaxrxt =
assocparams.sasoc_asocmaxrxt; assocparams->sasoc_asocmaxrxt;
if (assocparams.sasoc_cookie_life != 0) if (assocparams->sasoc_cookie_life != 0)
sp->assocparams.sasoc_cookie_life = sp->assocparams.sasoc_cookie_life =
assocparams.sasoc_cookie_life; assocparams->sasoc_cookie_life;
} }
return 0; return 0;
} }
...@@ -4693,7 +4693,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4693,7 +4693,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_rtoinfo(sk, kopt, optlen); retval = sctp_setsockopt_rtoinfo(sk, kopt, optlen);
break; break;
case SCTP_ASSOCINFO: case SCTP_ASSOCINFO:
retval = sctp_setsockopt_associnfo(sk, optval, optlen); retval = sctp_setsockopt_associnfo(sk, kopt, optlen);
break; break;
case SCTP_I_WANT_MAPPED_V4_ADDR: case SCTP_I_WANT_MAPPED_V4_ADDR:
retval = sctp_setsockopt_mappedv4(sk, optval, optlen); retval = sctp_setsockopt_mappedv4(sk, optval, optlen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment