summaryrefslogtreecommitdiff
path: root/net/bluetooth/selftest.c
diff options
context:
space:
mode:
authorSalvatore Benedetto <salvatore.benedetto@intel.com>2017-04-25 18:59:47 +0300
committerMarcel Holtmann <marcel@holtmann.org>2017-04-30 13:22:05 +0300
commit763d9a302ab18da0a0078c9788ed6566d0c974e3 (patch)
treeccc0213c60b3d08a9292493b27f6ad4a5cb25c1a /net/bluetooth/selftest.c
parent58771c1cb0023fdd744e76d6cad7716dc4f579ee (diff)
downloadlinux-763d9a302ab18da0a0078c9788ed6566d0c974e3.tar.xz
Bluetooth: allocate data for kpp on heap
Bluetooth would crash when computing ECDH keys with kpp if VMAP_STACK is enabled. Fix by allocating data passed to kpp on heap. Fixes: 58771c1c ("Bluetooth: convert smp and selftest to crypto kpp API") Signed-off-by: Salvatore Benedetto <salvatore.benedetto@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/selftest.c')
-rw-r--r--net/bluetooth/selftest.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/net/bluetooth/selftest.c b/net/bluetooth/selftest.c
index efef2815646e..ee92c925ecc5 100644
--- a/net/bluetooth/selftest.c
+++ b/net/bluetooth/selftest.c
@@ -142,18 +142,30 @@ static int __init test_ecdh_sample(const u8 priv_a[32], const u8 priv_b[32],
const u8 pub_a[64], const u8 pub_b[64],
const u8 dhkey[32])
{
- u8 dhkey_a[32], dhkey_b[32];
+ u8 *tmp, *dhkey_a, *dhkey_b;
+ int ret = 0;
+
+ tmp = kmalloc(64, GFP_KERNEL);
+ if (!tmp)
+ return -EINVAL;
+
+ dhkey_a = &tmp[0];
+ dhkey_b = &tmp[32];
compute_ecdh_secret(pub_b, priv_a, dhkey_a);
compute_ecdh_secret(pub_a, priv_b, dhkey_b);
- if (memcmp(dhkey_a, dhkey, 32))
- return -EINVAL;
+ if (memcmp(dhkey_a, dhkey, 32)) {
+ ret = -EINVAL;
+ goto out;
+ }
if (memcmp(dhkey_b, dhkey, 32))
- return -EINVAL;
+ ret = -EINVAL;
- return 0;
+out:
+ kfree(dhkey_a);
+ return ret;
}
static char test_ecdh_buffer[32];