[PATCH v4 2/3] crypto: acomp - enforce MAX_SYNC_COMP_REQSIZE

From: Usama Arif

Date: Sat Oct 17 2026 - 12:13:30 EST


From: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

Enforce the limit MAX_SYNC_COMP_REQSIZE when an acomp tfm is
initialised. All existing algorithms obey this limit.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Usama Arif <usama.arif@xxxxxxxxx>
---
crypto/acompress.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/crypto/acompress.c b/crypto/acompress.c
index 4de1a2ad577f2..c8b4b8589769e 100644
--- a/crypto/acompress.c
+++ b/crypto/acompress.c
@@ -92,10 +92,6 @@ static int crypto_acomp_init_tfm(struct crypto_tfm *tfm)
if (IS_ERR(fb))
return PTR_ERR(fb);

- err = -EINVAL;
- if (crypto_acomp_reqsize(fb) > MAX_SYNC_COMP_REQSIZE)
- goto out_free_fb;
-
tfm->fb = crypto_acomp_tfm(fb);
}

@@ -105,15 +101,19 @@ static int crypto_acomp_init_tfm(struct crypto_tfm *tfm)

acomp->base.exit = crypto_acomp_exit_tfm;

- if (!alg->init)
- return 0;
-
- err = alg->init(acomp);
- if (err)
+ if (alg->init && ((err = alg->init(acomp))))
goto out_free_fb;

+ err = -EINVAL;
+ if (!acomp_is_async(acomp) &&
+ crypto_acomp_reqsize(acomp) > MAX_SYNC_COMP_REQSIZE)
+ goto out_exit_tfm;
+
return 0;

+out_exit_tfm:
+ if (alg->exit)
+ alg->exit(acomp);
out_free_fb:
crypto_free_acomp(fb);
return err;
--
2.53.0-Meta