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

sctp: pass a kernel pointer to sctp_setsockopt_maxburst

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 1031cea0
...@@ -3482,12 +3482,13 @@ static int sctp_setsockopt_partial_delivery_point(struct sock *sk, u32 *val, ...@@ -3482,12 +3482,13 @@ static int sctp_setsockopt_partial_delivery_point(struct sock *sk, u32 *val,
* future associations inheriting the socket value. * future associations inheriting the socket value.
*/ */
static int sctp_setsockopt_maxburst(struct sock *sk, static int sctp_setsockopt_maxburst(struct sock *sk,
char __user *optval, struct sctp_assoc_value *params,
unsigned int optlen) unsigned int optlen)
{ {
struct sctp_sock *sp = sctp_sk(sk); struct sctp_sock *sp = sctp_sk(sk);
struct sctp_assoc_value params;
struct sctp_association *asoc; struct sctp_association *asoc;
sctp_assoc_t assoc_id;
u32 assoc_value;
if (optlen == sizeof(int)) { if (optlen == sizeof(int)) {
pr_warn_ratelimited(DEPRECATED pr_warn_ratelimited(DEPRECATED
...@@ -3495,37 +3496,33 @@ static int sctp_setsockopt_maxburst(struct sock *sk, ...@@ -3495,37 +3496,33 @@ static int sctp_setsockopt_maxburst(struct sock *sk,
"Use of int in max_burst socket option deprecated.\n" "Use of int in max_burst socket option deprecated.\n"
"Use struct sctp_assoc_value instead\n", "Use struct sctp_assoc_value instead\n",
current->comm, task_pid_nr(current)); current->comm, task_pid_nr(current));
if (copy_from_user(&params.assoc_value, optval, optlen)) assoc_id = SCTP_FUTURE_ASSOC;
return -EFAULT; assoc_value = *((int *)params);
params.assoc_id = SCTP_FUTURE_ASSOC;
} else if (optlen == sizeof(struct sctp_assoc_value)) { } else if (optlen == sizeof(struct sctp_assoc_value)) {
if (copy_from_user(&params, optval, optlen)) assoc_id = params->assoc_id;
return -EFAULT; assoc_value = params->assoc_value;
} else } else
return -EINVAL; return -EINVAL;
asoc = sctp_id2assoc(sk, params.assoc_id); asoc = sctp_id2assoc(sk, assoc_id);
if (!asoc && params.assoc_id > SCTP_ALL_ASSOC && if (!asoc && assoc_id > SCTP_ALL_ASSOC && sctp_style(sk, UDP))
sctp_style(sk, UDP))
return -EINVAL; return -EINVAL;
if (asoc) { if (asoc) {
asoc->max_burst = params.assoc_value; asoc->max_burst = assoc_value;
return 0; return 0;
} }
if (sctp_style(sk, TCP)) if (sctp_style(sk, TCP))
params.assoc_id = SCTP_FUTURE_ASSOC; assoc_id = SCTP_FUTURE_ASSOC;
if (params.assoc_id == SCTP_FUTURE_ASSOC || if (assoc_id == SCTP_FUTURE_ASSOC || assoc_id == SCTP_ALL_ASSOC)
params.assoc_id == SCTP_ALL_ASSOC) sp->max_burst = assoc_value;
sp->max_burst = params.assoc_value;
if (params.assoc_id == SCTP_CURRENT_ASSOC || if (assoc_id == SCTP_CURRENT_ASSOC || assoc_id == SCTP_ALL_ASSOC)
params.assoc_id == SCTP_ALL_ASSOC)
list_for_each_entry(asoc, &sp->ep->asocs, asocs) list_for_each_entry(asoc, &sp->ep->asocs, asocs)
asoc->max_burst = params.assoc_value; asoc->max_burst = assoc_value;
return 0; return 0;
} }
...@@ -4699,7 +4696,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4699,7 +4696,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_fragment_interleave(sk, kopt, optlen); retval = sctp_setsockopt_fragment_interleave(sk, kopt, optlen);
break; break;
case SCTP_MAX_BURST: case SCTP_MAX_BURST:
retval = sctp_setsockopt_maxburst(sk, optval, optlen); retval = sctp_setsockopt_maxburst(sk, kopt, optlen);
break; break;
case SCTP_AUTH_CHUNK: case SCTP_AUTH_CHUNK:
retval = sctp_setsockopt_auth_chunk(sk, optval, optlen); retval = sctp_setsockopt_auth_chunk(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