nbd: handle unexpected replies better
[linux-2.6-microblaze.git] / crypto / algapi.c
index 2a0271b..c0755cf 100644 (file)
@@ -10,6 +10,7 @@
  *
  */
 
+#include <crypto/algapi.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/fips.h>
@@ -59,6 +60,15 @@ static int crypto_check_alg(struct crypto_alg *alg)
        if (alg->cra_blocksize > PAGE_SIZE / 8)
                return -EINVAL;
 
+       if (!alg->cra_type && (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
+                              CRYPTO_ALG_TYPE_CIPHER) {
+               if (alg->cra_alignmask > MAX_CIPHER_ALIGNMASK)
+                       return -EINVAL;
+
+               if (alg->cra_blocksize > MAX_CIPHER_BLOCKSIZE)
+                       return -EINVAL;
+       }
+
        if (alg->cra_priority < 0)
                return -EINVAL;