summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-08-28 09:28:40 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-08-28 09:28:40 -0700
commit9df08cdd33a70ee1310523065fc4e3f161f6242e (patch)
tree4461f95d57f819fec8483a688403de6f49fcf64a /crypto
parent344be13211d0fceb791a7da70ef810ad13340fe0 (diff)
parentee440d4fc0d2f15894ab1f64c474a3adbc858880 (diff)
downloadlinux-9df08cdd33a70ee1310523065fc4e3f161f6242e.tar.gz
linux-9df08cdd33a70ee1310523065fc4e3f161f6242e.zip
Merge tag 'v7.3-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fix from Herbert Xu: "Fix a memory allocation overrun in crypto acomp" * tag 'v7.3-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: acomp - allocate async request context when cloning
Diffstat (limited to 'crypto')
-rw-r--r--crypto/acompress.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/crypto/acompress.c b/crypto/acompress.c
index 032de704eb2c..4de1a2ad577f 100644
--- a/crypto/acompress.c
+++ b/crypto/acompress.c
@@ -559,12 +559,22 @@ EXPORT_SYMBOL_GPL(acomp_walk_virt);
struct acomp_req *acomp_request_clone(struct acomp_req *req,
size_t total, gfp_t gfp)
{
+ struct crypto_tfm *tfm = req->base.tfm;
struct acomp_req *nreq;
+ size_t len;
- nreq = container_of(crypto_request_clone(&req->base, total, gfp),
- struct acomp_req, base);
- if (nreq == req)
+ len = sizeof(*req) +
+ crypto_acomp_reqsize(crypto_acomp_reqtfm(req));
+ len = ALIGN(len, CRYPTO_MINALIGN);
+
+ nreq = kzalloc(len, gfp);
+ if (!nreq) {
+ req->base.tfm = tfm->fb;
return req;
+ }
+
+ memcpy(nreq, req, sizeof(*req));
+ nreq->base.flags &= ~CRYPTO_TFM_REQ_ON_STACK;
if (req->src == &req->chain.ssg)
nreq->src = &nreq->chain.ssg;