diff --git a/target/linux/generic/backport-6.12/932-v7.1-crypto-tcrypt-clamp-num_mb-to-avoid-divide-by-zero.patch b/target/linux/generic/backport-6.12/932-v7.1-crypto-tcrypt-clamp-num_mb-to-avoid-divide-by-zero.patch new file mode 100644 index 0000000000..e369826dd8 --- /dev/null +++ b/target/linux/generic/backport-6.12/932-v7.1-crypto-tcrypt-clamp-num_mb-to-avoid-divide-by-zero.patch @@ -0,0 +1,36 @@ +From 32e76e3757e89f370bf2ac8dba8aeb133071834e Mon Sep 17 00:00:00 2001 +From: Saeed Mirzamohammadi +Date: Mon, 2 Mar 2026 15:59:14 -0800 +Subject: [PATCH] crypto: tcrypt - clamp num_mb to avoid divide-by-zero + +Passing num_mb=0 to the multibuffer speed tests leaves test_mb_aead_cycles() +and test_mb_acipher_cycles() dividing by (8 * num_mb). With sec=0 (the +default), the module prints "1 operation in ..." and hits a divide-by-zero +fault. + +Force num_mb to at least 1 during module init and warn the caller so the +warm-up loop and the final report stay well-defined. + +To reproduce: +sudo modprobe tcrypt mode=600 num_mb=0 + +Signed-off-by: Saeed Mirzamohammadi +Signed-off-by: Herbert Xu +--- + crypto/tcrypt.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/crypto/tcrypt.c ++++ b/crypto/tcrypt.c +@@ -2832,6 +2832,11 @@ static int __init tcrypt_mod_init(void) + goto err_free_tv; + } + ++ if (!num_mb) { ++ pr_warn("num_mb must be at least 1; forcing to 1\n"); ++ num_mb = 1; ++ } ++ + err = do_test(alg, type, mask, mode, num_mb); + + if (err) { diff --git a/target/linux/generic/backport-6.12/933-v7.1-crypto-tcrypt-stop-ahash-speed-tests-when-setkey-fai.patch b/target/linux/generic/backport-6.12/933-v7.1-crypto-tcrypt-stop-ahash-speed-tests-when-setkey-fai.patch new file mode 100644 index 0000000000..2d1ef0aa52 --- /dev/null +++ b/target/linux/generic/backport-6.12/933-v7.1-crypto-tcrypt-stop-ahash-speed-tests-when-setkey-fai.patch @@ -0,0 +1,36 @@ +From 03170b8f84354f1649a757e57c2130e1de237f5d Mon Sep 17 00:00:00 2001 +From: Saeed Mirzamohammadi +Date: Mon, 2 Mar 2026 16:06:40 -0800 +Subject: [PATCH] crypto: tcrypt - stop ahash speed tests when setkey fails + +The async hash speed path ignores the return code from +crypto_ahash_setkey(). If the caller picks an unsupported key length, +the transform keeps whatever key state it already has and the speed test +still runs, producing misleading numbers, hence bail out of the loop when +setkey fails. + +Signed-off-by: Saeed Mirzamohammadi +Signed-off-by: Herbert Xu +--- + crypto/tcrypt.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/crypto/tcrypt.c ++++ b/crypto/tcrypt.c +@@ -911,8 +911,14 @@ static void test_ahash_speed_common(cons + break; + } + +- if (klen) +- crypto_ahash_setkey(tfm, tvmem[0], klen); ++ if (klen) { ++ ret = crypto_ahash_setkey(tfm, tvmem[0], klen); ++ if (ret) { ++ pr_err("setkey() failed flags=%x: %d\n", ++ crypto_ahash_get_flags(tfm), ret); ++ break; ++ } ++ } + + pr_info("test%3u " + "(%5u byte blocks,%5u bytes per update,%4u updates): ", diff --git a/target/linux/generic/backport-6.18/932-v7.1-crypto-tcrypt-clamp-num_mb-to-avoid-divide-by-zero.patch b/target/linux/generic/backport-6.18/932-v7.1-crypto-tcrypt-clamp-num_mb-to-avoid-divide-by-zero.patch new file mode 100644 index 0000000000..500b006ff8 --- /dev/null +++ b/target/linux/generic/backport-6.18/932-v7.1-crypto-tcrypt-clamp-num_mb-to-avoid-divide-by-zero.patch @@ -0,0 +1,36 @@ +From 32e76e3757e89f370bf2ac8dba8aeb133071834e Mon Sep 17 00:00:00 2001 +From: Saeed Mirzamohammadi +Date: Mon, 2 Mar 2026 15:59:14 -0800 +Subject: [PATCH] crypto: tcrypt - clamp num_mb to avoid divide-by-zero + +Passing num_mb=0 to the multibuffer speed tests leaves test_mb_aead_cycles() +and test_mb_acipher_cycles() dividing by (8 * num_mb). With sec=0 (the +default), the module prints "1 operation in ..." and hits a divide-by-zero +fault. + +Force num_mb to at least 1 during module init and warn the caller so the +warm-up loop and the final report stay well-defined. + +To reproduce: +sudo modprobe tcrypt mode=600 num_mb=0 + +Signed-off-by: Saeed Mirzamohammadi +Signed-off-by: Herbert Xu +--- + crypto/tcrypt.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/crypto/tcrypt.c ++++ b/crypto/tcrypt.c +@@ -2820,6 +2820,11 @@ static int __init tcrypt_mod_init(void) + goto err_free_tv; + } + ++ if (!num_mb) { ++ pr_warn("num_mb must be at least 1; forcing to 1\n"); ++ num_mb = 1; ++ } ++ + err = do_test(alg, type, mask, mode, num_mb); + + if (err) { diff --git a/target/linux/generic/backport-6.18/933-v7.1-crypto-tcrypt-stop-ahash-speed-tests-when-setkey-fai.patch b/target/linux/generic/backport-6.18/933-v7.1-crypto-tcrypt-stop-ahash-speed-tests-when-setkey-fai.patch new file mode 100644 index 0000000000..2d1ef0aa52 --- /dev/null +++ b/target/linux/generic/backport-6.18/933-v7.1-crypto-tcrypt-stop-ahash-speed-tests-when-setkey-fai.patch @@ -0,0 +1,36 @@ +From 03170b8f84354f1649a757e57c2130e1de237f5d Mon Sep 17 00:00:00 2001 +From: Saeed Mirzamohammadi +Date: Mon, 2 Mar 2026 16:06:40 -0800 +Subject: [PATCH] crypto: tcrypt - stop ahash speed tests when setkey fails + +The async hash speed path ignores the return code from +crypto_ahash_setkey(). If the caller picks an unsupported key length, +the transform keeps whatever key state it already has and the speed test +still runs, producing misleading numbers, hence bail out of the loop when +setkey fails. + +Signed-off-by: Saeed Mirzamohammadi +Signed-off-by: Herbert Xu +--- + crypto/tcrypt.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/crypto/tcrypt.c ++++ b/crypto/tcrypt.c +@@ -911,8 +911,14 @@ static void test_ahash_speed_common(cons + break; + } + +- if (klen) +- crypto_ahash_setkey(tfm, tvmem[0], klen); ++ if (klen) { ++ ret = crypto_ahash_setkey(tfm, tvmem[0], klen); ++ if (ret) { ++ pr_err("setkey() failed flags=%x: %d\n", ++ crypto_ahash_get_flags(tfm), ret); ++ break; ++ } ++ } + + pr_info("test%3u " + "(%5u byte blocks,%5u bytes per update,%4u updates): ",