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

sctp: pass a kernel pointer to sctp_setsockopt_active_key

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 534d13d0
...@@ -3655,42 +3655,39 @@ static int sctp_setsockopt_auth_key(struct sock *sk, ...@@ -3655,42 +3655,39 @@ static int sctp_setsockopt_auth_key(struct sock *sk,
* the association shared key. * the association shared key.
*/ */
static int sctp_setsockopt_active_key(struct sock *sk, static int sctp_setsockopt_active_key(struct sock *sk,
char __user *optval, struct sctp_authkeyid *val,
unsigned int optlen) unsigned int optlen)
{ {
struct sctp_endpoint *ep = sctp_sk(sk)->ep; struct sctp_endpoint *ep = sctp_sk(sk)->ep;
struct sctp_association *asoc; struct sctp_association *asoc;
struct sctp_authkeyid val;
int ret = 0; int ret = 0;
if (optlen != sizeof(struct sctp_authkeyid)) if (optlen != sizeof(struct sctp_authkeyid))
return -EINVAL; return -EINVAL;
if (copy_from_user(&val, optval, optlen))
return -EFAULT;
asoc = sctp_id2assoc(sk, val.scact_assoc_id); asoc = sctp_id2assoc(sk, val->scact_assoc_id);
if (!asoc && val.scact_assoc_id > SCTP_ALL_ASSOC && if (!asoc && val->scact_assoc_id > SCTP_ALL_ASSOC &&
sctp_style(sk, UDP)) sctp_style(sk, UDP))
return -EINVAL; return -EINVAL;
if (asoc) if (asoc)
return sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); return sctp_auth_set_active_key(ep, asoc, val->scact_keynumber);
if (sctp_style(sk, TCP)) if (sctp_style(sk, TCP))
val.scact_assoc_id = SCTP_FUTURE_ASSOC; val->scact_assoc_id = SCTP_FUTURE_ASSOC;
if (val.scact_assoc_id == SCTP_FUTURE_ASSOC || if (val->scact_assoc_id == SCTP_FUTURE_ASSOC ||
val.scact_assoc_id == SCTP_ALL_ASSOC) { val->scact_assoc_id == SCTP_ALL_ASSOC) {
ret = sctp_auth_set_active_key(ep, asoc, val.scact_keynumber); ret = sctp_auth_set_active_key(ep, asoc, val->scact_keynumber);
if (ret) if (ret)
return ret; return ret;
} }
if (val.scact_assoc_id == SCTP_CURRENT_ASSOC || if (val->scact_assoc_id == SCTP_CURRENT_ASSOC ||
val.scact_assoc_id == SCTP_ALL_ASSOC) { val->scact_assoc_id == SCTP_ALL_ASSOC) {
list_for_each_entry(asoc, &ep->asocs, asocs) { list_for_each_entry(asoc, &ep->asocs, asocs) {
int res = sctp_auth_set_active_key(ep, asoc, int res = sctp_auth_set_active_key(ep, asoc,
val.scact_keynumber); val->scact_keynumber);
if (res && !ret) if (res && !ret)
ret = res; ret = res;
...@@ -4689,7 +4686,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4689,7 +4686,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_auth_key(sk, kopt, optlen); retval = sctp_setsockopt_auth_key(sk, kopt, optlen);
break; break;
case SCTP_AUTH_ACTIVE_KEY: case SCTP_AUTH_ACTIVE_KEY:
retval = sctp_setsockopt_active_key(sk, optval, optlen); retval = sctp_setsockopt_active_key(sk, kopt, optlen);
break; break;
case SCTP_AUTH_DELETE_KEY: case SCTP_AUTH_DELETE_KEY:
retval = sctp_setsockopt_del_key(sk, optval, optlen); retval = sctp_setsockopt_del_key(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