sctp: pass a kernel pointer to sctp_setsockopt_default_sndinfo
Use the kernel pointer that sctp_setsockopt has available instead of directly handling the user pointer. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c23ad6d2b7
commit
8a2409d356
@ -2925,54 +2925,51 @@ static int sctp_setsockopt_default_send_param(struct sock *sk,
|
|||||||
* (SCTP_DEFAULT_SNDINFO)
|
* (SCTP_DEFAULT_SNDINFO)
|
||||||
*/
|
*/
|
||||||
static int sctp_setsockopt_default_sndinfo(struct sock *sk,
|
static int sctp_setsockopt_default_sndinfo(struct sock *sk,
|
||||||
char __user *optval,
|
struct sctp_sndinfo *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_sndinfo info;
|
|
||||||
|
|
||||||
if (optlen != sizeof(info))
|
if (optlen != sizeof(*info))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (copy_from_user(&info, optval, optlen))
|
if (info->snd_flags &
|
||||||
return -EFAULT;
|
|
||||||
if (info.snd_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.snd_assoc_id);
|
asoc = sctp_id2assoc(sk, info->snd_assoc_id);
|
||||||
if (!asoc && info.snd_assoc_id > SCTP_ALL_ASSOC &&
|
if (!asoc && info->snd_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.snd_sid;
|
asoc->default_stream = info->snd_sid;
|
||||||
asoc->default_flags = info.snd_flags;
|
asoc->default_flags = info->snd_flags;
|
||||||
asoc->default_ppid = info.snd_ppid;
|
asoc->default_ppid = info->snd_ppid;
|
||||||
asoc->default_context = info.snd_context;
|
asoc->default_context = info->snd_context;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sctp_style(sk, TCP))
|
if (sctp_style(sk, TCP))
|
||||||
info.snd_assoc_id = SCTP_FUTURE_ASSOC;
|
info->snd_assoc_id = SCTP_FUTURE_ASSOC;
|
||||||
|
|
||||||
if (info.snd_assoc_id == SCTP_FUTURE_ASSOC ||
|
if (info->snd_assoc_id == SCTP_FUTURE_ASSOC ||
|
||||||
info.snd_assoc_id == SCTP_ALL_ASSOC) {
|
info->snd_assoc_id == SCTP_ALL_ASSOC) {
|
||||||
sp->default_stream = info.snd_sid;
|
sp->default_stream = info->snd_sid;
|
||||||
sp->default_flags = info.snd_flags;
|
sp->default_flags = info->snd_flags;
|
||||||
sp->default_ppid = info.snd_ppid;
|
sp->default_ppid = info->snd_ppid;
|
||||||
sp->default_context = info.snd_context;
|
sp->default_context = info->snd_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.snd_assoc_id == SCTP_CURRENT_ASSOC ||
|
if (info->snd_assoc_id == SCTP_CURRENT_ASSOC ||
|
||||||
info.snd_assoc_id == SCTP_ALL_ASSOC) {
|
info->snd_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.snd_sid;
|
asoc->default_stream = info->snd_sid;
|
||||||
asoc->default_flags = info.snd_flags;
|
asoc->default_flags = info->snd_flags;
|
||||||
asoc->default_ppid = info.snd_ppid;
|
asoc->default_ppid = info->snd_ppid;
|
||||||
asoc->default_context = info.snd_context;
|
asoc->default_context = info->snd_context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4695,7 +4692,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
|
|||||||
retval = sctp_setsockopt_default_send_param(sk, kopt, optlen);
|
retval = sctp_setsockopt_default_send_param(sk, kopt, 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, 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, optval, optlen);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user