Commit 9b7b0d1a authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David S. Miller

sctp: pass a kernel pointer to sctp_setsockopt_peer_addr_params

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 0b49a65c
...@@ -2589,48 +2589,42 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params, ...@@ -2589,48 +2589,42 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params,
} }
static int sctp_setsockopt_peer_addr_params(struct sock *sk, static int sctp_setsockopt_peer_addr_params(struct sock *sk,
char __user *optval, struct sctp_paddrparams *params,
unsigned int optlen) unsigned int optlen)
{ {
struct sctp_paddrparams params;
struct sctp_transport *trans = NULL; struct sctp_transport *trans = NULL;
struct sctp_association *asoc = NULL; struct sctp_association *asoc = NULL;
struct sctp_sock *sp = sctp_sk(sk); struct sctp_sock *sp = sctp_sk(sk);
int error; int error;
int hb_change, pmtud_change, sackdelay_change; int hb_change, pmtud_change, sackdelay_change;
if (optlen == sizeof(params)) { if (optlen == ALIGN(offsetof(struct sctp_paddrparams,
if (copy_from_user(&params, optval, optlen))
return -EFAULT;
} else if (optlen == ALIGN(offsetof(struct sctp_paddrparams,
spp_ipv6_flowlabel), 4)) { spp_ipv6_flowlabel), 4)) {
if (copy_from_user(&params, optval, optlen)) if (params->spp_flags & (SPP_DSCP | SPP_IPV6_FLOWLABEL))
return -EFAULT;
if (params.spp_flags & (SPP_DSCP | SPP_IPV6_FLOWLABEL))
return -EINVAL; return -EINVAL;
} else { } else if (optlen != sizeof(*params)) {
return -EINVAL; return -EINVAL;
} }
/* Validate flags and value parameters. */ /* Validate flags and value parameters. */
hb_change = params.spp_flags & SPP_HB; hb_change = params->spp_flags & SPP_HB;
pmtud_change = params.spp_flags & SPP_PMTUD; pmtud_change = params->spp_flags & SPP_PMTUD;
sackdelay_change = params.spp_flags & SPP_SACKDELAY; sackdelay_change = params->spp_flags & SPP_SACKDELAY;
if (hb_change == SPP_HB || if (hb_change == SPP_HB ||
pmtud_change == SPP_PMTUD || pmtud_change == SPP_PMTUD ||
sackdelay_change == SPP_SACKDELAY || sackdelay_change == SPP_SACKDELAY ||
params.spp_sackdelay > 500 || params->spp_sackdelay > 500 ||
(params.spp_pathmtu && (params->spp_pathmtu &&
params.spp_pathmtu < SCTP_DEFAULT_MINSEGMENT)) params->spp_pathmtu < SCTP_DEFAULT_MINSEGMENT))
return -EINVAL; return -EINVAL;
/* If an address other than INADDR_ANY is specified, and /* If an address other than INADDR_ANY is specified, and
* no transport is found, then the request is invalid. * no transport is found, then the request is invalid.
*/ */
if (!sctp_is_any(sk, (union sctp_addr *)&params.spp_address)) { if (!sctp_is_any(sk, (union sctp_addr *)&params->spp_address)) {
trans = sctp_addr_id2transport(sk, &params.spp_address, trans = sctp_addr_id2transport(sk, &params->spp_address,
params.spp_assoc_id); params->spp_assoc_id);
if (!trans) if (!trans)
return -EINVAL; return -EINVAL;
} }
...@@ -2639,19 +2633,19 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, ...@@ -2639,19 +2633,19 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
* socket is a one to many style socket, and an association * socket is a one to many style socket, and an association
* was not found, then the id was invalid. * was not found, then the id was invalid.
*/ */
asoc = sctp_id2assoc(sk, params.spp_assoc_id); asoc = sctp_id2assoc(sk, params->spp_assoc_id);
if (!asoc && params.spp_assoc_id != SCTP_FUTURE_ASSOC && if (!asoc && params->spp_assoc_id != SCTP_FUTURE_ASSOC &&
sctp_style(sk, UDP)) sctp_style(sk, UDP))
return -EINVAL; return -EINVAL;
/* Heartbeat demand can only be sent on a transport or /* Heartbeat demand can only be sent on a transport or
* association, but not a socket. * association, but not a socket.
*/ */
if (params.spp_flags & SPP_HB_DEMAND && !trans && !asoc) if (params->spp_flags & SPP_HB_DEMAND && !trans && !asoc)
return -EINVAL; return -EINVAL;
/* Process parameters. */ /* Process parameters. */
error = sctp_apply_peer_addr_params(&params, trans, asoc, sp, error = sctp_apply_peer_addr_params(params, trans, asoc, sp,
hb_change, pmtud_change, hb_change, pmtud_change,
sackdelay_change); sackdelay_change);
...@@ -2664,7 +2658,7 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk, ...@@ -2664,7 +2658,7 @@ static int sctp_setsockopt_peer_addr_params(struct sock *sk,
if (!trans && asoc) { if (!trans && asoc) {
list_for_each_entry(trans, &asoc->peer.transport_addr_list, list_for_each_entry(trans, &asoc->peer.transport_addr_list,
transports) { transports) {
sctp_apply_peer_addr_params(&params, trans, asoc, sp, sctp_apply_peer_addr_params(params, trans, asoc, sp,
hb_change, pmtud_change, hb_change, pmtud_change,
sackdelay_change); sackdelay_change);
} }
...@@ -4699,7 +4693,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4699,7 +4693,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
break; break;
case SCTP_PEER_ADDR_PARAMS: case SCTP_PEER_ADDR_PARAMS:
retval = sctp_setsockopt_peer_addr_params(sk, optval, optlen); retval = sctp_setsockopt_peer_addr_params(sk, kopt, optlen);
break; break;
case SCTP_DELAYED_SACK: case SCTP_DELAYED_SACK:
......
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