crypto: acomp - Fix CFI failure due to type punning
Subsystems (3)
PATCH 1/1 crypto: acomp - Fix CFI failure due to type punning
To avoid a crash when control flow integrity is enabled, make the workspace ("stream") free function use a consistent type, and call it through a function pointer that has that same type.
Fixes 42d9f6c77479 ("crypto: acomp - Move scomp stream allocation code into acomp")
Signed-off-by Eric Biggers <[email protected]>
--- crypto/deflate.c | 7 ++++++- crypto/zstd.c | 7 ++++++- include/crypto/internal/acompress.h | 5 +---- 3 files changed, 13 insertions(+), 6 deletions(-)
crypto/deflate.c +6 -1
@@ -46,13 +46,18 @@ static void *deflate_alloc_stream(void) ctx->stream.workspace = ctx->workspace;return ctx; } +static void deflate_free_stream (void *ctx) +{ +kvfree (ctx); +} +static struct crypto_acomp_streams deflate_streams = { .alloc_ctx = deflate_alloc_stream, - .cfree_ctx = kvfree, + .free_ctx = deflate_free_stream, };static int deflate_compress_one (struct acomp_req *req,struct deflate_stream *ds) {
crypto/zstd.c +6 -1
@@ -52,13 +52,18 @@ static void *zstd_alloc_stream(void) ctx->wksp_size = wksp_size;return ctx; } +static void zstd_free_stream (void *ctx) +{ +kvfree (ctx); +} +static struct crypto_acomp_streams zstd_streams = { .alloc_ctx = zstd_alloc_stream, - .cfree_ctx = kvfree, + .free_ctx = zstd_free_stream, };static int zstd_init (struct crypto_acomp *acomp_tfm) {int ret =0 ;
include/crypto/internal/acompress.h +1 -4
@@ -61,14 +61,11 @@ struct crypto_acomp_stream { };struct crypto_acomp_streams {/* These must come first because of struct scomp_alg. */ void *(*alloc_ctx)(void ); -union { -void (*free_ctx)(void *); -void (*cfree_ctx)(const void *); - }; +void (*free_ctx)(void *);struct crypto_acomp_stream __percpu *streams;struct work_struct stream_work;cpumask_t stream_want; };
base-commit: 181698af38d3f93381229ad89c09b5bd0496661a
Signature · 1 line
2.50.1
Quoted 4 lines · Eric Biggers
To avoid a crash when control flow integrity is enabled, make the workspace ("stream") free function use a consistent type, and call it through a function pointer that has that same type.
Quoted 9 lines
Fixes 42d9f6c77479 ("crypto: acomp - Move scomp stream allocation code into acomp")Signed-off-by Eric Biggers <[email protected]>--- crypto/deflate.c | 7 ++++++- crypto/zstd.c | 7 ++++++- include/crypto/internal/acompress.h | 5 +---- 3 files changed, 13 insertions(+), 6 deletions(-)
Reviewed-by Giovanni Cabiddu <[email protected]>
Regards,
Signature · 1 line
Giovanni
Herbert Xu
maintainerQuoted 4 lines · Eric Biggers
To avoid a crash when control flow integrity is enabled, make the workspace ("stream") free function use a consistent type, and call it through a function pointer that has that same type.
Quoted 8 lines
Fixes 42d9f6c77479 ("crypto: acomp - Move scomp stream allocation code into acomp")Signed-off-by Eric Biggers <[email protected]>---
crypto/deflate.c | 7 ++++++- crypto/zstd.c | 7 ++++++- include/crypto/internal/acompress.h | 5 +---- 3 files changed, 13 insertions(+), 6 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt