Skip to content

[ciqlts9_6] crypto: algif_aead - Revert to operating out-of-place#1162

Closed
ciq-kernel-automation[bot] wants to merge 1 commit into
ciqlts9_6from
{rnicolescu}_ciqlts9_6
Closed

[ciqlts9_6] crypto: algif_aead - Revert to operating out-of-place#1162
ciq-kernel-automation[bot] wants to merge 1 commit into
ciqlts9_6from
{rnicolescu}_ciqlts9_6

Conversation

@ciq-kernel-automation

Copy link
Copy Markdown

Summary

This PR has been automatically created after successful completion of all CI stages.

Commit Message(s)

crypto: algif_aead - Revert to operating out-of-place

jira VULN-181881
cve CVE-2026-31431
commit-author Herbert Xu <herbert@gondor.apana.org.au>
commit a664bf3d603dc3bdcf9ae47cc21e0daec706d7a5
upstream-diff |
	This kernel lacks upstream commits c1abe6f570aff ("crypto: af_alg:
	Use extract_iter_to_sg() to create scatterlists") and f2804d0eee8dd
	("crypto: algif_aead - use memcpy_sglist() instead of null
	skcipher"). As a result, there are two conflicts: the scatterlist
	table is located in a different member of `struct af_alg_sgl` and
	the null skcipher is used for copying between scatterlists instead
	of memcpy_sglist() (which is a helper that doesn't exist in this
	kernel version).

Test Results

✅ Build Stage

Architecture Build Time Total Time
x86_64 32m 53s 33m 45s
aarch64 19m 18s 20m 5s

✅ Boot Verification

✅ Kernel Selftests

Architecture Passed Failed Compared Against Status
x86_64 206 43 ciqlts9_6 ✅ No regressions
aarch64 153 46 ciqlts9_6 ✅ No regressions

✅ LTP Results

Architecture Passed Failed Compared Against Status
x86_64 1453 82 ciqlts9_6 ✅ No regressions
aarch64 1426 83 ciqlts9_6 ✅ No regressions

x86_64 newly passing:

  • binfmt_misc01 (PASS)
  • binfmt_misc02 (PASS)
  • cap_bounds (PASS)
  • check_keepcaps01 (PASS)
  • check_keepcaps02 (PASS)
  • check_keepcaps03 (PASS)
  • dio01 (PASS)
  • dio02 (PASS)
  • dio03 (PASS)
  • dio04 (PASS)
  • dio05 (PASS)
  • dio06 (PASS)
  • dio07 (PASS)
  • dio08 (PASS)
  • dio09 (PASS)
  • dio10 (PASS)
  • dio11 (PASS)
  • dio12 (PASS)
  • dio13 (PASS)
  • dio14 (PASS)
  • dio15 (PASS)
  • dio16 (PASS)
  • dio17 (PASS)
  • dio18 (PASS)
  • dio19 (PASS)
  • dio20 (PASS)
  • dio21 (PASS)
  • dio22 (PASS)
  • dio23 (PASS)
  • dio24 (PASS)
  • dio25 (PASS)
  • dio26 (PASS)
  • dio27 (PASS)
  • dio28 (PASS)
  • dio29 (PASS)
  • dio30 (PASS)
  • filecaps (PASS)
  • fs_di (PASS)
  • fs_fill (PASS)
  • fs_inod01 (PASS)
  • fs_perms01 (PASS)
  • fs_perms02 (PASS)
  • fs_perms03 (PASS)
  • fs_perms04 (PASS)
  • fs_perms05 (PASS)
  • fs_perms06 (PASS)
  • fs_perms07 (PASS)
  • fs_perms08 (PASS)
  • fs_perms09 (PASS)
  • fs_perms10 (PASS)
  • fs_perms11 (PASS)
  • fs_perms12 (PASS)
  • fs_perms13 (PASS)
  • fs_perms14 (PASS)
  • fs_perms15 (PASS)
  • fs_perms16 (PASS)
  • fs_perms17 (PASS)
  • fs_perms18 (PASS)
  • fs_racer (PASS)
  • ftest01 (PASS)
  • ftest02 (PASS)
  • ftest03 (PASS)
  • ftest04 (PASS)
  • ftest05 (PASS)
  • ftest06 (PASS)
  • ftest07 (PASS)
  • ftest08 (PASS)
  • gf01 (PASS)
  • gf02 (PASS)
  • gf03 (PASS)
  • gf04 (PASS)
  • gf05 (PASS)
  • gf06 (PASS)
  • gf07 (PASS)
  • gf08 (PASS)
  • gf09 (PASS)
  • gf10 (PASS)
  • gf11 (PASS)
  • gf12 (PASS)
  • gf13 (PASS)
  • gf14 (PASS)
  • gf15 (PASS)
  • gf16 (PASS)
  • gf17 (PASS)
  • gf18 (PASS)
  • gf19 (PASS)
  • gf20 (PASS)
  • gf21 (PASS)
  • gf22 (PASS)
  • gf23 (PASS)
  • gf24 (PASS)
  • gf25 (PASS)
  • gf26 (PASS)
  • gf27 (PASS)
  • gf28 (PASS)
  • gf29 (PASS)
  • gf30 (PASS)
  • inode01 (PASS)
  • inode02 (PASS)
  • iogen01 (PASS)
  • isofs (CONF)
  • lftest01 (PASS)
  • linker01 (PASS)
  • openfile01 (PASS)
  • proc01 (PASS)
  • quota_remount_test01 (CONF)
  • read_all_dev (PASS)
  • read_all_proc (PASS)
  • read_all_sys (PASS)
  • rwtest01 (PASS)
  • rwtest02 (PASS)
  • rwtest03 (PASS)
  • rwtest04 (PASS)
  • rwtest05 (PASS)
  • squashfs01 (CONF)
  • stream01 (PASS)
  • stream02 (PASS)
  • stream03 (PASS)
  • stream04 (PASS)
  • stream05 (PASS)
  • writetest01 (PASS)
    aarch64 newly passing:
  • binfmt_misc01 (PASS)
  • binfmt_misc02 (PASS)
  • cap_bounds (PASS)
  • check_keepcaps01 (PASS)
  • check_keepcaps02 (PASS)
  • check_keepcaps03 (PASS)
  • dio01 (PASS)
  • dio02 (PASS)
  • dio03 (PASS)
  • dio04 (PASS)
  • dio05 (PASS)
  • dio06 (PASS)
  • dio07 (PASS)
  • dio08 (PASS)
  • dio09 (PASS)
  • dio10 (PASS)
  • dio11 (PASS)
  • dio12 (PASS)
  • dio13 (PASS)
  • dio14 (PASS)
  • dio15 (PASS)
  • dio16 (PASS)
  • dio17 (PASS)
  • dio18 (PASS)
  • dio19 (PASS)
  • dio20 (PASS)
  • dio21 (PASS)
  • dio22 (PASS)
  • dio23 (PASS)
  • dio24 (PASS)
  • dio25 (PASS)
  • dio26 (PASS)
  • dio27 (PASS)
  • dio28 (PASS)
  • dio29 (PASS)
  • dio30 (PASS)
  • filecaps (PASS)
  • fs_di (PASS)
  • fs_fill (PASS)
  • fs_inod01 (PASS)
  • fs_perms01 (PASS)
  • fs_perms02 (PASS)
  • fs_perms03 (PASS)
  • fs_perms04 (PASS)
  • fs_perms05 (PASS)
  • fs_perms06 (PASS)
  • fs_perms07 (PASS)
  • fs_perms08 (PASS)
  • fs_perms09 (PASS)
  • fs_perms10 (PASS)
  • fs_perms11 (PASS)
  • fs_perms12 (PASS)
  • fs_perms13 (PASS)
  • fs_perms14 (PASS)
  • fs_perms15 (PASS)
  • fs_perms16 (PASS)
  • fs_perms17 (PASS)
  • fs_perms18 (PASS)
  • fs_racer (PASS)
  • ftest01 (PASS)
  • ftest02 (PASS)
  • ftest03 (PASS)
  • ftest04 (PASS)
  • ftest05 (PASS)
  • ftest06 (PASS)
  • ftest07 (PASS)
  • ftest08 (PASS)
  • gf01 (PASS)
  • gf02 (PASS)
  • gf03 (PASS)
  • gf04 (PASS)
  • gf05 (PASS)
  • gf06 (PASS)
  • gf07 (PASS)
  • gf08 (PASS)
  • gf09 (PASS)
  • gf10 (PASS)
  • gf11 (PASS)
  • gf12 (PASS)
  • gf13 (PASS)
  • gf14 (PASS)
  • gf15 (PASS)
  • gf16 (PASS)
  • gf17 (PASS)
  • gf18 (PASS)
  • gf19 (PASS)
  • gf20 (PASS)
  • gf21 (PASS)
  • gf22 (PASS)
  • gf23 (PASS)
  • gf24 (PASS)
  • gf25 (PASS)
  • gf26 (PASS)
  • gf27 (PASS)
  • gf28 (PASS)
  • gf29 (PASS)
  • gf30 (PASS)
  • inode01 (PASS)
  • inode02 (PASS)
  • iogen01 (PASS)
  • isofs (CONF)
  • lftest01 (PASS)
  • linker01 (PASS)
  • openfile01 (PASS)
  • proc01 (PASS)
  • quota_remount_test01 (CONF)
  • read_all_dev (PASS)
  • read_all_proc (PASS)
  • read_all_sys (PASS)
  • rwtest01 (PASS)
  • rwtest02 (PASS)
  • rwtest03 (PASS)
  • rwtest04 (PASS)
  • rwtest05 (PASS)
  • squashfs01 (CONF)
  • stream01 (PASS)
  • stream02 (PASS)
  • stream03 (PASS)
  • stream04 (PASS)
  • stream05 (PASS)
  • writetest01 (PASS)

🤖 This PR was automatically generated by GitHub Actions
Run ID: 25156153758

jira VULN-181881
cve CVE-2026-31431
commit-author Herbert Xu <herbert@gondor.apana.org.au>
commit a664bf3
upstream-diff |
	This kernel lacks upstream commits c1abe6f ("crypto: af_alg:
	Use extract_iter_to_sg() to create scatterlists") and f2804d0
	("crypto: algif_aead - use memcpy_sglist() instead of null
	skcipher"). As a result, there are two conflicts: the scatterlist
	table is located in a different member of `struct af_alg_sgl` and
	the null skcipher is used for copying between scatterlists instead
	of memcpy_sglist() (which is a helper that doesn't exist in this
	kernel version).

	The scatterlist table discrepancy is resolved by using the correct
	member of `struct af_alg_sgl`.

	The upstream patch's usage of memcpy_sglist() is replaced by a call
	to the null skcipher to perform the scatterlist copy instead.

This mostly reverts commit 72548b0 except for the copying of
the associated data.

There is no benefit in operating in-place in algif_aead since the
source and destination come from different mappings.  Get rid of
all the complexity added for in-place operation and just copy the
AD directly.

Fixes: 72548b0 ("crypto: algif_aead - copy AAD from src to dst")
	Reported-by: Taeyang Lee <0wn@theori.io>
	Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit a664bf3)
	Signed-off-by: Sultan Alsawaf <sultan@ciq.com>
@ciq-kernel-automation ciq-kernel-automation Bot added the created-by-kernelci Tag PRs that were automatically created when a user branch was pushed to the repo (kernelCI) label Apr 30, 2026
@github-actions

Copy link
Copy Markdown

🤖 Validation Checks In Progress Workflow run: https://github.com/ctrliq/kernel-src-tree/actions/runs/25165768486

@github-actions

Copy link
Copy Markdown

🔍 Interdiff Analysis

  • ⚠️ PR commit 1b6558cabba (crypto: algif_aead - Revert to operating out-of-place) → upstream a664bf3d603d
    Differences found:
================================================================================
*    DELTA DIFFERENCES - code changes that differ between the patches          *
================================================================================

--- b/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -207,13 +208,72 @@
 	/* Use the RX SGL as source (and destination) for crypto op. */
 	rsgl_src = areq->first_rsgl.sgl.sg;
 
-	err = crypto_aead_copy_sgl(null_tfm, tsgl_src, rsgl_src,
-				   ctx->aead_assoclen);
-	if (err)
-		goto free;
+	if (ctx->enc) {
+		/*
+		 * Encryption operation - The in-place cipher operation is
+		 * achieved by the following operation:
+		 *
+		 * TX SGL: AAD || PT
+		 *	    |	   |
+		 *	    | copy |
+		 *	    v	   v
+		 * RX SGL: AAD || PT || Tag
+		 */
+		err = crypto_aead_copy_sgl(null_tfm, tsgl_src,
+					   areq->first_rsgl.sgl.sg, processed);
+		if (err)
+			goto free;
+		af_alg_pull_tsgl(sk, processed, NULL, 0);
+	} else {
+		/*
+		 * Decryption operation - To achieve an in-place cipher
+		 * operation, the following  SGL structure is used:
+		 *
+		 * TX SGL: AAD || CT || Tag
+		 *	    |	   |	 ^
+		 *	    | copy |	 | Create SGL link.
+		 *	    v	   v	 |
+		 * RX SGL: AAD || CT ----+
+		 */
+
+		 /* Copy AAD || CT to RX SGL buffer for in-place operation. */
+		err = crypto_aead_copy_sgl(null_tfm, tsgl_src,
+					   areq->first_rsgl.sgl.sg, outlen);
+		if (err)
+			goto free;
+
+		/* Create TX SGL for tag and chain it to RX SGL. */
+		areq->tsgl_entries = af_alg_count_tsgl(sk, processed,
+						       processed - as);
+		if (!areq->tsgl_entries)
+			areq->tsgl_entries = 1;
+		areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),
+							 areq->tsgl_entries),
+					  GFP_KERNEL);
+		if (!areq->tsgl) {
+			err = -ENOMEM;
+			goto free;
+		}
+		sg_init_table(areq->tsgl, areq->tsgl_entries);
+
+		/* Release TX SGL, except for tag data and reassign tag data. */
+		af_alg_pull_tsgl(sk, processed, areq->tsgl, processed - as);
+
+		/* chain the areq TX SGL holding the tag with RX SGL */
+		if (usedpages) {
+			/* RX SGL present */
+			struct af_alg_sgl *sgl_prev = &areq->last_rsgl->sgl;
+
+			sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1);
+			sg_chain(sgl_prev->sg, sgl_prev->npages + 1,
+				 areq->tsgl);
+		} else
+			/* no RX SGL present (e.g. authentication only) */
+			rsgl_src = areq->tsgl;
+	}
 
 	/* Initialize the crypto operation */
