]> www.infradead.org Git - users/jedix/linux-maple.git/commit
crypto: hash - Fix test underflow in shash_ahash_digest
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 13 Mar 2025 05:14:58 +0000 (13:14 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Mar 2025 09:33:38 +0000 (17:33 +0800)
commit480db5009571aa8d7f39b0357a6fd337fa3caf31
treed1a96c1ed949819fb4314c12f84dd8d012e4fe01
parentda6f9bf40ac267b5c720694a817beea84fa40f77
crypto: hash - Fix test underflow in shash_ahash_digest

The test on PAGE_SIZE - offset in shash_ahash_digest can underflow,
leading to execution of the fast path even if the data cannot be
mapped into a single page.

Fix this by splitting the test into four cases:

1) nbytes > sg->length: More than one SG entry, slow path.
2) !IS_ENABLED(CONFIG_HIGHMEM): fast path.
3) nbytes > (unsigned int)PAGE_SIZE - offset: Two highmem pages, slow path.
4) Highmem fast path.

Fixes: 5f7082ed4f48 ("crypto: hash - Export shash through hash")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/ahash.c