summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2020-07-24 15:41:54 -0700
committerDavid S. Miller <davem@davemloft.net>2020-07-24 15:41:54 -0700
commited29545e2ddcc133a532ec7965716f111ceb65e0 (patch)
treeea30acf3bfac3bf9a0bbb4841bf8a0593749b080
parent765b02ea6391fbba7fc0d0c7c91febb65f0cd170 (diff)
parent9353c6d2a3cc04d370d62b6f1304b496c16d7fbd (diff)
downloadlinux-crypto-ed29545e2ddcc133a532ec7965716f111ceb65e0.tar.gz
linux-crypto-ed29545e2ddcc133a532ec7965716f111ceb65e0.zip
Merge branch 'get-rid-of-the-address_space-override-in-setsockopt-v2'
Christoph Hellwig says: ==================== get rid of the address_space override in setsockopt v2 setsockopt is the last place in architecture-independ code that still uses set_fs to force the uaccess routines to operate on kernel pointers. This series adds a new sockptr_t type that can contained either a kernel or user pointer, and which has accessors that do the right thing, and then uses it for setsockopt, starting by refactoring some low-level helpers and moving them over to it before finally doing the main setsockopt method. Note that apparently the eBPF selftests do not even cover this path, so the series has been tested with a testing patch that always copies the data first and passes a kernel pointer. This is something that works for most common sockopts (and is something that the ePBF support relies on), but unfortunately in various corner cases we either don't use the passed in length, or in one case actually copy data back from setsockopt, or in case of bpfilter straight out do not work with kernel pointers at all. Against net-next/master. Changes since v1: - check that users don't pass in kernel addresses - more bpfilter cleanups - cosmetic mptcp tweak ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--crypto/af_alg.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 29f71428..892242a4 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -197,8 +197,7 @@ unlock:
return err;
}
-static int alg_setkey(struct sock *sk, char __user *ukey,
- unsigned int keylen)
+static int alg_setkey(struct sock *sk, sockptr_t ukey, unsigned int keylen)
{
struct alg_sock *ask = alg_sk(sk);
const struct af_alg_type *type = ask->type;
@@ -210,7 +209,7 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
return -ENOMEM;
err = -EFAULT;
- if (copy_from_user(key, ukey, keylen))
+ if (copy_from_sockptr(key, ukey, keylen))
goto out;
err = type->setkey(ask->private, key, keylen);
@@ -222,7 +221,7 @@ out:
}
static int alg_setsockopt(struct socket *sock, int level, int optname,
- char __user *optval, unsigned int optlen)
+ sockptr_t optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
struct alg_sock *ask = alg_sk(sk);