summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2021-06-10 08:21:50 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-14 16:53:13 +0200
commit80b9d3becd84ef0b096df286cdf4663d74e8354a (patch)
tree5e36d6f0bff54b1870ab63ab8245ead4c0fa53e1 /include
parent31ef30f8f8786b70a27837634ad176a4b035ac27 (diff)
downloadlinux-stable-80b9d3becd84ef0b096df286cdf4663d74e8354a.tar.gz
linux-stable-80b9d3becd84ef0b096df286cdf4663d74e8354a.tar.bz2
linux-stable-80b9d3becd84ef0b096df286cdf4663d74e8354a.zip
crypto: shash - avoid comparing pointers to exported functions under CFI
[ Upstream commit 22ca9f4aaf431a9413dcc115dd590123307f274f ] crypto_shash_alg_has_setkey() is implemented by testing whether the .setkey() member of a struct shash_alg points to the default version, called shash_no_setkey(). As crypto_shash_alg_has_setkey() is a static inline, this requires shash_no_setkey() to be exported to modules. Unfortunately, when building with CFI, function pointers are routed via CFI stubs which are private to each module (or to the kernel proper) and so this function pointer comparison may fail spuriously. Let's fix this by turning crypto_shash_alg_has_setkey() into an out of line function. Cc: Sami Tolvanen <samitolvanen@google.com> Cc: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/crypto/internal/hash.h8
1 files changed, 1 insertions, 7 deletions
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index bfc9db7b100d..9cc7f1c02d27 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -77,13 +77,7 @@ int ahash_register_instance(struct crypto_template *tmpl,
struct ahash_instance *inst);
void ahash_free_instance(struct crypto_instance *inst);
-int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
- unsigned int keylen);
-
-static inline bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
-{
- return alg->setkey != shash_no_setkey;
-}
+bool crypto_shash_alg_has_setkey(struct shash_alg *alg);
bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg);