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

sctp: pass a kernel pointer to sctp_setsockopt_delayed_ack

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 9b7b0d1a
...@@ -2751,17 +2751,14 @@ static void sctp_apply_asoc_delayed_ack(struct sctp_sack_info *params, ...@@ -2751,17 +2751,14 @@ static void sctp_apply_asoc_delayed_ack(struct sctp_sack_info *params,
*/ */
static int sctp_setsockopt_delayed_ack(struct sock *sk, static int sctp_setsockopt_delayed_ack(struct sock *sk,
char __user *optval, unsigned int optlen) struct sctp_sack_info *params,
unsigned int optlen)
{ {
struct sctp_sock *sp = sctp_sk(sk); struct sctp_sock *sp = sctp_sk(sk);
struct sctp_association *asoc; struct sctp_association *asoc;
struct sctp_sack_info params;
if (optlen == sizeof(struct sctp_sack_info)) { if (optlen == sizeof(struct sctp_sack_info)) {
if (copy_from_user(&params, optval, optlen)) if (params->sack_delay == 0 && params->sack_freq == 0)
return -EFAULT;
if (params.sack_delay == 0 && params.sack_freq == 0)
return 0; return 0;
} else if (optlen == sizeof(struct sctp_assoc_value)) { } else if (optlen == sizeof(struct sctp_assoc_value)) {
pr_warn_ratelimited(DEPRECATED pr_warn_ratelimited(DEPRECATED
...@@ -2769,59 +2766,57 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk, ...@@ -2769,59 +2766,57 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,
"Use of struct sctp_assoc_value in delayed_ack socket option.\n" "Use of struct sctp_assoc_value in delayed_ack socket option.\n"
"Use struct sctp_sack_info instead\n", "Use struct sctp_sack_info instead\n",
current->comm, task_pid_nr(current)); current->comm, task_pid_nr(current));
if (copy_from_user(&params, optval, optlen))
return -EFAULT;
if (params.sack_delay == 0) if (params->sack_delay == 0)
params.sack_freq = 1; params->sack_freq = 1;
else else
params.sack_freq = 0; params->sack_freq = 0;
} else } else
return -EINVAL; return -EINVAL;
/* Validate value parameter. */ /* Validate value parameter. */
if (params.sack_delay > 500) if (params->sack_delay > 500)
return -EINVAL; return -EINVAL;
/* Get association, if sack_assoc_id != SCTP_FUTURE_ASSOC and the /* Get association, if sack_assoc_id != SCTP_FUTURE_ASSOC and the
* 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.sack_assoc_id); asoc = sctp_id2assoc(sk, params->sack_assoc_id);
if (!asoc && params.sack_assoc_id > SCTP_ALL_ASSOC && if (!asoc && params->sack_assoc_id > SCTP_ALL_ASSOC &&
sctp_style(sk, UDP)) sctp_style(sk, UDP))
return -EINVAL; return -EINVAL;
if (asoc) { if (asoc) {
sctp_apply_asoc_delayed_ack(&params, asoc); sctp_apply_asoc_delayed_ack(params, asoc);
return 0; return 0;
} }
if (sctp_style(sk, TCP)) if (sctp_style(sk, TCP))
params.sack_assoc_id = SCTP_FUTURE_ASSOC; params->sack_assoc_id = SCTP_FUTURE_ASSOC;
if (params.sack_assoc_id == SCTP_FUTURE_ASSOC || if (params->sack_assoc_id == SCTP_FUTURE_ASSOC ||
params.sack_assoc_id == SCTP_ALL_ASSOC) { params->sack_assoc_id == SCTP_ALL_ASSOC) {
if (params.sack_delay) { if (params->sack_delay) {
sp->sackdelay = params.sack_delay; sp->sackdelay = params->sack_delay;
sp->param_flags = sp->param_flags =
sctp_spp_sackdelay_enable(sp->param_flags); sctp_spp_sackdelay_enable(sp->param_flags);
} }
if (params.sack_freq == 1) { if (params->sack_freq == 1) {
sp->param_flags = sp->param_flags =
sctp_spp_sackdelay_disable(sp->param_flags); sctp_spp_sackdelay_disable(sp->param_flags);
} else if (params.sack_freq > 1) { } else if (params->sack_freq > 1) {
sp->sackfreq = params.sack_freq; sp->sackfreq = params->sack_freq;
sp->param_flags = sp->param_flags =
sctp_spp_sackdelay_enable(sp->param_flags); sctp_spp_sackdelay_enable(sp->param_flags);
} }
} }
if (params.sack_assoc_id == SCTP_CURRENT_ASSOC || if (params->sack_assoc_id == SCTP_CURRENT_ASSOC ||
params.sack_assoc_id == SCTP_ALL_ASSOC) params->sack_assoc_id == SCTP_ALL_ASSOC)
list_for_each_entry(asoc, &sp->ep->asocs, asocs) list_for_each_entry(asoc, &sp->ep->asocs, asocs)
sctp_apply_asoc_delayed_ack(&params, asoc); sctp_apply_asoc_delayed_ack(params, asoc);
return 0; return 0;
} }
...@@ -4697,7 +4692,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4697,7 +4692,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
break; break;
case SCTP_DELAYED_SACK: case SCTP_DELAYED_SACK:
retval = sctp_setsockopt_delayed_ack(sk, optval, optlen); retval = sctp_setsockopt_delayed_ack(sk, kopt, optlen);
break; break;
case SCTP_PARTIAL_DELIVERY_POINT: case SCTP_PARTIAL_DELIVERY_POINT:
retval = sctp_setsockopt_partial_delivery_point(sk, optval, optlen); retval = sctp_setsockopt_partial_delivery_point(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