]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - crypto/af_alg.c
crypto: af_alg - Allow arbitrarily long algorithm names
[mirror_ubuntu-bionic-kernel.git] / crypto / af_alg.c
index f5e18c2a48527bb3f5bbdc5202b37577689710b3..3556d8eb54a740741fcb282d6c39f5d942ea79f5 100644 (file)
@@ -160,11 +160,11 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        if (sock->state == SS_CONNECTED)
                return -EINVAL;
 
-       if (addr_len != sizeof(*sa))
+       if (addr_len < sizeof(*sa))
                return -EINVAL;
 
        sa->salg_type[sizeof(sa->salg_type) - 1] = 0;
-       sa->salg_name[sizeof(sa->salg_name) - 1] = 0;
+       sa->salg_name[sizeof(sa->salg_name) + addr_len - sizeof(*sa) - 1] = 0;
 
        type = alg_get_type(sa->salg_type);
        if (IS_ERR(type) && PTR_ERR(type) == -ENOENT) {
@@ -266,7 +266,7 @@ unlock:
        return err;
 }
 
-int af_alg_accept(struct sock *sk, struct socket *newsock)
+int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
 {
        struct alg_sock *ask = alg_sk(sk);
        const struct af_alg_type *type;
@@ -281,7 +281,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock)
        if (!type)
                goto unlock;
 
-       sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, 0);
+       sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, kern);
        err = -ENOMEM;
        if (!sk2)
                goto unlock;
@@ -323,9 +323,10 @@ unlock:
 }
 EXPORT_SYMBOL_GPL(af_alg_accept);
 
-static int alg_accept(struct socket *sock, struct socket *newsock, int flags)
+static int alg_accept(struct socket *sock, struct socket *newsock, int flags,
+                     bool kern)
 {
-       return af_alg_accept(sock->sk, newsock);
+       return af_alg_accept(sock->sk, newsock, kern);
 }
 
 static const struct proto_ops alg_proto_ops = {