]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: acomp - Fix CFI failure due to type punning
authorEric Biggers <ebiggers@kernel.org>
Wed, 9 Jul 2025 00:59:54 +0000 (17:59 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 18 Jul 2025 10:52:00 +0000 (20:52 +1000)
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")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/deflate.c
crypto/zstd.c
include/crypto/internal/acompress.h

index fe8e4ad0fee1060c29f30f1b4aff9a48c483fcc0..21404515dc77ec208021d82dc20ae3517e0fbbad 100644 (file)
@@ -48,9 +48,14 @@ static void *deflate_alloc_stream(void)
        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,
index ebeadc1f3b5fdae51b686d1fdef28bf4b2197b0e..c2a19cb0879d60e0b3a9d0e650db4ede6059551b 100644 (file)
@@ -54,9 +54,14 @@ static void *zstd_alloc_stream(void)
        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)
index ffffd88bbbad3316e7e34fe6735d4b16def2cc71..2d97440028ffd7bf3ae1c2c69ebb955c523838bb 100644 (file)
@@ -63,10 +63,7 @@ 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;