crypto: acomp - fix dst-folio branch setting src instead of dst in acomp_virt_to_sg
Subsystems (2)
PATCH 1/1 crypto: acomp - fix dst-folio branch setting src instead of dst in acomp_virt_to_sg
In acomp_virt_to_sg(), the dst_isfolio branch calls acomp_request_set_src_sg() instead of acomp_request_set_dst_sg(). This overwrites req->src with the destination folio SG and leaves req->dst holding a raw struct folio pointer (via the src/dst union). The algorithm then reads from the wrong buffer and dereferences the stale folio pointer as a scatterlist.
The bug is reachable from UBIFS decompression on systems with a hardware compression accelerator (HiSilicon ZIP, Intel IAA, Intel QAT), where crypto_alloc_acomp() selects the hardware driver over scompress. Software scompress backends are unaffected because they set CRYPTO_ALG_REQ_CHAIN and bypass acomp_virt_to_sg() entirely.
--- crypto/acompress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/acompress.c +1 -1
@@ -237,7 +237,7 @@ static void acomp_virt_to_sg(struct acomp_req *req)sg_init_table (&state->dsg,1 );sg_set_page (&state->dsg,folio_page (folio, off /PAGE_SIZE ), dlen, off %PAGE_SIZE ); -acomp_request_set_src_sg (req, &state->dsg, dlen); +acomp_request_set_dst_sg (req, &state->dsg, dlen); } }
Signature · 1 line
2.53.0
Herbert Xu
maintainercrypto/acompress.c static void acomp_virt_to_sg(struct acomp_req *req) · line 242
Quoted 13 lines · Aaron Esau
crypto/acompress.c +1
-1@@ -237,7 +237,7 @@ static void acomp_virt_to_sg(struct acomp_req *req)sg_init_table (&state->dsg,1 );sg_set_page (&state->dsg,folio_page (folio, off /PAGE_SIZE ), dlen, off %PAGE_SIZE ); -acomp_request_set_src_sg (req, &state->dsg, dlen); +acomp_request_set_dst_sg (req, &state->dsg, dlen); } }
This patch doesn't apply against mainline. In fact the code that you're referencing does not exist on mainline.
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
Hi Herbert,
The patch was generated against v6.15-rc6 (82f2b0b97). The buggy line is at crypto/acompress.c:240 in that tag, and the index hash f7a3fbe54 matched (I just checked again).
Could you double-check?
Thanks,
Aaron
Herbert Xu
maintainerQuoted 6 lines · Aaron Esau
The patch was generated against v6.15-rc6 (
82f2b0b97). The buggy line is atcrypto/acompress.c:240in that tag, and the index hashf7a3fbe54matched (I just checked again).Could you double-check?
We're currently at v7.0 heading towards v7.1. The bug that you're reporting does not exist in v7.0.
Cheers,
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