FAILED: patch "[PATCH] s390/crypto: Fix skcipher_walk return code handling in" failed to apply to 5.10-stable tree
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 15fa028589c3a2545f0bff355eff06d5844196bf
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026091622-vice-vendor-ddbe@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 15fa028589c3a2545f0bff355eff06d5844196bf Mon Sep 17 00:00:00 2001
From: Harald Freudenberger <[email protected]>
Date: Mon, 31 Aug 2026 10:37:33 +0200
Subject: [PATCH] s390/crypto: Fix skcipher_walk return code handling in
aes_s390
The return codes from skcipher_walk_virt() were not properly checked before entering the processing loops in ecb_aes_crypt() and ctr_aes_crypt(). If skcipher_walk_virt() fails, the walk structure may be in an undefined state, and attempting to process data could lead to incorrect behavior or accessing uninitialized memory.
Add proper return code checking to ensure correct handling of the walk initialization and walk advance and eventually return to the caller with that return code.
arch/s390/crypto/aes_s390.c +6 -6
@@ -129,7 +129,7 @@ static int ecb_aes_crypt(struct skcipher_request *req, unsigned long modifier)return fallback_skcipher_crypt (sctx, req, modifier); ret =skcipher_walk_virt (&walk, req, false); -while ((nbytes = walk.nbytes) !=0 ) { +while (!ret && ((nbytes = walk.nbytes) !=0 )) {/* only use complete blocks */ n = nbytes & ~(AES_BLOCK_SIZE -1 ); cpacf_km(sctx->fc | modifier, sctx->key,
@@ -233,7 +233,7 @@ static int cbc_aes_crypt(struct skcipher_request *req, unsigned long modifier)return ret;memcpy (param.iv, walk.iv,AES_BLOCK_SIZE );memcpy (param.key, sctx->key, sctx->key_len); -while ((nbytes = walk.nbytes) !=0 ) { +while (!ret && ((nbytes = walk.nbytes) !=0 )) {/* only use complete blocks */ n = nbytes & ~(AES_BLOCK_SIZE -1 ); cpacf_kmc(sctx->fc | modifier, ¶m,
@@ -359,7 +359,7 @@ static int xts_aes_crypt(struct skcipher_request *req, unsigned long modifier)memcpy (xts_param.key + offset, xts_ctx->key, xts_ctx->key_len);memcpy (xts_param.init, pcc_param.xts,16 ); -while ((nbytes = walk.nbytes) !=0 ) { +while (!ret && ((nbytes = walk.nbytes) !=0 )) {/* only use complete blocks */ n = nbytes & ~(AES_BLOCK_SIZE -1 ); cpacf_km(xts_ctx->fc | modifier, xts_param.key + offset,
@@ -487,7 +487,7 @@ static int fullxts_aes_crypt(struct skcipher_request *req, unsigned long modifimemcpy (fxts_param.tweak, req->iv,AES_BLOCK_SIZE ); fxts_param.nap[0 ] =0x01 ;/* initial alpha power (1, little-endian) */ -while ((nbytes = walk.nbytes) !=0 ) { +while (!ret && ((nbytes = walk.nbytes) !=0 )) {/* only use complete blocks */ n = nbytes & ~(AES_BLOCK_SIZE -1 ); cpacf_km(xts_ctx->fc | modifier, fxts_param.key + offset,
@@ -577,7 +577,7 @@ static int ctr_aes_crypt(struct skcipher_request *req) locked =mutex_trylock (&ctrblk_lock); ret =skcipher_walk_virt (&walk, req, false); -while ((nbytes = walk.nbytes) >=AES_BLOCK_SIZE ) { +while (!ret && ((nbytes = walk.nbytes) >=AES_BLOCK_SIZE )) { n =AES_BLOCK_SIZE ;if (nbytes >=2 *AES_BLOCK_SIZE && locked)
@@ -596,7 +596,7 @@ static int ctr_aes_crypt(struct skcipher_request *req)/* * final block may be < AES_BLOCK_SIZE, copy only nbytes */ -if (nbytes) { +if (!ret && nbytes) {memset (buf,0 ,AES_BLOCK_SIZE );memcpy (buf, walk.src.virt.addr, nbytes); cpacf_kmctr(sctx->fc, sctx->key, buf, buf,