Commit 46a0ae9d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

sctp: pass a kernel pointer to sctp_setsockopt_peer_primary_addr

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 1eec6958
...@@ -3284,12 +3284,12 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned ...@@ -3284,12 +3284,12 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
* locally bound addresses. The following structure is used to make a * locally bound addresses. The following structure is used to make a
* set primary request: * set primary request:
*/ */
static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval, static int sctp_setsockopt_peer_primary_addr(struct sock *sk,
struct sctp_setpeerprim *prim,
unsigned int optlen) unsigned int optlen)
{ {
struct sctp_sock *sp; struct sctp_sock *sp;
struct sctp_association *asoc = NULL; struct sctp_association *asoc = NULL;
struct sctp_setpeerprim prim;
struct sctp_chunk *chunk; struct sctp_chunk *chunk;
struct sctp_af *af; struct sctp_af *af;
int err; int err;
...@@ -3302,10 +3302,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva ...@@ -3302,10 +3302,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
if (optlen != sizeof(struct sctp_setpeerprim)) if (optlen != sizeof(struct sctp_setpeerprim))
return -EINVAL; return -EINVAL;
if (copy_from_user(&prim, optval, optlen)) asoc = sctp_id2assoc(sk, prim->sspp_assoc_id);
return -EFAULT;
asoc = sctp_id2assoc(sk, prim.sspp_assoc_id);
if (!asoc) if (!asoc)
return -EINVAL; return -EINVAL;
...@@ -3318,26 +3315,26 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva ...@@ -3318,26 +3315,26 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva
if (!sctp_state(asoc, ESTABLISHED)) if (!sctp_state(asoc, ESTABLISHED))
return -ENOTCONN; return -ENOTCONN;
af = sctp_get_af_specific(prim.sspp_addr.ss_family); af = sctp_get_af_specific(prim->sspp_addr.ss_family);
if (!af) if (!af)
return -EINVAL; return -EINVAL;
if (!af->addr_valid((union sctp_addr *)&prim.sspp_addr, sp, NULL)) if (!af->addr_valid((union sctp_addr *)&prim->sspp_addr, sp, NULL))
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim.sspp_addr)) if (!sctp_assoc_lookup_laddr(asoc, (union sctp_addr *)&prim->sspp_addr))
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
/* Allow security module to validate address. */ /* Allow security module to validate address. */
err = security_sctp_bind_connect(sk, SCTP_SET_PEER_PRIMARY_ADDR, err = security_sctp_bind_connect(sk, SCTP_SET_PEER_PRIMARY_ADDR,
(struct sockaddr *)&prim.sspp_addr, (struct sockaddr *)&prim->sspp_addr,
af->sockaddr_len); af->sockaddr_len);
if (err) if (err)
return err; return err;
/* Create an ASCONF chunk with SET_PRIMARY parameter */ /* Create an ASCONF chunk with SET_PRIMARY parameter */
chunk = sctp_make_asconf_set_prim(asoc, chunk = sctp_make_asconf_set_prim(asoc,
(union sctp_addr *)&prim.sspp_addr); (union sctp_addr *)&prim->sspp_addr);
if (!chunk) if (!chunk)
return -ENOMEM; return -ENOMEM;
...@@ -4694,7 +4691,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4694,7 +4691,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_primary_addr(sk, kopt, optlen); retval = sctp_setsockopt_primary_addr(sk, kopt, optlen);
break; break;
case SCTP_SET_PEER_PRIMARY_ADDR: case SCTP_SET_PEER_PRIMARY_ADDR:
retval = sctp_setsockopt_peer_primary_addr(sk, optval, optlen); retval = sctp_setsockopt_peer_primary_addr(sk, kopt, optlen);
break; break;
case SCTP_NODELAY: case SCTP_NODELAY:
retval = sctp_setsockopt_nodelay(sk, optval, optlen); retval = sctp_setsockopt_nodelay(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