Skip to content

Commit 7ec68c5

Browse files
Eric Biggersgregkh
authored andcommitted
crypto: acomp - Fix CFI failure due to type punning
commit 962ddc5 upstream. 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: 42d9f6c ("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> [Giovanni: Backport to 6.16.y. Removed logic in crypto/zstd.c as commit f5ad93f ("crypto: zstd - convert to acomp") is not going to be backported to stable.] Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 31eb1b5 commit 7ec68c5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

crypto/deflate.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ static void *deflate_alloc_stream(void)
4848
return ctx;
4949
}
5050

51+
static void deflate_free_stream(void *ctx)
52+
{
53+
kvfree(ctx);
54+
}
55+
5156
static struct crypto_acomp_streams deflate_streams = {
5257
.alloc_ctx = deflate_alloc_stream,
53-
.cfree_ctx = kvfree,
58+
.free_ctx = deflate_free_stream,
5459
};
5560

5661
static int deflate_compress_one(struct acomp_req *req,

include/crypto/internal/acompress.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ struct crypto_acomp_stream {
6363
struct crypto_acomp_streams {
6464
/* These must come first because of struct scomp_alg. */
6565
void *(*alloc_ctx)(void);
66-
union {
67-
void (*free_ctx)(void *);
68-
void (*cfree_ctx)(const void *);
69-
};
66+
void (*free_ctx)(void *);
7067

7168
struct crypto_acomp_stream __percpu *streams;
7269
struct work_struct stream_work;

0 commit comments

Comments
 (0)