summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaire Farron2016-02-26 19:00:19 +0000
committerClaire Farron2016-02-26 19:00:19 +0000
commit4515dcf1ed927e6ba2a75f6a233287cb56229f46 (patch)
treeda243740abd1ff806cbf368bc87963cd256c46fa
parentf9d544c4178331a2dab1dc458ae9e20ecc7731e6 (diff)
downloadaur-4515dcf1ed927e6ba2a75f6a233287cb56229f46.tar.gz
Workaround: FS48230 - https://bugs.archlinux.org/task/48230
-rw-r--r--.SRCINFO8
-rw-r--r--0001-Set-skcipher-key-before-accept-call-in-kernel-crypto.patch191
-rw-r--r--0002-Fix-kernel-crypto-backend-to-set-key-before-accept-c.patch76
-rw-r--r--PKGBUILD17
-rw-r--r--libcryptsetup.h.patch.asc26
5 files changed, 300 insertions, 18 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 50c98bc4794c..fb4c1622e62f 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,9 @@
+# Generated by mksrcinfo v8
+# Fri Feb 26 19:00:16 UTC 2016
pkgbase = cryptsetup-nuke-keys
pkgdesc = cryptsetup patched to nuke all keyslots given a certain passphrase
pkgver = 1.7.0
- pkgrel = 1
+ pkgrel = 2
url = https://github.com/offensive-security/cryptsetup-nuke-keys
arch = i686
arch = x86_64
@@ -25,6 +27,8 @@ pkgbase = cryptsetup-nuke-keys
source = libcryptsetup.h.patch
source = libcryptsetup.h.patch.asc
source = setup.c.patch
+ source = 0001-Set-skcipher-key-before-accept-call-in-kernel-crypto.patch
+ source = 0002-Fix-kernel-crypto-backend-to-set-key-before-accept-c.patch
sha256sums = 075524a7cc0db36d12119fa79116750accb1c6c8825d5faa2534b74b8ce3d148
sha256sums = SKIP
sha256sums = 4406f8dc83f4f1b408e49d557515f721d91b358355c71fbe51f74ab27e5c84ff
@@ -35,6 +39,8 @@ pkgbase = cryptsetup-nuke-keys
sha256sums = b877fbba63e59aaac3d8ee37789b5d1f497d133909b1d4148b7afb5e9dd4e565
sha256sums = SKIP
sha256sums = 257656034c2fda27e0711dc76142693519453812d2cd45248abe3ea2f3c60a80
+ sha256sums = c4fb5946ba1b48b5a2fdafa2c32748f205d83d4cc824ebdae2d2f30abfc31b07
+ sha256sums = f4074ddf3f494f7da09be6a4ab9d42d84cf2a7818a959c526849e1bb40dab54d
pkgname = cryptsetup-nuke-keys
diff --git a/0001-Set-skcipher-key-before-accept-call-in-kernel-crypto.patch b/0001-Set-skcipher-key-before-accept-call-in-kernel-crypto.patch
new file mode 100644
index 000000000000..f79db4237047
--- /dev/null
+++ b/0001-Set-skcipher-key-before-accept-call-in-kernel-crypto.patch
@@ -0,0 +1,191 @@
+From 93ed401b7c1d298de0a3fe38ae45d96529a8511c Mon Sep 17 00:00:00 2001
+From: Milan Broz <gmazyland@gmail.com>
+Date: Sat, 2 Jan 2016 20:02:28 +0100
+Subject: [PATCH] Set skcipher key before accept() call in kernel crypto
+ backend.
+
+Also relax input errno checking to catch all errors.
+---
+ lib/crypto_backend/crypto_cipher_kernel.c | 56 ++++++++++++-------------------
+ lib/crypto_backend/crypto_kernel.c | 35 ++++++++++++++-----
+ 2 files changed, 48 insertions(+), 43 deletions(-)
+
+diff --git a/lib/crypto_backend/crypto_cipher_kernel.c b/lib/crypto_backend/crypto_cipher_kernel.c
+index f7d2bcf..46e1f97 100644
+--- a/lib/crypto_backend/crypto_cipher_kernel.c
++++ b/lib/crypto_backend/crypto_cipher_kernel.c
+@@ -2,7 +2,7 @@
+ * Linux kernel userspace API crypto backend implementation (skcipher)
+ *
+ * Copyright (C) 2012, Red Hat, Inc. All rights reserved.
+- * Copyright (C) 2012-2014, Milan Broz
++ * Copyright (C) 2012-2016, Milan Broz
+ *
+ * This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+@@ -88,33 +88,8 @@ int crypt_cipher_blocksize(const char *name)
+ return ca ? ca->blocksize : -EINVAL;
+ }
+
+-/* Shared with hash kernel backend */
+-int crypt_kernel_socket_init(struct sockaddr_alg *sa, int *tfmfd, int *opfd);
+-
+-int crypt_kernel_socket_init(struct sockaddr_alg *sa, int *tfmfd, int *opfd)
+-{
+- *tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
+- if (*tfmfd == -1)
+- return -ENOTSUP;
+-
+- if (bind(*tfmfd, (struct sockaddr *)sa, sizeof(*sa)) == -1) {
+- close(*tfmfd);
+- *tfmfd = -1;
+- return -ENOENT;
+- }
+-
+- *opfd = accept(*tfmfd, NULL, 0);
+- if (*opfd == -1) {
+- close(*tfmfd);
+- *tfmfd = -1;
+- return -EINVAL;
+- }
+-
+- return 0;
+-}
+-
+ /*
+- *ciphers
++ * ciphers
+ *
+ * ENOENT - algorithm not available
+ * ENOTSUP - AF_ALG family not available
+@@ -128,7 +103,6 @@ int crypt_cipher_init(struct crypt_cipher **ctx, const char *name,
+ .salg_family = AF_ALG,
+ .salg_type = "skcipher",
+ };
+- int r;
+
+ h = malloc(sizeof(*h));
+ if (!h)
+@@ -137,14 +111,26 @@ int crypt_cipher_init(struct crypt_cipher **ctx, const char *name,
+ snprintf((char *)sa.salg_name, sizeof(sa.salg_name),
+ "%s(%s)", mode, name);
+
+- r = crypt_kernel_socket_init(&sa, &h->tfmfd, &h->opfd);
+- if (r < 0) {
+- free(h);
+- return r;
++ h->opfd = -1;
++ h->tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
++ if (h->tfmfd < 0) {
++ crypt_cipher_destroy(h);
++ return -ENOTSUP;
++ }
++
++ if (bind(h->tfmfd, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
++ crypt_cipher_destroy(h);
++ return -ENOENT;
+ }
+
+ if (length && strcmp(name, "cipher_null") &&
+- setsockopt(h->tfmfd, SOL_ALG, ALG_SET_KEY, buffer, length) == -1) {
++ setsockopt(h->tfmfd, SOL_ALG, ALG_SET_KEY, buffer, length) < 0) {
++ crypt_cipher_destroy(h);
++ return -EINVAL;
++ }
++
++ h->opfd = accept(h->tfmfd, NULL, 0);
++ if (h->opfd < 0) {
+ crypt_cipher_destroy(h);
+ return -EINVAL;
+ }
+@@ -239,9 +225,9 @@ int crypt_cipher_decrypt(struct crypt_cipher *ctx,
+
+ int crypt_cipher_destroy(struct crypt_cipher *ctx)
+ {
+- if (ctx->tfmfd != -1)
++ if (ctx->tfmfd >= 0)
+ close(ctx->tfmfd);
+- if (ctx->opfd != -1)
++ if (ctx->opfd >= 0)
+ close(ctx->opfd);
+ memset(ctx, 0, sizeof(*ctx));
+ free(ctx);
+diff --git a/lib/crypto_backend/crypto_kernel.c b/lib/crypto_backend/crypto_kernel.c
+index 45cff31..4fbc578 100644
+--- a/lib/crypto_backend/crypto_kernel.c
++++ b/lib/crypto_backend/crypto_kernel.c
+@@ -2,7 +2,7 @@
+ * Linux kernel userspace API crypto backend implementation
+ *
+ * Copyright (C) 2010-2012, Red Hat, Inc. All rights reserved.
+- * Copyright (C) 2010-2014, Milan Broz
++ * Copyright (C) 2010-2016, Milan Broz
+ *
+ * This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+@@ -68,8 +68,27 @@ struct crypt_hmac {
+ int hash_len;
+ };
+
+-/* Defined in crypt_kernel_ciphers.c */
+-extern int crypt_kernel_socket_init(struct sockaddr_alg *sa, int *tfmfd, int *opfd);
++static int crypt_kernel_socket_init(struct sockaddr_alg *sa, int *tfmfd, int *opfd)
++{
++ *tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
++ if (*tfmfd < 0)
++ return -ENOTSUP;
++
++ if (bind(*tfmfd, (struct sockaddr *)sa, sizeof(*sa)) < 0) {
++ close(*tfmfd);
++ *tfmfd = -1;
++ return -ENOENT;
++ }
++
++ *opfd = accept(*tfmfd, NULL, 0);
++ if (*opfd < 0) {
++ close(*tfmfd);
++ *tfmfd = -1;
++ return -EINVAL;
++ }
++
++ return 0;
++}
+
+ int crypt_backend_init(struct crypt_device *ctx)
+ {
+@@ -188,9 +207,9 @@ int crypt_hash_final(struct crypt_hash *ctx, char *buffer, size_t length)
+
+ int crypt_hash_destroy(struct crypt_hash *ctx)
+ {
+- if (ctx->tfmfd != -1)
++ if (ctx->tfmfd >= 0)
+ close(ctx->tfmfd);
+- if (ctx->opfd != -1)
++ if (ctx->opfd >= 0)
+ close(ctx->opfd);
+ memset(ctx, 0, sizeof(*ctx));
+ free(ctx);
+@@ -232,7 +251,7 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
+ return -EINVAL;
+ }
+
+- if (setsockopt(h->tfmfd, SOL_ALG, ALG_SET_KEY, buffer, length) == -1) {
++ if (setsockopt(h->tfmfd, SOL_ALG, ALG_SET_KEY, buffer, length) < 0) {
+ crypt_hmac_destroy(h);
+ return -EINVAL;
+ }
+@@ -268,9 +287,9 @@ int crypt_hmac_final(struct crypt_hmac *ctx, char *buffer, size_t length)
+
+ int crypt_hmac_destroy(struct crypt_hmac *ctx)
+ {
+- if (ctx->tfmfd != -1)
++ if (ctx->tfmfd >= 0)
+ close(ctx->tfmfd);
+- if (ctx->opfd != -1)
++ if (ctx->opfd >= 0)
+ close(ctx->opfd);
+ memset(ctx, 0, sizeof(*ctx));
+ free(ctx);
+--
+2.7.1
+
diff --git a/0002-Fix-kernel-crypto-backend-to-set-key-before-accept-c.patch b/0002-Fix-kernel-crypto-backend-to-set-key-before-accept-c.patch
new file mode 100644
index 000000000000..a896bee3eb8d
--- /dev/null
+++ b/0002-Fix-kernel-crypto-backend-to-set-key-before-accept-c.patch
@@ -0,0 +1,76 @@
+From 4dc88e8ffb6442ebba7ad8d14fa55691734371e0 Mon Sep 17 00:00:00 2001
+From: Milan Broz <gmazyland@gmail.com>
+Date: Mon, 4 Jan 2016 14:19:50 +0100
+Subject: [PATCH] Fix kernel crypto backend to set key before accept call even
+ for HMAC.
+
+---
+ lib/crypto_backend/crypto_kernel.c | 20 +++++++++++---------
+ 1 file changed, 11 insertions(+), 9 deletions(-)
+
+diff --git a/lib/crypto_backend/crypto_kernel.c b/lib/crypto_backend/crypto_kernel.c
+index 4fbc578..4d9d075 100644
+--- a/lib/crypto_backend/crypto_kernel.c
++++ b/lib/crypto_backend/crypto_kernel.c
+@@ -68,7 +68,8 @@ struct crypt_hmac {
+ int hash_len;
+ };
+
+-static int crypt_kernel_socket_init(struct sockaddr_alg *sa, int *tfmfd, int *opfd)
++static int crypt_kernel_socket_init(struct sockaddr_alg *sa, int *tfmfd, int *opfd,
++ const void *key, size_t key_length)
+ {
+ *tfmfd = socket(AF_ALG, SOCK_SEQPACKET, 0);
+ if (*tfmfd < 0)
+@@ -80,6 +81,12 @@ static int crypt_kernel_socket_init(struct sockaddr_alg *sa, int *tfmfd, int *op
+ return -ENOENT;
+ }
+
++ if (key && setsockopt(*tfmfd, SOL_ALG, ALG_SET_KEY, key, key_length) < 0) {
++ close(*tfmfd);
++ *tfmfd = -1;
++ return -EINVAL;
++ }
++
+ *opfd = accept(*tfmfd, NULL, 0);
+ if (*opfd < 0) {
+ close(*tfmfd);
+@@ -106,7 +113,7 @@ int crypt_backend_init(struct crypt_device *ctx)
+ if (uname(&uts) == -1 || strcmp(uts.sysname, "Linux"))
+ return -EINVAL;
+
+- if (crypt_kernel_socket_init(&sa, &tfmfd, &opfd) < 0)
++ if (crypt_kernel_socket_init(&sa, &tfmfd, &opfd, NULL, 0) < 0)
+ return -EINVAL;
+
+ close(tfmfd);
+@@ -171,7 +178,7 @@ int crypt_hash_init(struct crypt_hash **ctx, const char *name)
+
+ strncpy((char *)sa.salg_name, ha->kernel_name, sizeof(sa.salg_name));
+
+- if (crypt_kernel_socket_init(&sa, &h->tfmfd, &h->opfd) < 0) {
++ if (crypt_kernel_socket_init(&sa, &h->tfmfd, &h->opfd, NULL, 0) < 0) {
+ free(h);
+ return -EINVAL;
+ }
+@@ -246,16 +253,11 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name,
+ snprintf((char *)sa.salg_name, sizeof(sa.salg_name),
+ "hmac(%s)", ha->kernel_name);
+
+- if (crypt_kernel_socket_init(&sa, &h->tfmfd, &h->opfd) < 0) {
++ if (crypt_kernel_socket_init(&sa, &h->tfmfd, &h->opfd, buffer, length) < 0) {
+ free(h);
+ return -EINVAL;
+ }
+
+- if (setsockopt(h->tfmfd, SOL_ALG, ALG_SET_KEY, buffer, length) < 0) {
+- crypt_hmac_destroy(h);
+- return -EINVAL;
+- }
+-
+ *ctx = h;
+ return 0;
+ }
+--
+2.7.1
+
diff --git a/PKGBUILD b/PKGBUILD
index a985bcc939f6..c5059149201b 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -4,7 +4,7 @@
# Contributor: Andy Weidenbaum <archbaum@gmail.com>
pkgname=cryptsetup-nuke-keys
pkgver=1.7.0
-pkgrel=1
+pkgrel=2
pkgdesc="cryptsetup patched to nuke all keyslots given a certain passphrase"
arch=(i686 x86_64)
license=('GPL')
@@ -18,11 +18,13 @@ source=(https://www.kernel.org/pub/linux/utils/cryptsetup/v1.7/cryptsetup-${pkgv
encrypt_hook
encrypt_install
sd-encrypt
- cryptsetup.c.patch
+ cryptsetup.c.patch
keymanage.c.patch
libcryptsetup.h.patch
libcryptsetup.h.patch.asc
- setup.c.patch)
+ setup.c.patch
+ 0001-Set-skcipher-key-before-accept-call-in-kernel-crypto.patch
+ 0002-Fix-kernel-crypto-backend-to-set-key-before-accept-c.patch)
sha256sums=('075524a7cc0db36d12119fa79116750accb1c6c8825d5faa2534b74b8ce3d148'
'SKIP'
'4406f8dc83f4f1b408e49d557515f721d91b358355c71fbe51f74ab27e5c84ff'
@@ -32,7 +34,9 @@ sha256sums=('075524a7cc0db36d12119fa79116750accb1c6c8825d5faa2534b74b8ce3d148'
'13545e49806f441c2a70513bc2449229c9905f20b933e17ba54078c0392f6d87'
'b877fbba63e59aaac3d8ee37789b5d1f497d133909b1d4148b7afb5e9dd4e565'
'SKIP'
- '257656034c2fda27e0711dc76142693519453812d2cd45248abe3ea2f3c60a80')
+ '257656034c2fda27e0711dc76142693519453812d2cd45248abe3ea2f3c60a80'
+ 'c4fb5946ba1b48b5a2fdafa2c32748f205d83d4cc824ebdae2d2f30abfc31b07'
+ 'f4074ddf3f494f7da09be6a4ab9d42d84cf2a7818a959c526849e1bb40dab54d')
validpgpkeys=(
'5F885602C7FD0951F565E27949F67298E6366A92' # Claire Farron
@@ -45,6 +49,11 @@ conflicts=('cryptsetup')
prepare() {
cd "${srcdir}"/${pkgname%-nuke*}-${pkgver}
+ # Workaround: FS48230 - https://bugs.archlinux.org/task/48230
+ # http://thread.gmane.org/gmane.linux.kernel.stable/165742
+ patch -p1 -i "${srcdir}"/0001-Set-skcipher-key-before-accept-call-in-kernel-crypto.patch
+ patch -p1 -i "${srcdir}"/0002-Fix-kernel-crypto-backend-to-set-key-before-accept-c.patch
+
# luksAddNuke
msg "Patching source to enable luksAddNuke"
patch -p1 < ${srcdir}/cryptsetup.c.patch
diff --git a/libcryptsetup.h.patch.asc b/libcryptsetup.h.patch.asc
index 6f21cd4b91ab..d81f078d78db 100644
--- a/libcryptsetup.h.patch.asc
+++ b/libcryptsetup.h.patch.asc
@@ -1,17 +1,17 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
-iQIcBAABCgAGBQJVxQhxAAoJEANdy2vBPrJhVrkP/iQQtaBER6ac/kiTw/V/46bF
-UMC34mUGhxxplkgmBXEsv9+IBHnzLSBOzZ+gyTJzxUYL7WIAsXnigKLKqh8idJBL
-HXPKooLpjxL9LKoV3SQi3PxU7hgsxVXyfZ/XdMWhP6rju4wPqmvbD/ceWRPVRtaV
-go/vrOi3j1wZ1opQxbDs3UyW7cxd8vzUEZuxJ9tx2LAs9tP736dZa5wTsjL6Onqb
-Hf8Oj11IB2fm6LZb2MR7evtlhXWg09iFBm1ifm8TLlJePkO5TaCfIeWIeMP1/NKP
-dj1NiDoj2rtqx73hIVBW1iiAZGL/n1tC21rC9N6uVfUiGfinYFn4YHaLcQJZtTBA
-q7+44YnjNnQaN/kMCxyI6cv4q/7hGIG0LJx3EOQBvIBokq59GJd+AVUn7JSK/yNw
-+24/2ds8rZyXnBmubvDcW1134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