Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[sfrench/cifs-2.6.git] / crypto / af_alg.c
index 8be8bec07cdd2c7a14f9a65bde64b4ed0b992e94..d11db80d24cd14a46b424885e9e6bcfd1299c58c 100644 (file)
@@ -254,6 +254,14 @@ static int alg_setsockopt(struct socket *sock, int level, int optname,
                if (!type->setauthsize)
                        goto unlock;
                err = type->setauthsize(ask->private, optlen);
+               break;
+       case ALG_SET_DRBG_ENTROPY:
+               if (sock->state == SS_CONNECTED)
+                       goto unlock;
+               if (!type->setentropy)
+                       goto unlock;
+
+               err = type->setentropy(ask->private, optval, optlen);
        }
 
 unlock:
@@ -286,6 +294,11 @@ int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
        security_sock_graft(sk2, newsock);
        security_sk_clone(sk, sk2);
 
+       /*
+        * newsock->ops assigned here to allow type->accept call to override
+        * them when required.
+        */
+       newsock->ops = type->ops;
        err = type->accept(ask->private, sk2);
 
        nokey = err == -ENOKEY;
@@ -304,7 +317,6 @@ int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
        alg_sk(sk2)->parent = sk;
        alg_sk(sk2)->type = type;
 
-       newsock->ops = type->ops;
        newsock->state = SS_CONNECTED;
 
        if (nokey)