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

sctp: copy the optval from user space in sctp_setsockopt

Prepare for for moving the copy_from_user from the individual sockopts
to the main setsockopt helper.  As of this commit the kopt variable
is not used yet, but the following commits will start using it.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9aa0dfe1
...@@ -4677,6 +4677,7 @@ static int sctp_setsockopt_pf_expose(struct sock *sk, ...@@ -4677,6 +4677,7 @@ static int sctp_setsockopt_pf_expose(struct sock *sk,
static int sctp_setsockopt(struct sock *sk, int level, int optname, static int sctp_setsockopt(struct sock *sk, int level, int optname,
char __user *optval, unsigned int optlen) char __user *optval, unsigned int optlen)
{ {
void *kopt = NULL;
int retval = 0; int retval = 0;
pr_debug("%s: sk:%p, optname:%d\n", __func__, sk, optname); pr_debug("%s: sk:%p, optname:%d\n", __func__, sk, optname);
...@@ -4693,6 +4694,12 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4693,6 +4694,12 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
goto out_nounlock; goto out_nounlock;
} }
if (optlen > 0) {
kopt = memdup_user(optval, optlen);
if (IS_ERR(kopt))
return PTR_ERR(kopt);
}
lock_sock(sk); lock_sock(sk);
switch (optname) { switch (optname) {
...@@ -4878,6 +4885,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, ...@@ -4878,6 +4885,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname,
} }
release_sock(sk); release_sock(sk);
kfree(kopt);
out_nounlock: out_nounlock:
return retval; return retval;
......
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