|
|
7cdc99 |
--- a/lib/crypto_backend/crypto_cipher_kernel.c
|
|
|
7cdc99 |
+++ b/lib/crypto_backend/crypto_cipher_kernel.c
|
|
|
7cdc99 |
@@ -31,6 +31,7 @@
|
|
|
7cdc99 |
#ifdef ENABLE_AF_ALG
|
|
|
7cdc99 |
|
|
|
7cdc99 |
#include <linux/if_alg.h>
|
|
|
7cdc99 |
+#include <sys/utsname.h>
|
|
|
7cdc99 |
|
|
|
7cdc99 |
#ifndef AF_ALG
|
|
|
7cdc99 |
#define AF_ALG 38
|
|
|
7cdc99 |
@@ -88,6 +89,35 @@ int crypt_cipher_blocksize(const char *n
|
|
|
7cdc99 |
return ca ? ca->blocksize : -EINVAL;
|
|
|
7cdc99 |
}
|
|
|
7cdc99 |
|
|
|
7cdc99 |
+static size_t pagesize(size_t defsize)
|
|
|
7cdc99 |
+{
|
|
|
7cdc99 |
+ long r = sysconf(_SC_PAGESIZE);
|
|
|
7cdc99 |
+ return r < 0 ? defsize : (size_t)r;
|
|
|
7cdc99 |
+}
|
|
|
7cdc99 |
+
|
|
|
7cdc99 |
+static int check_rh_kernel_version(void)
|
|
|
7cdc99 |
+{
|
|
|
7cdc99 |
+ unsigned maj, mid, min, rel;
|
|
|
7cdc99 |
+ static struct utsname uts = {{ 0 }};
|
|
|
7cdc99 |
+ size_t ps = pagesize(32768);
|
|
|
7cdc99 |
+
|
|
|
7cdc99 |
+ if (ps < 32768)
|
|
|
7cdc99 |
+ return 0;
|
|
|
7cdc99 |
+
|
|
|
7cdc99 |
+ if (!*uts.release && uname(&uts) < 0)
|
|
|
7cdc99 |
+ return -ENOTSUP;
|
|
|
7cdc99 |
+ /*
|
|
|
7cdc99 |
+ * RH kernels 3.10.0-185 and lower are affected by a crypto API kernel
|
|
|
7cdc99 |
+ * socket bug. The bug only manifests on archs with page size >= 32 KiB.
|
|
|
7cdc99 |
+ *
|
|
|
7cdc99 |
+ * For reference, see rhbz#1136075
|
|
|
7cdc99 |
+ */
|
|
|
7cdc99 |
+ if (sscanf(uts.release, "%u.%u.%u-%u", &maj, &mid, &min, &rel) == 4)
|
|
|
7cdc99 |
+ return (maj == 3 && mid == 10 && min == 0 && rel < 186) ? -ENOTSUP : 0;
|
|
|
7cdc99 |
+
|
|
|
7cdc99 |
+ return -ENOTSUP;
|
|
|
7cdc99 |
+}
|
|
|
7cdc99 |
+
|
|
|
7cdc99 |
/*
|
|
|
7cdc99 |
* ciphers
|
|
|
7cdc99 |
*
|
|
|
7cdc99 |
@@ -104,6 +134,9 @@ int crypt_cipher_init(struct crypt_ciphe
|
|
|
7cdc99 |
.salg_type = "skcipher",
|
|
|
7cdc99 |
};
|
|
|
7cdc99 |
|
|
|
7cdc99 |
+ if (check_rh_kernel_version())
|
|
|
7cdc99 |
+ return -ENOTSUP;
|
|
|
7cdc99 |
+
|
|
|
7cdc99 |
h = malloc(sizeof(*h));
|
|
|
7cdc99 |
if (!h)
|
|
|
7cdc99 |
return -ENOMEM;
|