Commit 1eec6958 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

sctp: pass a kernel pointer to sctp_setsockopt_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 8a2409d3
...@@ -2982,10 +2982,9 @@ static int sctp_setsockopt_default_sndinfo(struct sock *sk, ...@@ -2982,10 +2982,9 @@ static int sctp_setsockopt_default_sndinfo(struct sock *sk,
* the association primary. The enclosed address must be one of the * the association primary. The enclosed address must be one of the
* association peer's addresses. * association peer's addresses.
*/ */
static int sctp_setsockopt_primary_addr(struct sock *sk, char __user *optval, static int sctp_setsockopt_primary_addr(struct sock *sk, struct sctp_prim *prim,
unsigned int optlen) unsigned int optlen)
{ {
struct sctp_prim prim;
struct sctp_transport *trans; struct sctp_transport *trans;
struct sctp_af *af; struct sctp_af *af;
int err; int err;
...@@ -2993,21 +2992,18 @@ static int sctp_setsockopt_primary_addr(struct sock *sk, char __user *optval, ...@@ -2993,21 +2992,18 @@ static int sctp_setsockopt_primary_addr(struct sock *sk, char __user *optval,
if (optlen != sizeof(struct sctp_prim)) if (optlen != sizeof(struct sctp_prim))
return -EINVAL; return -EINVAL;
if (copy_from_user(&prim, optval, sizeof(struct sctp_prim)))
return -EFAULT;
/* Allow security module to validate address but need address len. */ /* Allow security module to validate address but need address len. */
af = sctp_get_af_specific(prim.ssp_addr.ss_family); af = sctp_get_af_specific(prim->ssp_addr.ss_family);
if (!af) if (!af)
return -EINVAL; return -EINVAL;
err = security_sctp_bind_connect(sk, SCTP_PRIMARY_ADDR, err = security_sctp_bind_connect(sk, SCTP_PRIMARY_ADDR,
(struct sockaddr *)&prim.ssp_addr, (struct sockaddr *)&prim->ssp_addr,
af->sockaddr_len); af->sockaddr_len);
if (err) if (err)
return err; return err;
trans = sctp_addr_id2transport(sk, &prim.ssp_addr, prim.ssp_assoc_id); trans = sctp_addr_id2transport(sk, &prim->ssp_addr, prim->ssp_assoc_id);
if (!trans) if (!trans)
return -EINVAL; return -EINVAL;
...@@ -4695,7 +4691,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4695,7 +4691,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_default_sndinfo(sk, kopt, optlen); retval = sctp_setsockopt_default_sndinfo(sk, kopt, optlen);
break; break;
case SCTP_PRIMARY_ADDR: case SCTP_PRIMARY_ADDR:
retval = sctp_setsockopt_primary_addr(sk, optval, 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, 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