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

sctp: pass a kernel pointer to sctp_setsockopt_default_send_param

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 9dfa6f04
...@@ -2867,57 +2867,54 @@ static int sctp_setsockopt_initmsg(struct sock *sk, struct sctp_initmsg *sinit, ...@@ -2867,57 +2867,54 @@ static int sctp_setsockopt_initmsg(struct sock *sk, struct sctp_initmsg *sinit,
* to this call if the caller is using the UDP model. * to this call if the caller is using the UDP model.
*/ */
static int sctp_setsockopt_default_send_param(struct sock *sk, static int sctp_setsockopt_default_send_param(struct sock *sk,
char __user *optval, struct sctp_sndrcvinfo *info,
unsigned int optlen) 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_sndrcvinfo info;
if (optlen != sizeof(info)) if (optlen != sizeof(*info))
return -EINVAL; return -EINVAL;
if (copy_from_user(&info, optval, optlen)) if (info->sinfo_flags &
return -EFAULT;
if (info.sinfo_flags &
~(SCTP_UNORDERED | SCTP_ADDR_OVER | ~(SCTP_UNORDERED | SCTP_ADDR_OVER |
SCTP_ABORT | SCTP_EOF)) SCTP_ABORT | SCTP_EOF))
return -EINVAL; return -EINVAL;
asoc = sctp_id2assoc(sk, info.sinfo_assoc_id); asoc = sctp_id2assoc(sk, info->sinfo_assoc_id);
if (!asoc && info.sinfo_assoc_id > SCTP_ALL_ASSOC && if (!asoc && info->sinfo_assoc_id > SCTP_ALL_ASSOC &&
sctp_style(sk, UDP)) sctp_style(sk, UDP))
return -EINVAL; return -EINVAL;
if (asoc) { if (asoc) {
asoc->default_stream = info.sinfo_stream; asoc->default_stream = info->sinfo_stream;
asoc->default_flags = info.sinfo_flags; asoc->default_flags = info->sinfo_flags;
asoc->default_ppid = info.sinfo_ppid; asoc->default_ppid = info->sinfo_ppid;
asoc->default_context = info.sinfo_context; asoc->default_context = info->sinfo_context;
asoc->default_timetolive = info.sinfo_timetolive; asoc->default_timetolive = info->sinfo_timetolive;
return 0; return 0;
} }
if (sctp_style(sk, TCP)) if (sctp_style(sk, TCP))
info.sinfo_assoc_id = SCTP_FUTURE_ASSOC; info->sinfo_assoc_id = SCTP_FUTURE_ASSOC;
if (info.sinfo_assoc_id == SCTP_FUTURE_ASSOC || if (info->sinfo_assoc_id == SCTP_FUTURE_ASSOC ||
info.sinfo_assoc_id == SCTP_ALL_ASSOC) { info->sinfo_assoc_id == SCTP_ALL_ASSOC) {
sp->default_stream = info.sinfo_stream; sp->default_stream = info->sinfo_stream;
sp->default_flags = info.sinfo_flags; sp->default_flags = info->sinfo_flags;
sp->default_ppid = info.sinfo_ppid; sp->default_ppid = info->sinfo_ppid;
sp->default_context = info.sinfo_context; sp->default_context = info->sinfo_context;
sp->default_timetolive = info.sinfo_timetolive; sp->default_timetolive = info->sinfo_timetolive;
} }
if (info.sinfo_assoc_id == SCTP_CURRENT_ASSOC || if (info->sinfo_assoc_id == SCTP_CURRENT_ASSOC ||
info.sinfo_assoc_id == SCTP_ALL_ASSOC) { info->sinfo_assoc_id == SCTP_ALL_ASSOC) {
list_for_each_entry(asoc, &sp->ep->asocs, asocs) { list_for_each_entry(asoc, &sp->ep->asocs, asocs) {
asoc->default_stream = info.sinfo_stream; asoc->default_stream = info->sinfo_stream;
asoc->default_flags = info.sinfo_flags; asoc->default_flags = info->sinfo_flags;
asoc->default_ppid = info.sinfo_ppid; asoc->default_ppid = info->sinfo_ppid;
asoc->default_context = info.sinfo_context; asoc->default_context = info->sinfo_context;
asoc->default_timetolive = info.sinfo_timetolive; asoc->default_timetolive = info->sinfo_timetolive;
} }
} }
...@@ -4695,8 +4692,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4695,8 +4692,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_initmsg(sk, kopt, optlen); retval = sctp_setsockopt_initmsg(sk, kopt, optlen);
break; break;
case SCTP_DEFAULT_SEND_PARAM: case SCTP_DEFAULT_SEND_PARAM:
retval = sctp_setsockopt_default_send_param(sk, optval, retval = sctp_setsockopt_default_send_param(sk, kopt, optlen);
optlen);
break; break;
case SCTP_DEFAULT_SNDINFO: case SCTP_DEFAULT_SNDINFO:
retval = sctp_setsockopt_default_sndinfo(sk, optval, optlen); retval = sctp_setsockopt_default_sndinfo(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