-	aead_request_set_crypt(&areq->cra_u.aead_req, tsgl_src,
+	aead_request_set_crypt(&areq->cra_u.aead_req, rsgl_src,
 			       areq->first_rsgl.sgl.sg, used, ctx->iv);
 	aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen);
 	aead_request_set_tfm(&areq->cra_u.aead_req, tfm);

################################################################################
!    REJECTED PATCH2 HUNKS - could not be compared; manual review needed       !
################################################################################

--- b/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -26,7 +26,6 @@
 #include <crypto/internal/aead.h>
 #include <crypto/scatterwalk.h>
 #include <crypto/if_alg.h>
-#include <crypto/skcipher.h>
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/kernel.h>
@@ -72,7 +71,7 @@
 	struct alg_sock *pask = alg_sk(psk);
 	struct af_alg_ctx *ctx = ask->private;
 	struct crypto_aead *tfm = pask->private;
-	unsigned int i, as = crypto_aead_authsize(tfm);
+	unsigned int as = crypto_aead_authsize(tfm);
 	struct af_alg_async_req *areq;
 	struct af_alg_tsgl *tsgl, *tmp;
 	struct scatterlist *rsgl_src, *tsgl_src = NULL;
@@ -182,64 +177,7 @@
 	/* Use the RX SGL as source (and destination) for crypto op. */
 	rsgl_src = areq->first_rsgl.sgl.sgt.sgl;
 
