crypto: caam - stop RSA zero scanning at the byte limit
PATCH 1/1 crypto: caam - stop RSA zero scanning at the byte limit
When the requested zero prefix ends at a scatterlist-entry boundary, caam_rsa_count_leading_zeros() calls sg_miter_next() after consuming all requested bytes. The iterator releases the current mapping and can return false because its bounded scatterlist is exhausted.
The scanner then assigns the previous mapping's zero count to miter.consumed, although miter.length has been cleared. The final sg_miter_stop() consequently warns that consumed exceeds length.
Stop scanning once the requested byte count has been reached, before advancing the iterator.
GitHub Copilot assisted with diagnosing the iterator boundary issue, developing the fix and regression tests, and drafting this message.
--- drivers/crypto/caam/caampkc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/caam/caampkc.c +1 -1
@@ -302,7 +302,7 @@ static int caam_rsa_count_leading_zeros(struct scatterlist *sgl, buff++; } -if (len && *buff) +if (lzeros == nbytes || (len && *buff))break ;if (!sg_miter_next (&miter))
Signature · 1 line
2.43.0