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

sctp: pass a kernel pointer to sctp_setsockopt_hmac_ident

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 88266d31
...@@ -3565,13 +3565,11 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, ...@@ -3565,13 +3565,11 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk,
* endpoint requires the peer to use. * endpoint requires the peer to use.
*/ */
static int sctp_setsockopt_hmac_ident(struct sock *sk, static int sctp_setsockopt_hmac_ident(struct sock *sk,
char __user *optval, struct sctp_hmacalgo *hmacs,
unsigned int optlen) unsigned int optlen)
{ {
struct sctp_endpoint *ep = sctp_sk(sk)->ep; struct sctp_endpoint *ep = sctp_sk(sk)->ep;
struct sctp_hmacalgo *hmacs;
u32 idents; u32 idents;
int err;
if (!ep->auth_enable) if (!ep->auth_enable)
return -EACCES; return -EACCES;
...@@ -3581,21 +3579,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, ...@@ -3581,21 +3579,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk,
optlen = min_t(unsigned int, optlen, sizeof(struct sctp_hmacalgo) + optlen = min_t(unsigned int, optlen, sizeof(struct sctp_hmacalgo) +
SCTP_AUTH_NUM_HMACS * sizeof(u16)); SCTP_AUTH_NUM_HMACS * sizeof(u16));
hmacs = memdup_user(optval, optlen);
if (IS_ERR(hmacs))
return PTR_ERR(hmacs);
idents = hmacs->shmac_num_idents; idents = hmacs->shmac_num_idents;
if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS ||
(idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo))) { (idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo)))
err = -EINVAL; return -EINVAL;
goto out;
}
err = sctp_auth_ep_set_hmacs(ep, hmacs); return sctp_auth_ep_set_hmacs(ep, hmacs);
out:
kfree(hmacs);
return err;
} }
/* /*
...@@ -4699,7 +4688,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4699,7 +4688,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
retval = sctp_setsockopt_auth_chunk(sk, kopt, optlen); retval = sctp_setsockopt_auth_chunk(sk, kopt, optlen);
break; break;
case SCTP_HMAC_IDENT: case SCTP_HMAC_IDENT:
retval = sctp_setsockopt_hmac_ident(sk, optval, optlen); retval = sctp_setsockopt_hmac_ident(sk, kopt, optlen);
break; break;
case SCTP_AUTH_KEY: case SCTP_AUTH_KEY:
retval = sctp_setsockopt_auth_key(sk, optval, optlen); retval = sctp_setsockopt_auth_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