-	if (ctx->enc) {
-		/*
-		 * Encryption operation - The in-place cipher operation is
-		 * achieved by the following operation:
-		 *
-		 * TX SGL: AAD || PT
-		 *	    |	   |
-		 *	    | copy |
-		 *	    v	   v
-		 * RX SGL: AAD || PT || Tag
-		 */
-		memcpy_sglist(areq->first_rsgl.sgl.sgt.sgl, tsgl_src,
-			      processed);
-		af_alg_pull_tsgl(sk, processed, NULL, 0);
-	} else {
-		/*
-		 * Decryption operation - To achieve an in-place cipher
-		 * operation, the following  SGL structure is used:
-		 *
-		 * TX SGL: AAD || CT || Tag
-		 *	    |	   |	 ^
-		 *	    | copy |	 | Create SGL link.
-		 *	    v	   v	 |
-		 * RX SGL: AAD || CT ----+
-		 */
-
-		/* Copy AAD || CT to RX SGL buffer for in-place operation. */
-		memcpy_sglist(areq->first_rsgl.sgl.sgt.sgl, tsgl_src, outlen);
-
-		/* Create TX SGL for tag and chain it to RX SGL. */
-		areq->tsgl_entries = af_alg_count_tsgl(sk, processed,
-						       processed - as);
-		if (!areq->tsgl_entries)
-			areq->tsgl_entries = 1;
-		areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),
-							 areq->tsgl_entries),
-					  GFP_KERNEL);
-		if (!areq->tsgl) {
-			err = -ENOMEM;
-			goto free;
-		}
-		sg_init_table(areq->tsgl, areq->tsgl_entries);
-
-		/* Release TX SGL, except for tag data and reassign tag data. */
-		af_alg_pull_tsgl(sk, processed, areq->tsgl, processed - as);
-
-		/* chain the areq TX SGL holding the tag with RX SGL */
-		if (usedpages) {
-			/* RX SGL present */
-			struct af_alg_sgl *sgl_prev = &areq->last_rsgl->sgl;
-			struct scatterlist *sg = sgl_prev->sgt.sgl;
-
-			sg_unmark_end(sg + sgl_prev->sgt.nents - 1);
-			sg_chain(sg, sgl_prev->sgt.nents + 1, areq->tsgl);
-		} else
-			/* no RX SGL present (e.g. authentication only) */
-			rsgl_src = areq->tsgl;
-	}
+	memcpy_sglist(rsgl_src, tsgl_src, ctx->aead_assoclen);
 
 	/* Initialize the crypto operation */
 	aead_request_set_crypt(&areq->cra_u.aead_req, rsgl_src,
@@ -242,7 +180,7 @@
 	}
 
 	/* Initialize the crypto operation */
