diff options
author | Christoph Hellwig <hch@lst.de> | 2020-07-19 09:21:38 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-07-19 18:26:41 -0700 |
commit | ca84bd058daefef1d184dd0a7b6b43c67339e72c (patch) | |
tree | 6ca326ad931708cfaaf757987fc5dc87fc6c2918 /net/sctp | |
parent | 9aa0dfe1fc9920ad2224b53f9be748c030f0a12e (diff) | |
download | linux-ca84bd058daefef1d184dd0a7b6b43c67339e72c.tar.gz linux-ca84bd058daefef1d184dd0a7b6b43c67339e72c.tar.bz2 linux-ca84bd058daefef1d184dd0a7b6b43c67339e72c.zip |
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: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/socket.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index d57e1a002ffc..af1ebc8313d3 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4677,6 +4677,7 @@ out: static int sctp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, unsigned int optlen) { + void *kopt = NULL; int retval = 0; 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, goto out_nounlock; } + if (optlen > 0) { + kopt = memdup_user(optval, optlen); + if (IS_ERR(kopt)) + return PTR_ERR(kopt); + } + lock_sock(sk); switch (optname) { @@ -4878,6 +4885,7 @@ static int sctp_setsockopt(struct sock *sk, int level, int optname, } release_sock(sk); + kfree(kopt); out_nounlock: return retval; |