From: Herbert Xu Date: Thu, 18 Jun 2015 06:00:49 +0000 (+0800) Subject: crypto: aead - Fix aead_instance struct size X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f5d8660acb9623470adcef426c6ff7b07cbe4b74;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git crypto: aead - Fix aead_instance struct size The struct aead_instance is meant to extend struct crypto_instance by incorporating the extra members of struct aead_alg. However, the current layout which is copied from shash/ahash does not specify the struct fully. In particular only aead_alg is present. For shash/ahash this works because users there add extra headroom to sizeof(struct crypto_instance) when allocating the instance. Unfortunately for aead, this bit was lost when the new aead_instance was added. Rather than fixing it like shash/ahash, this patch simply expands struct aead_instance to contain what is supposed to be there, i.e., adding struct crypto_instance. In order to not break existing AEAD users, this is done through an anonymous union. Signed-off-by: Herbert Xu --- diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h index ba52c37b8c40..4b2547186519 100644 --- a/include/crypto/internal/aead.h +++ b/include/crypto/internal/aead.h @@ -15,12 +15,19 @@ #include #include +#include #include struct rtattr; struct aead_instance { - struct aead_alg alg; + union { + struct { + char head[offsetof(struct aead_alg, base)]; + struct crypto_instance base; + } s; + struct aead_alg alg; + }; }; struct crypto_aead_spawn {