-	aead_request_set_crypt(&areq->cra_u.aead_req, rsgl_src,
+	aead_request_set_crypt(&areq->cra_u.aead_req, tsgl_src,
 			       areq->first_rsgl.sgl.sgt.sgl, used, ctx->iv);
 	aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen);
 	aead_request_set_tfm(&areq->cra_u.aead_req, tfm);

================================================================================
*    CONTEXT DIFFERENCES - surrounding code differences between the patches    *
================================================================================

--- b/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -28,5 +28,4 @@
 #include <crypto/if_alg.h>
 #include <crypto/skcipher.h>
-#include <crypto/null.h>
 #include <linux/init.h>
 #include <linux/list.h>
@@ -69,6 +69,6 @@
-	struct aead_tfm *aeadc = pask->private;
-	struct crypto_aead *tfm = aeadc->aead;
-	struct crypto_sync_skcipher *null_tfm = aeadc->null_tfm;
+	struct alg_sock *pask = alg_sk(psk);
+	struct af_alg_ctx *ctx = ask->private;
+	struct crypto_aead *tfm = pask->private;
 	unsigned int i, as = crypto_aead_authsize(tfm);
 	struct af_alg_async_req *areq;
 	struct af_alg_tsgl *tsgl, *tmp;
@@ -210,7 +184,7 @@
 	 */
 
 	/* Use the RX SGL as source (and destination) for crypto op. */
