[LTP] [PATCH v3 2/2] tst_af_alg: TCONF on ciphers disabled by FIPS
Petr Vorel
pvorel@suse.cz
Wed Dec 22 20:26:04 CET 2021
Similar fix to 4fa302ef9d. It fixes:
./af_alg01
tst_af_alg.c:84: TBROK: unexpected error binding AF_ALG socket to hash algorithm 'md5': ELIBBAD (80)
become
tst_fips.c:22: TINFO: FIPS: on
tst_af_alg.c:111: TCONF: FIPS enabled => hash algorithm 'md5' disabled
tst_fips.c:22: TINFO: FIPS: on
tst_af_alg.c:111: TCONF: FIPS enabled => hash algorithm 'md5-generic' disabled
./af_alg02
tst_af_alg.c:37: TBROK: unexpected error binding AF_ALG socket to skcipher algorithm 'salsa20': ELIBBAD (80)
become
tst_fips.c:22: TINFO: FIPS: on
tst_af_alg.c:36: TCONF: FIPS enabled => skcipher algorithm 'salsa20' disabled
./af_alg04
tst_af_alg.c:81: TBROK: unexpected error binding AF_ALG socket to hash algorithm 'vmac64(aes)': ELIBBAD (80)
become
tst_fips.c:22: TINFO: FIPS: on
tst_af_alg.c:111: TCONF: FIPS enabled => hash algorithm 'vmac64(aes)' disabled
Tested on Debian stable bullseye and SLES 15-SP4.
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
NOTE: I asked Herbert Xu for confirmation that my code understanding is
correct and ELIBBAD is expected for ciphers disabled by FIPS.
include/tst_af_alg.h | 2 +-
lib/tst_af_alg.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/tst_af_alg.h b/include/tst_af_alg.h
index 93ff5715b7..86df18eb81 100644
--- a/include/tst_af_alg.h
+++ b/include/tst_af_alg.h
@@ -73,7 +73,7 @@ int tst_try_alg(const char *algtype, const char *algname);
*
* Return true if the algorithm is available, or false if unavailable
* and call tst_res() with TCONF. If another error occurs, tst_brk() is called
- * with TBROK.
+ * with TBROK unless algorithm is disabled due FIPS mode (errno ELIBBAD).
*/
bool tst_have_alg(const char *algtype, const char *algname);
diff --git a/lib/tst_af_alg.c b/lib/tst_af_alg.c
index d99a9ee2ef..52c0b0abb4 100644
--- a/lib/tst_af_alg.c
+++ b/lib/tst_af_alg.c
@@ -31,10 +31,18 @@ void tst_alg_bind_addr(int algfd, const struct sockaddr_alg *addr)
if (ret == 0)
return;
+
+ if (errno == ELIBBAD && tst_fips_enabled()) {
+ tst_brk(TCONF,
+ "FIPS enabled => %s algorithm '%s' disabled",
+ addr->salg_type, addr->salg_name);
+ }
+
if (errno == ENOENT) {
tst_brk(TCONF, "kernel doesn't support %s algorithm '%s'",
addr->salg_type, addr->salg_name);
}
+
tst_brk(TBROK | TERRNO,
"unexpected error binding AF_ALG socket to %s algorithm '%s'",
addr->salg_type, addr->salg_name);
@@ -98,6 +106,14 @@ bool tst_have_alg(const char *algtype, const char *algname)
tst_res(TCONF, "kernel doesn't have %s algorithm '%s'",
algtype, algname);
return false;
+ case ELIBBAD:
+ if (tst_fips_enabled()) {
+ tst_res(TCONF,
+ "FIPS enabled => %s algorithm '%s' disabled",
+ algtype, algname);
+ return false;
+ }
+ /* fallthrough */
default:
errno = ret;
tst_brk(TBROK | TERRNO,
--
2.34.1
More information about the ltp
mailing list