summaryrefslogtreecommitdiffstats
path: root/net/ceph/crypto.h
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2016-12-02 16:35:07 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-26 08:24:41 +0100
commitecf7ced8562811576cd02158d6ae8e44c1fb4671 (patch)
treefef5843604cce3dd494664b1d23d47c0da786d3f /net/ceph/crypto.h
parent0548b82989384a58e749f0c04781b2c823c6c1b9 (diff)
downloadlinux-stable-ecf7ced8562811576cd02158d6ae8e44c1fb4671.tar.gz
linux-stable-ecf7ced8562811576cd02158d6ae8e44c1fb4671.tar.bz2
linux-stable-ecf7ced8562811576cd02158d6ae8e44c1fb4671.zip
libceph: introduce ceph_crypt() for in-place en/decryption
commit a45f795c65b479b4ba107b6ccde29b896d51ee98 upstream. Starting with 4.9, kernel stacks may be vmalloced and therefore not guaranteed to be physically contiguous; the new CONFIG_VMAP_STACK option is enabled by default on x86. This makes it invalid to use on-stack buffers with the crypto scatterlist API, as sg_set_buf() expects a logical address and won't work with vmalloced addresses. There isn't a different (e.g. kvec-based) crypto API we could switch net/ceph/crypto.c to and the current scatterlist.h API isn't getting updated to accommodate this use case. Allocating a new header and padding for each operation is a non-starter, so do the en/decryption in-place on a single pre-assembled (header + data + padding) heap buffer. This is explicitly supported by the crypto API: "... the caller may provide the same scatter/gather list for the plaintext and cipher text. After the completion of the cipher operation, the plaintext data is replaced with the ciphertext data in case of an encryption and vice versa for a decryption." Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Reviewed-by: Sage Weil <sage@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/ceph/crypto.h')
-rw-r--r--net/ceph/crypto.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/ceph/crypto.h b/net/ceph/crypto.h
index 2e9cab09f37b..73da34e8c62e 100644
--- a/net/ceph/crypto.h
+++ b/net/ceph/crypto.h
@@ -43,6 +43,8 @@ int ceph_encrypt2(struct ceph_crypto_key *secret,
void *dst, size_t *dst_len,
const void *src1, size_t src1_len,
const void *src2, size_t src2_len);
+int ceph_crypt(const struct ceph_crypto_key *key, bool encrypt,
+ void *buf, int buf_len, int in_len, int *pout_len);
int ceph_crypto_init(void);
void ceph_crypto_shutdown(void);