-	rsgl_src = areq->first_rsgl.sgl.sg;
+	rsgl_src = areq->first_rsgl.sgl.sgt.sgl;
 
 	if (ctx->enc) {
 		/*
@@ -223,10 +197,8 @@
 		 *	    v	   v
 		 * RX SGL: AAD || PT || Tag
 		 */
-		err = crypto_aead_copy_sgl(null_tfm, tsgl_src,
-					   areq->first_rsgl.sgl.sg, processed);
-		if (err)
-			goto free;
+		memcpy_sglist(areq->first_rsgl.sgl.sgt.sgl, tsgl_src,
+			      processed);
 		af_alg_pull_tsgl(sk, processed, NULL, 0);
 	} else {
 		/*
@@ -240,11 +212,8 @@
 		 * RX SGL: AAD || CT ----+
 		 */
 
-		 /* Copy AAD || CT to RX SGL buffer for in-place operation. */
-		err = crypto_aead_copy_sgl(null_tfm, tsgl_src,
-					   areq->first_rsgl.sgl.sg, outlen);
-		if (err)
-			goto free;
+		/* Copy AAD || CT to RX SGL buffer for in-place operation. */
+		memcpy_sglist(areq->first_rsgl.sgl.sgt.sgl, tsgl_src, outlen);
 
 		/* Create TX SGL for tag and chain it to RX SGL. */
 		areq->tsgl_entries = af_alg_count_tsgl(sk, processed,
@@ -267,10 +236,10 @@
 		if (usedpages) {
 			/* RX SGL present */
 			struct af_alg_sgl *sgl_prev = &areq->last_rsgl->sgl;
+			struct scatterlist *sg = sgl_prev->sgt.sgl;
 
-			sg_unmark_end(sgl_prev->sg + sgl_prev->npages - 1);
-			sg_chain(sgl_prev->sg, sgl_prev->npages + 1,
-				 areq->tsgl);
+			sg_unmark_end(sg + sgl_prev->sgt.nents - 1);
+			sg_chain(sg, sgl_prev->sgt.nents + 1, areq->tsgl);
 		} else
 			/* no RX SGL present (e.g. authentication only) */
 			rsgl_src = areq->tsgl;
@@ -279,5 +248,5 @@
 	/* Initialize the crypto operation */
 	aead_request_set_crypt(&areq->cra_u.aead_req, rsgl_src,
-			       areq->first_rsgl.sgl.sg, used, ctx->iv);
+			       areq->first_rsgl.sgl.sgt.sgl, used, ctx->iv);
 	aead_request_set_ad(&areq->cra_u.aead_req, ctx->aead_assoclen);
 	aead_request_set_tfm(&areq->cra_u.aead_req, tfm);
@@ -478,4 +447,4 @@
-	struct crypto_aead *tfm = aeadc->aead;
+	struct crypto_aead *tfm = pask->private;
 	unsigned int ivlen = crypto_aead_ivsize(tfm);
 
 	af_alg_pull_tsgl(sk, ctx->used, NULL, 0);
--- b/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -310,7 +359,7 @@
 	struct alg_sock *pask = alg_sk(psk);
 	struct crypto_skcipher *tfm = pask->private;
 
 	af_alg_pull_tsgl(sk, ctx->used, NULL, 0);
 	sock_kzfree_s(sk, ctx->iv, crypto_skcipher_ivsize(tfm));
-	sock_kfree_s(sk, ctx, ctx->len);
-	af_alg_release_parent(sk);
+	if (ctx->state)
+		sock_kzfree_s(sk, ctx->state, crypto_skcipher_statesize(tfm));

This is an automated interdiff check for backported commits.

@github-actions

Copy link
Copy Markdown

Validation checks completed successfully View full results: https://github.com/ctrliq/kernel-src-tree/actions/runs/25165768486

@roxanan1996

Copy link
Copy Markdown
Contributor

Closing this because another PR exists.

@roxanan1996 roxanan1996 deleted the {rnicolescu}_ciqlts9_6 branch June 8, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by-kernelci Tag PRs that were automatically created when a user branch was pushed to the repo (kernelCI)

Development

Successfully merging this pull request may close these issues.

2 participants