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

sctp: pass a kernel pointer to sctp_setsockopt_auto_asconf

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 76b3d0c4
...@@ -3807,26 +3807,23 @@ static int sctp_setsockopt_deactivate_key(struct sock *sk, ...@@ -3807,26 +3807,23 @@ static int sctp_setsockopt_deactivate_key(struct sock *sk,
* Note. In this implementation, socket operation overrides default parameter * Note. In this implementation, socket operation overrides default parameter
* being set by sysctl as well as FreeBSD implementation * being set by sysctl as well as FreeBSD implementation
*/ */
static int sctp_setsockopt_auto_asconf(struct sock *sk, char __user *optval, static int sctp_setsockopt_auto_asconf(struct sock *sk, int *val,
unsigned int optlen) unsigned int optlen)
{ {
int val;
struct sctp_sock *sp = sctp_sk(sk); struct sctp_sock *sp = sctp_sk(sk);
if (optlen < sizeof(int)) if (optlen < sizeof(int))
return -EINVAL; return -EINVAL;
if (get_user(val, (int __user *)optval)) if (!sctp_is_ep_boundall(sk) && *val)
return -EFAULT;
if (!sctp_is_ep_boundall(sk) && val)
return -EINVAL; return -EINVAL;
if ((val && sp->do_auto_asconf) || (!val && !sp->do_auto_asconf)) if ((*val && sp->do_auto_asconf) || (!*val && !sp->do_auto_asconf))
return 0; return 0;
spin_lock_bh(&sock_net(sk)->sctp.addr_wq_lock); spin_lock_bh(&sock_net(sk)->sctp.addr_wq_lock);
if (val == 0 && sp->do_auto_asconf) { if (*val == 0 && sp->do_auto_asconf) {
list_del(&sp->auto_asconf_list); list_del(&sp->auto_asconf_list);
sp->do_auto_asconf = 0; sp->do_auto_asconf = 0;
} else if (val && !sp->do_auto_asconf) { } else if (*val && !sp->do_auto_asconf) {
list_add_tail(&sp->auto_asconf_list, list_add_tail(&sp->auto_asconf_list,
&sock_net(sk)->sctp.auto_asconf_splist); &sock_net(sk)->sctp.auto_asconf_splist);
sp->do_auto_asconf = 1; sp->do_auto_asconf = 1;
...@@ -4690,7 +4687,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4690,7 +4687,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_deactivate_key(sk, kopt, optlen); retval = sctp_setsockopt_deactivate_key(sk, kopt, optlen);
break; break;
case SCTP_AUTO_ASCONF: case SCTP_AUTO_ASCONF:
retval = sctp_setsockopt_auto_asconf(sk, optval, optlen); retval = sctp_setsockopt_auto_asconf(sk, kopt, optlen);
break; break;
case SCTP_PEER_ADDR_THLDS: case SCTP_PEER_ADDR_THLDS:
retval = sctp_setsockopt_paddr_thresholds(sk, optval, optlen, retval = sctp_setsockopt_paddr_thresholds(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