crypto/af_alg09: Test CVE-2026-52972
PATCH 1/1 crypto/af_alg09: Test CVE-2026-52972
From: Stephen Bertram <[email protected]>
Add a regression test for the missing cap on the AEAD associated data length. Kernel commit e4c06479d705 ("crypto: af_alg - Cap AEAD AD length to 0x80000000") rejects ALG_SET_AEAD_ASSOCLEN values greater than or equal to 0x80000000; without it af_alg_sendmsg() accepts any 32-bit value.
The test opens an AF_ALG AEAD request socket, sets ALG_OP_DECRYPT and ALG_SET_AEAD_ASSOCLEN to 0x7fffffff, which must be accepted, and to 0x80000000 and 0xffffffff, which must fail with EINVAL. It does not call recvmsg(), so the test only depends on the control-message validation.
--- runtest/crypto | 1 + testcases/kernel/crypto/.gitignore | 1 + testcases/kernel/crypto/af_alg09.c | 131 +++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 testcases/kernel/crypto/af_alg09.c
runtest/crypto +1 -0
@@ -6,6 +6,7 @@ af_alg05 af_alg05 af_alg06 af_alg06 af_alg07 af_alg07 af_alg08 af_alg08 +af_alg09 af_alg09 pcrypt_aead01 pcrypt_aead01 crypto_user01 crypto_user01 crypto_user02 crypto_user02
testcases/kernel/crypto/.gitignore +1 -0
@@ -6,6 +6,7 @@ af_alg05 af_alg06 af_alg07 af_alg08 +af_alg09 pcrypt_aead01 crypto_user01 crypto_user02
testcases/kernel/crypto/af_alg09.c new file +131 -0
131 lines not on this page · raw message
Signature · 5 lines
2.55.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Stephen,
runtest/crypto af_alg05 af_alg05 · line 9
Quoted 11 lines · Stephen Bertram
crypto/af_alg09: Test CVE-2026-52972runtest/crypto +1
-0@@ -6,6 +6,7 @@ af_alg05 af_alg05 af_alg06 af_alg06 af_alg07 af_alg07 af_alg08 af_alg08 +af_alg09 af_alg09
Please also add a "cve-2026-52972 af_alg09" entry to runtest/cve, matching the other CVE regression tests in this directory.
runtest/crypto af_alg05 af_alg05
Quoted 4 lines
runtest/crypto +4
-0+/*\ + * Test for CVE-2026-52972. + * + * [Description]
Remove the deprecated [Description] header from the documentation comment block.
Quoted 33 lines
runtest/crypto +33
-0+static void run(void) +{ + static const uint32_t assoclens[] = { + 0x7fffffff, + ASSOCLEN_LIMIT, + 0xffffffff, + }; + size_t i; + int reqfd; + + for (i = 0; i < ARRAY_SIZE(assoclens); i++) { + reqfd = tst_alg_accept(algfd); + + TEST(send_assoclen(reqfd, assoclens[i])); + + if (assoclens[i] < ASSOCLEN_LIMIT) { + if (TST_RET == SEND_SIZE) { + tst_res(TPASS, "sendmsg() accepted assoclen=%#x", + assoclens[i]); + } else if (TST_RET < 0) { + tst_res(TFAIL | TTERRNO, + "sendmsg() failed for valid assoclen=%#x", + assoclens[i]); + } else { + tst_res(TFAIL, + "sendmsg() returned %ld for valid assoclen=%#x", + TST_RET, assoclens[i]); + } + } else if (TST_RET >= 0) { + tst_res(TFAIL, "sendmsg() accepted assoclen=%#x", + assoclens[i]); + } else if (TST_ERR != EINVAL) { + tst_res(TFAIL | TTERRNO,
runtest/crypto
Quoted 10 lines
runtest/crypto +10
-0+ "sendmsg() failed for assoclen=%#x with unexpected error", + assoclens[i]); + } else { + tst_res(TPASS, "sendmsg() rejected assoclen=%#x with EINVAL", + assoclens[i]); + } + + SAFE_CLOSE(reqfd); + } +}
Move assoclens[] to file scope and use .test = run with .tcnt = ARRAY_SIZE(assoclens) in struct tst_test instead of looping inside .test_all. Replace the manual TEST() and if/else result checks with TST_EXP_VAL(send_assoclen(reqfd, assoclens[i]), SEND_SIZE, ...) for the valid length and TST_EXP_FAIL2(send_assoclen(reqfd, assoclens[i]), EINVAL, ...) for the rejected lengths.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 crypto/af_alg09: Test CVE-2026-52972
In reply to Stephen Bertram via ltpFrom: Stephen Bertram <[email protected]>
Add a regression test for the missing cap on the AEAD associated data length. Kernel commit e4c06479d705 ("crypto: af_alg - Cap AEAD AD length to 0x80000000") rejects ALG_SET_AEAD_ASSOCLEN values greater than or equal to 0x80000000; without it af_alg_sendmsg() accepts any 32-bit value.
The test opens an AF_ALG AEAD request socket, sets ALG_OP_DECRYPT and ALG_SET_AEAD_ASSOCLEN to 0x7fffffff, which must be accepted, and to 0x80000000 and 0xffffffff, which must fail with EINVAL. It does not call recvmsg(), so the test only depends on the control-message validation.
--- runtest/crypto | 1 + runtest/cve | 1 + testcases/kernel/crypto/.gitignore | 1 + testcases/kernel/crypto/af_alg09.c | 107 +++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 testcases/kernel/crypto/af_alg09.c
runtest/crypto +1 -0
@@ -6,6 +6,7 @@ af_alg05 af_alg05 af_alg06 af_alg06 af_alg07 af_alg07 af_alg08 af_alg08 +af_alg09 af_alg09 pcrypt_aead01 pcrypt_aead01 crypto_user01 crypto_user01 crypto_user02 crypto_user02
runtest/cve +1 -0
@@ -89,6 +89,7 @@ cve-2023-0461 setsockopt10 cve-2023-31248 nft02 cve-2023-52879 fanotify25 cve-2026-43499 ghostlock +cve-2026-52972 af_alg09 cve-2026-53362 setsockopt11 cve-2026-64600 refluxfs cve-2026-99999 pwnescape
testcases/kernel/crypto/.gitignore +1 -0
@@ -6,6 +6,7 @@ af_alg05 af_alg06 af_alg07 af_alg08 +af_alg09 pcrypt_aead01 crypto_user01 crypto_user02
testcases/kernel/crypto/af_alg09.c new file +107 -0
107 lines not on this page · raw message
Signature · 5 lines
2.56.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Stephen,
Quoted 1 line · Stephen Bertram
crypto/af_alg09: Test CVE-2026-52972
Verdict - Reviewed
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 8 lines · Stephen Bertram via ltp
From: Stephen Bertram <[email protected]>
Add a regression test for the missing cap on the AEAD associated data length. Kernel commit
e4c06479d705("crypto:af_alg- Cap AEAD AD length to0x80000000") rejectsALG_SET_AEAD_ASSOCLENvalues greater than or equal to0x80000000; without itaf_alg_sendmsg()accepts any 32-bit value.
Quoted 7 lines
The test opens an
AF_ALGAEAD request socket, setsALG_OP_DECRYPTandALG_SET_AEAD_ASSOCLENto0x7fffffff, which must be accepted, and to0x80000000and0xffffffff, which must fail with EINVAL. It does not callrecvmsg(), so the test only depends on the control-message validation.Signed-off-by Stephen Bertram <[email protected]>
e4c06479d705 (fixed, 7.1.0-rc2):
3/3 TPASS: 0x7fffffff accepted; 0x80000000 and 0xffffffff → EINVAL
ffdd2bc37895 (before the fix, 7.1.0-rc2):
1 TPASS (0x7fffffff), 2 TFAIL: 0x80000000 and 0xffffffff succeeded instead of EINVAL
20eef29b7c84 (current mainline, 7.4.0-rc3):lib/tst_af_alg.c:42: TCONF: kernel doesn't support aead algorithm 'gcm(aes)'
20eef29b7c84 (current mainline, 7.4.0-rc3) with /proc/sys/crypto/af_alg_restrict set to 0:
3/3 TPASS: 0x7fffffff accepted; 0x80000000 and 0xffffffff → EINVAL
Perhaps add a .save_restore entry for /proc/sys/crypto/af_alg_restrict ?
Quoted 157 lines
--- runtest/crypto | 1 + runtest/cve | 1 + testcases/kernel/crypto/.gitignore | 1 + testcases/kernel/crypto/af_alg09.c | 107 +++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 testcases/kernel/crypto/af_alg09.cruntest/crypto +1
-0@@ -6,6 +6,7 @@ af_alg05 af_alg05 af_alg06 af_alg06 af_alg07 af_alg07 af_alg08 af_alg08 +af_alg09 af_alg09 pcrypt_aead01 pcrypt_aead01 crypto_user01 crypto_user01 crypto_user02 crypto_user02runtest/cve +1
-0@@ -89,6 +89,7 @@ cve-2023-0461 setsockopt10 cve-2023-31248 nft02 cve-2023-52879 fanotify25 cve-2026-43499 ghostlock +cve-2026-52972 af_alg09 cve-2026-53362 setsockopt11 cve-2026-64600 refluxfs cve-2026-99999 pwnescapetestcases/kernel/crypto/.gitignore +1
-0@@ -6,6 +6,7 @@ af_alg05 af_alg06 af_alg07 af_alg08 +af_alg09 pcrypt_aead01 crypto_user01 crypto_user02testcases/kernel/crypto/af_alg09.c new file +107
-0@@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2026 Red Hat, Inc. +*/ + +/*\ +* Test for CVE-2026-52972. +* +* Verify that the AF_ALG AEAD interface rejects an associated data length +* greater than or equal to 0x80000000 with EINVAL. +* +* Before kernel commit e4c06479d705 ("crypto: af_alg - Cap AEAD AD length to +* 0x80000000") af_alg_sendmsg() accepted any 32-bit ALG_SET_AEAD_ASSOCLEN +* value. +*/ + +#include "tst_test.h" +#include "tst_af_alg.h" +#include "lapi/socket.h" + +#define ASSOCLEN_LIMIT 0x80000000U +#define SEND_SIZE 16 + +static int algfd =-1 ; + +/* +* Send SEND_SIZE bytes with ALG_SET_AEAD_ASSOCLEN set to assoclen and +* ALG_SET_OP set to ALG_OP_DECRYPT. Return the sendmsg() return value, with +* errno from sendmsg() preserved. +*/ +static ssize_t send_assoclen (int reqfd,uint32_t assoclen) +{ +char data[SEND_SIZE ] = {0 }; +char control[CMSG_SPACE (sizeof (uint32_t )) *2 ]; +struct iovec iov = { + .iov_base = data, + .iov_len =sizeof (data), + }; +struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen =1 , + .msg_control = control, + .msg_controllen =sizeof (control), + }; +struct cmsghdr *cmsg; +uint32_t op =ALG_OP_DECRYPT ; + +memset (control,0 ,sizeof (control)); + + cmsg =CMSG_FIRSTHDR (&msg); + cmsg->cmsg_level =SOL_ALG ; + cmsg->cmsg_type =ALG_SET_OP ; + cmsg->cmsg_len =CMSG_LEN (sizeof (op)); +memcpy (CMSG_DATA (cmsg), &op,sizeof (op)); + + cmsg =CMSG_NXTHDR (&msg, cmsg); + cmsg->cmsg_level =SOL_ALG ; + cmsg->cmsg_type =ALG_SET_AEAD_ASSOCLEN ; + cmsg->cmsg_len =CMSG_LEN (sizeof (assoclen)); +memcpy (CMSG_DATA (cmsg), &assoclen,sizeof (assoclen)); + +return sendmsg (reqfd, &msg,0 ); +} + +static const uint32_t assoclens[] = { +0x7fffffff , +ASSOCLEN_LIMIT , +0xffffffff , +}; + +static void run (unsigned int i) +{ +int reqfd =tst_alg_accept (algfd); + +if (assoclens[i] <ASSOCLEN_LIMIT ) { +TST_EXP_VAL (send_assoclen (reqfd, assoclens[i]),SEND_SIZE , +"assoclen=%#x" , assoclens[i]); + }else { +TST_EXP_FAIL2 (send_assoclen (reqfd, assoclens[i]),EINVAL , +"assoclen=%#x" , assoclens[i]); + } + +SAFE_CLOSE (reqfd); +} + +static void setup (void ) +{ + algfd =tst_alg_setup ("aead" ,"gcm(aes)" ,NULL ,16 ); +} + +static void cleanup (void ) +{ +if (algfd !=-1 ) +SAFE_CLOSE (algfd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test = run, + .tcnt =ARRAY_SIZE (assoclens), + .tags = (const struct tst_tag []) { + {"linux-git" ,"e4c06479d7059888adf2f22bc1ebcf053bf691a2" }, + {"CVE" ,"2026-52972" }, + {} + }, +};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/1 crypto/af_alg09: Test CVE-2026-52972
In reply to Stephen Bertram via ltpFrom: Stephen Bertram <[email protected]>
Add a regression test for the missing cap on the AEAD associated data length. Kernel commit e4c06479d705 ("crypto: af_alg - Cap AEAD AD length to 0x80000000") rejects ALG_SET_AEAD_ASSOCLEN values greater than or equal to 0x80000000; without it af_alg_sendmsg() accepts any 32-bit value.
The test opens an AF_ALG AEAD request socket, sets ALG_OP_DECRYPT and ALG_SET_AEAD_ASSOCLEN to 0x7fffffff, which must be accepted, and to 0x80000000 and 0xffffffff, which must fail with EINVAL. It does not call recvmsg(), so the test only depends on the control-message validation.
Since Linux 7.3, /proc/sys/crypto/af_alg_restrict defaults to 1 and bind() of gcm(aes) fails with ENOENT. When that file exists and is writable, the test sets it to 0 for the run and restores the previous value.
--- runtest/crypto | 1 + runtest/cve | 1 + testcases/kernel/crypto/.gitignore | 1 + testcases/kernel/crypto/af_alg09.c | 112 +++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 testcases/kernel/crypto/af_alg09.c
runtest/crypto +1 -0
@@ -6,6 +6,7 @@ af_alg05 af_alg05 af_alg06 af_alg06 af_alg07 af_alg07 af_alg08 af_alg08 +af_alg09 af_alg09 pcrypt_aead01 pcrypt_aead01 crypto_user01 crypto_user01 crypto_user02 crypto_user02
runtest/cve +1 -0
@@ -89,6 +89,7 @@ cve-2023-0461 setsockopt10 cve-2023-31248 nft02 cve-2023-52879 fanotify25 cve-2026-43499 ghostlock +cve-2026-52972 af_alg09 cve-2026-53362 setsockopt11 cve-2026-64600 refluxfs cve-2026-99999 pwnescape
testcases/kernel/crypto/.gitignore +1 -0
@@ -6,6 +6,7 @@ af_alg05 af_alg06 af_alg07 af_alg08 +af_alg09 pcrypt_aead01 crypto_user01 crypto_user02
testcases/kernel/crypto/af_alg09.c new file +112 -0
112 lines not on this page · raw message
Signature · 5 lines
2.56.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Stephen,
Quoted 1 line · Stephen Bertram
crypto/af_alg09: Test CVE-2026-52972
Verdict - Reviewed
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 164 lines · Stephen Bertram via ltp
From: Stephen Bertram <[email protected]>
Add a regression test for the missing cap on the AEAD associated data length. Kernel commit
e4c06479d705("crypto:af_alg- Cap AEAD AD length to0x80000000") rejectsALG_SET_AEAD_ASSOCLENvalues greater than or equal to0x80000000; without itaf_alg_sendmsg()accepts any 32-bit value.The test opens an
AF_ALGAEAD request socket, setsALG_OP_DECRYPTandALG_SET_AEAD_ASSOCLENto0x7fffffff, which must be accepted, and to0x80000000and0xffffffff, which must fail with EINVAL. It does not callrecvmsg(), so the test only depends on the control-message validation.Since Linux 7.3,
/proc/sys/crypto/af_alg_restrictdefaults to 1 andbind()of gcm(aes) fails with ENOENT. When that file exists and is writable, the test sets it to 0 for the run and restores the previous value.Assisted-by Cursor:Grok-4.7Signed-off-by Stephen Bertram <[email protected]>--- runtest/crypto | 1 + runtest/cve | 1 + testcases/kernel/crypto/.gitignore | 1 + testcases/kernel/crypto/af_alg09.c | 112 +++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 testcases/kernel/crypto/af_alg09.cruntest/crypto +1
-0@@ -6,6 +6,7 @@ af_alg05 af_alg05 af_alg06 af_alg06 af_alg07 af_alg07 af_alg08 af_alg08 +af_alg09 af_alg09 pcrypt_aead01 pcrypt_aead01 crypto_user01 crypto_user01 crypto_user02 crypto_user02runtest/cve +1
-0@@ -89,6 +89,7 @@ cve-2023-0461 setsockopt10 cve-2023-31248 nft02 cve-2023-52879 fanotify25 cve-2026-43499 ghostlock +cve-2026-52972 af_alg09 cve-2026-53362 setsockopt11 cve-2026-64600 refluxfs cve-2026-99999 pwnescapetestcases/kernel/crypto/.gitignore +1
-0@@ -6,6 +6,7 @@ af_alg05 af_alg06 af_alg07 af_alg08 +af_alg09 pcrypt_aead01 crypto_user01 crypto_user02testcases/kernel/crypto/af_alg09.c new file +94
-0@@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2026 Red Hat, Inc. +*/ + +/*\ +* Test for CVE-2026-52972. +* +* Verify that the AF_ALG AEAD interface rejects an associated data length +* greater than or equal to 0x80000000 with EINVAL. +* +* Before kernel commit e4c06479d705 ("crypto: af_alg - Cap AEAD AD length to +* 0x80000000") af_alg_sendmsg() accepted any 32-bit ALG_SET_AEAD_ASSOCLEN +* value. +*/ + +#include "tst_test.h" +#include "tst_af_alg.h" +#include "lapi/socket.h" + +#define ASSOCLEN_LIMIT 0x80000000U +#define SEND_SIZE 16 + +static int algfd =-1 ; + +/* +* Send SEND_SIZE bytes with ALG_SET_AEAD_ASSOCLEN set to assoclen and +* ALG_SET_OP set to ALG_OP_DECRYPT. Return the sendmsg() return value, with +* errno from sendmsg() preserved. +*/ +static ssize_t send_assoclen (int reqfd,uint32_t assoclen) +{ +char data[SEND_SIZE ] = {0 }; +char control[CMSG_SPACE (sizeof (uint32_t )) *2 ]; +struct iovec iov = { + .iov_base = data, + .iov_len =sizeof (data), + }; +struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen =1 , + .msg_control = control, + .msg_controllen =sizeof (control), + }; +struct cmsghdr *cmsg; +uint32_t op =ALG_OP_DECRYPT ; + +memset (control,0 ,sizeof (control)); + + cmsg =CMSG_FIRSTHDR (&msg); + cmsg->cmsg_level =SOL_ALG ; + cmsg->cmsg_type =ALG_SET_OP ; + cmsg->cmsg_len =CMSG_LEN (sizeof (op)); +memcpy (CMSG_DATA (cmsg), &op,sizeof (op)); + + cmsg =CMSG_NXTHDR (&msg, cmsg); + cmsg->cmsg_level =SOL_ALG ; + cmsg->cmsg_type =ALG_SET_AEAD_ASSOCLEN ; + cmsg->cmsg_len =CMSG_LEN (sizeof (assoclen)); +memcpy (CMSG_DATA (cmsg), &assoclen,sizeof (assoclen)); + +return sendmsg (reqfd, &msg,0 ); +} + +static const uint32_t assoclens[] = { +0x7fffffff , +ASSOCLEN_LIMIT , +0xffffffff , +}; + +static void run (unsigned int i) +{ +int reqfd =tst_alg_accept (algfd); + +if (assoclens[i] <ASSOCLEN_LIMIT ) { +TST_EXP_VAL (send_assoclen (reqfd, assoclens[i]),SEND_SIZE , +"assoclen=%#x" , assoclens[i]); + }else { +TST_EXP_FAIL2 (send_assoclen (reqfd, assoclens[i]),EINVAL , +"assoclen=%#x" , assoclens[i]); + } + +SAFE_CLOSE (reqfd); +} + +static void setup (void ) +{ + algfd =tst_alg_setup ("aead" ,"gcm(aes)" ,NULL ,16 ); +} + +static void cleanup (void ) +{ +if (algfd !=-1 ) +SAFE_CLOSE (algfd);
testcases/kernel/crypto/af_alg09.c line 104
Quoted 10 lines
testcases/kernel/crypto/af_alg09.c new file +10
-0+} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test = run, + .tcnt =ARRAY_SIZE (assoclens), + .save_restore = (const struct tst_path_val []) { + {"/proc/sys/crypto/af_alg_restrict" ,"0" , +TST_SR_SKIP_MISSING |TST_SR_TCONF_RO },
Consider using TST_SR_SKIP_RO instead of TST_SR_TCONF_RO here if no root needed.
Quoted 14 lines
testcases/kernel/crypto/af_alg09.c new file +8
-0+ {} + }, + .tags = (const struct tst_tag[]) { + {"linux-git" ,"e4c06479d7059888adf2f22bc1ebcf053bf691a2" }, + {"CVE" ,"2026-52972" }, + {} + }, +};Signature · 5 lines
2.56.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Stephen,
Quoted 14 lines · Stephen Bertram via ltp
From: Stephen Bertram <[email protected]>
Add a regression test for the missing cap on the AEAD associated data length. Kernel commit
e4c06479d705("crypto:af_alg- Cap AEAD AD length to0x80000000") rejectsALG_SET_AEAD_ASSOCLENvalues greater than or equal to0x80000000; without itaf_alg_sendmsg()accepts any 32-bit value.The test opens an
AF_ALGAEAD request socket, setsALG_OP_DECRYPTandALG_SET_AEAD_ASSOCLENto0x7fffffff, which must be accepted, and to0x80000000and0xffffffff, which must fail with EINVAL. It does not callrecvmsg(), so the test only depends on the control-message validation.
Quoted 7 lines
Since Linux 7.3,
/proc/sys/crypto/af_alg_restrictdefaults to 1 andbind()of gcm(aes) fails with ENOENT. When that file exists and is writable, the test sets it to 0 for the run and restores the previous value.Assisted-by Cursor:Grok-4.7Signed-off-by Stephen Bertram <[email protected]>---
It is good practice to do a bullet point list below the "---" in single patches or in the cover letter for the case of a patch series that explain what was changed between the revisions.
e.g. in v2:
v1 -> v2:
- Added .save_restore
Link to v1: https://lore.kernel.org/...
Feel free to add:
Thanks,
- Ricardo.
Quoted 161 lines
runtest/crypto | 1 + runtest/cve | 1 + testcases/kernel/crypto/.gitignore | 1 + testcases/kernel/crypto/af_alg09.c | 112 +++++++++++++++++++++++++++++ 4 files changed, 115 insertions(+) create mode 100644 testcases/kernel/crypto/af_alg09.cruntest/crypto +1
-0@@ -6,6 +6,7 @@ af_alg05 af_alg05 af_alg06 af_alg06 af_alg07 af_alg07 af_alg08 af_alg08 +af_alg09 af_alg09 pcrypt_aead01 pcrypt_aead01 crypto_user01 crypto_user01 crypto_user02 crypto_user02runtest/cve +1
-0@@ -89,6 +89,7 @@ cve-2023-0461 setsockopt10 cve-2023-31248 nft02 cve-2023-52879 fanotify25 cve-2026-43499 ghostlock +cve-2026-52972 af_alg09 cve-2026-53362 setsockopt11 cve-2026-64600 refluxfs cve-2026-99999 pwnescapetestcases/kernel/crypto/.gitignore +1
-0@@ -6,6 +6,7 @@ af_alg05 af_alg06 af_alg07 af_alg08 +af_alg09 pcrypt_aead01 crypto_user01 crypto_user02testcases/kernel/crypto/af_alg09.c new file +112
-0@@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2026 Red Hat, Inc. +*/ + +/*\ +* Test for CVE-2026-52972. +* +* Verify that the AF_ALG AEAD interface rejects an associated data length +* greater than or equal to 0x80000000 with EINVAL. +* +* Before kernel commit e4c06479d705 ("crypto: af_alg - Cap AEAD AD length to +* 0x80000000") af_alg_sendmsg() accepted any 32-bit ALG_SET_AEAD_ASSOCLEN +* value. +*/ + +#include "tst_test.h" +#include "tst_af_alg.h" +#include "lapi/socket.h" + +#define ASSOCLEN_LIMIT 0x80000000U +#define SEND_SIZE 16 + +static int algfd =-1 ; + +/* +* Send SEND_SIZE bytes with ALG_SET_AEAD_ASSOCLEN set to assoclen and +* ALG_SET_OP set to ALG_OP_DECRYPT. Return the sendmsg() return value, with +* errno from sendmsg() preserved. +*/ +static ssize_t send_assoclen (int reqfd,uint32_t assoclen) +{ +char data[SEND_SIZE ] = {0 }; +char control[CMSG_SPACE (sizeof (uint32_t )) *2 ]; +struct iovec iov = { + .iov_base = data, + .iov_len =sizeof (data), + }; +struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen =1 , + .msg_control = control, + .msg_controllen =sizeof (control), + }; +struct cmsghdr *cmsg; +uint32_t op =ALG_OP_DECRYPT ; + +memset (control,0 ,sizeof (control)); + + cmsg =CMSG_FIRSTHDR (&msg); + cmsg->cmsg_level =SOL_ALG ; + cmsg->cmsg_type =ALG_SET_OP ; + cmsg->cmsg_len =CMSG_LEN (sizeof (op)); +memcpy (CMSG_DATA (cmsg), &op,sizeof (op)); + + cmsg =CMSG_NXTHDR (&msg, cmsg); + cmsg->cmsg_level =SOL_ALG ; + cmsg->cmsg_type =ALG_SET_AEAD_ASSOCLEN ; + cmsg->cmsg_len =CMSG_LEN (sizeof (assoclen)); +memcpy (CMSG_DATA (cmsg), &assoclen,sizeof (assoclen)); + +return sendmsg (reqfd, &msg,0 ); +} + +static const uint32_t assoclens[] = { +0x7fffffff , +ASSOCLEN_LIMIT , +0xffffffff , +}; + +static void run (unsigned int i) +{ +int reqfd =tst_alg_accept (algfd); + +if (assoclens[i] <ASSOCLEN_LIMIT ) { +TST_EXP_VAL (send_assoclen (reqfd, assoclens[i]),SEND_SIZE , +"assoclen=%#x" , assoclens[i]); + }else { +TST_EXP_FAIL2 (send_assoclen (reqfd, assoclens[i]),EINVAL , +"assoclen=%#x" , assoclens[i]); + } + +SAFE_CLOSE (reqfd); +} + +static void setup (void ) +{ + algfd =tst_alg_setup ("aead" ,"gcm(aes)" ,NULL ,16 ); +} + +static void cleanup (void ) +{ +if (algfd !=-1 ) +SAFE_CLOSE (algfd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test = run, + .tcnt =ARRAY_SIZE (assoclens), + .save_restore = (const struct tst_path_val []) { + {"/proc/sys/crypto/af_alg_restrict" ,"0" , +TST_SR_SKIP_MISSING |TST_SR_TCONF_RO }, + {} + }, + .tags = (const struct tst_tag []) { + {"linux-git" ,"e4c06479d7059888adf2f22bc1ebcf053bf691a2" }, + {"CVE" ,"2026-52972" }, + {} + }, +};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp