]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - crypto/af_alg.c
crypto: x86/salsa20 - remove x86 salsa20 implementations
[mirror_ubuntu-bionic-kernel.git] / crypto / af_alg.c
index 35d4dcea381fbee7aa312667aa235456bb9d7918..ef2064d560a6a78ac89f38ca81234445f0e567fe 100644 (file)
@@ -150,7 +150,7 @@ EXPORT_SYMBOL_GPL(af_alg_release_parent);
 
 static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 {
-       const u32 forbidden = CRYPTO_ALG_INTERNAL;
+       const u32 allowed = CRYPTO_ALG_KERN_DRIVER_ONLY;
        struct sock *sk = sock->sk;
        struct alg_sock *ask = alg_sk(sk);
        struct sockaddr_alg *sa = (void *)uaddr;
@@ -164,6 +164,10 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        if (addr_len < sizeof(*sa))
                return -EINVAL;
 
+       /* If caller uses non-allowed flag, return error. */
+       if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed))
+               return -EINVAL;
+
        sa->salg_type[sizeof(sa->salg_type) - 1] = 0;
        sa->salg_name[sizeof(sa->salg_name) + addr_len - sizeof(*sa) - 1] = 0;
 
@@ -176,9 +180,7 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        if (IS_ERR(type))
                return PTR_ERR(type);
 
-       private = type->bind(sa->salg_name,
-                            sa->salg_feat & ~forbidden,
-                            sa->salg_mask & ~forbidden);
+       private = type->bind(sa->salg_name, sa->salg_feat, sa->salg_mask);
        if (IS_ERR(private)) {
                module_put(type->owner);
                return PTR_ERR(private);