summaryrefslogtreecommitdiff
path: root/crypto/authenc.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2019-02-07 16:44:43 +0100
committerBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2019-02-07 16:44:43 +0100
commitfa52b9919271e59a73b989df5c92bbf0bb983c3d (patch)
treead35f7c066ef1e52febbbfc0fc62fe9623cc4e00 /crypto/authenc.c
parent6e603ea6e028001e3d56dc56822cb9c1cf2908f9 (diff)
parentbc2a1ca9b6b0c50decebcbb4c6b4160cf81eed93 (diff)
downloadlinux-crypto-fa52b9919271e59a73b989df5c92bbf0bb983c3d.tar.gz
linux-crypto-fa52b9919271e59a73b989df5c92bbf0bb983c3d.zip
Merge tag 'v5.0-rc5' of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into fbdev-for-next
Linux 5.0-rc5 Sync with upstream (which now contains fbdev-v5.0-rc3 changes) to prepare a base for fbdev-v5.1 changes.
Diffstat (limited to 'crypto/authenc.c')
-rw-r--r--crypto/authenc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/crypto/authenc.c b/crypto/authenc.c
index 37f54d1b..4be293a4 100644
--- a/crypto/authenc.c
+++ b/crypto/authenc.c
@@ -58,14 +58,22 @@ int crypto_authenc_extractkeys(struct crypto_authenc_keys *keys, const u8 *key,
return -EINVAL;
if (rta->rta_type != CRYPTO_AUTHENC_KEYA_PARAM)
return -EINVAL;
- if (RTA_PAYLOAD(rta) < sizeof(*param))
+
+ /*
+ * RTA_OK() didn't align the rtattr's payload when validating that it
+ * fits in the buffer. Yet, the keys should start on the next 4-byte
+ * aligned boundary. To avoid confusion, require that the rtattr
+ * payload be exactly the param struct, which has a 4-byte aligned size.
+ */
+ if (RTA_PAYLOAD(rta) != sizeof(*param))
return -EINVAL;
+ BUILD_BUG_ON(sizeof(*param) % RTA_ALIGNTO);
param = RTA_DATA(rta);
keys->enckeylen = be32_to_cpu(param->enckeylen);
- key += RTA_ALIGN(rta->rta_len);
- keylen -= RTA_ALIGN(rta->rta_len);
+ key += rta->rta_len;
+ keylen -= rta->rta_len;
if (keylen < keys->enckeylen)
return -EINVAL;