Skip to contentSkip to conversation

crypto: skcipher - fix mismatch between mapping and unmapping order

PATCH In review Eric Biggers 2 participants 2 messages Mar 6, 2025 – Mar 8, 2025 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: skcipher - fix mismatch between mapping and unmapping order

From: Eric Biggers <[email protected]>

Local kunmaps have to be unmapped in the opposite order from which they were mapped. My recent change flipped the unmap order in the SKCIPHER_WALK_DIFF case. Adjust the mapping side to match.

This fixes a WARN_ON_ONCE that was triggered when running the crypto-self tests on a 32-bit kernel with CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP=y.

Fixes 95dbd711b1d8 ("crypto: skcipher - use the new scatterwalk functions")
---
 crypto/skcipher.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
crypto/skcipher.c +3 -3
index 53123d3685d5d..66d19c360dd8b 100644
@@ -207,16 +207,16 @@ static int skcipher_next_fast(struct skcipher_walk *walk)
 	diff = offset_in_page(walk->in.offset) -
 	       offset_in_page(walk->out.offset);
 	diff |= (u8 *)(sg_page(walk->in.sg) + (walk->in.offset >> PAGE_SHIFT)) -
 		(u8 *)(sg_page(walk->out.sg) + (walk->out.offset >> PAGE_SHIFT));
 
-	skcipher_map_src(walk);
-	walk->dst.virt.addr = walk->src.virt.addr;
+	skcipher_map_dst(walk);
+	walk->src.virt.addr = walk->dst.virt.addr;
 
 	if (diff) {
 		walk->flags |= SKCIPHER_WALK_DIFF;
-		skcipher_map_dst(walk);
+		skcipher_map_src(walk);
 	}
 
 	return 0;
 }
 

base-commit: 17ec3e71ba797cdb62164fea9532c81b60f47167

Signature · 1 line
2.48.1
maintainer
#1 lore raw
Quoted 10 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Local kunmaps have to be unmapped in the opposite order from which they were mapped. My recent change flipped the unmap order in the SKCIPHER_WALK_DIFF case. Adjust the mapping side to match.

This fixes a WARN_ON_ONCE that was triggered when running the crypto-self tests on a 32-bit kernel with CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP=y.

Quoted 5 lines
Fixes 95dbd711b1d8 ("crypto: skcipher - use the new scatterwalk functions")

---
crypto/skcipher.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)

Patch applied. 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