Skip to contentSkip to conversation

sctp_big_chunk: Do not use md5 hmac algo if fips is enabled

PATCH Superseded Ashwin Dayanand Kamat via ltp 2 participants 8 messages Jun 20, 2023 – Jun 21, 2023 2 messages not in the archive

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp_big_chunk: Do not use md5 hmac algo if fips is enabled

MD5 is not FIPS compliant. But still md5 is used as the default algorithm for sctp even when fips is enabled. Due to this, sctp_big_chunk testcase is failing because listen() system call in setup_server() is failing in fips environment.

Fix is to not use md5 algorithm while setting up server. Instead use sha1 as algorithm if it's supported or else set it to none.

Signed-Off by: Ashwin Dayanand Kamat <[email protected]>

---
 testcases/network/sctp/sctp_big_chunk.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
testcases/network/sctp/sctp_big_chunk.c +14 -0
index a6a326ea2..267f1cb45 100644
@@ -133,11 +133,15 @@ static void setup_client(void)
 }
 
 static const char mtu_path[] = "/sys/class/net/lo/mtu";
+static const char hmac_algo_path[] = "/proc/sys/net/sctp/cookie_hmac_alg";
 static const unsigned int max_mtu = 65535;
 static unsigned int mtu;
 
 static void setup(void)
 {
+	char hmac_algo[CHAR_MAX];
+	int fips_enabled = tst_fips_enabled();
+
 	if (tst_parse_int(addr_param, &addr_num, 1, INT_MAX))
 		tst_brk(TBROK, "wrong address number '%s'", addr_param);
 
@@ -146,8 +150,18 @@ static void setup(void)
 	if (mtu < max_mtu)
 		tst_brk(TCONF, "Test needs that 'lo' MTU has %d", max_mtu);
 
+	SAFE_FILE_SCANF(hmac_algo_path, "%s", hmac_algo);
+
+	if (fips_enabled) {
+		if (!system("grep hmac\\(sha1\\) /proc/crypto"))
+			SAFE_FILE_PRINTF(hmac_algo_path, "%s", "sha1");
+		else
+			SAFE_FILE_PRINTF(hmac_algo_path, "%s", "none");
+	}
+
 	setup_server();
 	setup_client();
+	SAFE_FILE_PRINTF(hmac_algo_path, "%s", hmac_algo);
 }
 
 static void run(void)
Signature · 5 lines
2.39.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Ashwin,

Quoted 33 lines

MD5 is not FIPS compliant. But still md5 is used as the default algorithm for sctp even when fips is enabled. Due to this, sctp_big_chunk testcase is failing because listen() system call in setup_server() is failing in fips environment.

Fix is to not use md5 algorithm while setting up server. Instead use sha1 as algorithm if it's supported or else set it to none.

Signed-Off by: Ashwin Dayanand Kamat <[email protected]>

---
 testcases/network/sctp/sctp_big_chunk.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
testcases/network/sctp/sctp_big_chunk.c +4 -0
index a6a326ea2..267f1cb45 100644
@@ -133,11 +133,15 @@ static void setup_client(void)
 }
 
 static const char mtu_path[] = "/sys/class/net/lo/mtu";
+static const char hmac_algo_path[] = "/proc/sys/net/sctp/cookie_hmac_alg";
 static const unsigned int max_mtu = 65535;
 static unsigned int mtu;
 
 static void setup(void)
 {
+	char hmac_algo[CHAR_MAX];
+	int fips_enabled = tst_fips_enabled();
+
 	if (tst_parse_int(addr_param, &addr_num, 1, INT_MAX))
 		tst_brk(TBROK, "wrong address number '%s'", addr_param);
 

testcases/network/sctp/sctp_big_chunk.c static void setup(void) · line 155

Quoted 6 lines
testcases/network/sctp/sctp_big_chunk.c +3 -0
@@ -146,8 +150,18 @@ static void setup(void)
 	if (mtu < max_mtu)
 		tst_brk(TCONF, "Test needs that 'lo' MTU has %d", max_mtu);
 
+	SAFE_FILE_SCANF(hmac_algo_path, "%s", hmac_algo);
+
+	if (fips_enabled) {

fips_enabled is used only here => if (tst_fips_enabled()) {

testcases/network/sctp/sctp_big_chunk.c static void setup(void) · line 156

Quoted 1 line
testcases/network/sctp/sctp_big_chunk.c +1 -0
+		if (!system("grep hmac\\(sha1\\) /proc/crypto"))

This would not be acceptable. We have SAFE_FILE_LINES_SCANF()

Something like would do:
SAFE_FILE_LINES_SCANF("/proc/crypto", "hmac(sha1)");

But I wonder if just setting "none" on FIPS would be enough.

Also, shouldn't this be set in setup_server() before SAFE_LISTEN(), to be obvious what needs it?

Kind regards,
Petr

Quoted 9 lines
testcases/network/sctp/sctp_big_chunk.c +6 -0
+			SAFE_FILE_PRINTF(hmac_algo_path, "%s", "sha1");
+		else
+			SAFE_FILE_PRINTF(hmac_algo_path, "%s", "none");
+	}
+
 	setup_server();
 	setup_client();
+	SAFE_FILE_PRINTF(hmac_algo_path, "%s", hmac_algo);
 }
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw
In reply to Ashwin Dayanand Kamat via ltp
Quoted 3 lines

MD5 is not FIPS compliant. But still md5 is used as the default algorithm for sctp even when fips is enabled. Due to this, sctp_big_chunk testcase is failing because listen() system call in setup_server() is failing in fips environment.

Out of curiosity, which errno is reported on listen?

In our case in FIPS ENOSYS is returned, thus handled as TCONF.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
Quoted 14 lines · Petr Vorel

!! External Email

Quoted 3 lines

MD5 is not FIPS compliant. But still md5 is used as the default algorithm for sctp even when fips is enabled. Due to this, sctp_big_chunk testcase is failing because listen() system call in setup_server() is failing in fips environment.

Out of curiosity, which errno is reported on listen?

In our case in FIPS ENOSYS is returned, thus handled as TCONF.

I am seeing the ENOSYS (38) error and it’s true that it is handled as TCONF. The intention of the patch is to fix the same.

Thanks,
Ashwin

Quoted 4 lines

Kind regards,
Petr

!! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hi Ashwin,

Quoted 5 lines
Quoted 3 lines

Out of curiosity, which errno is reported on listen?

In our case in FIPS ENOSYS is returned, thus handled as TCONF.

I am seeing the ENOSYS (38) error and it’s true that it is handled as TCONF. The intention of the patch is to fix the same.

TCONF means skipped, i.e. OK. I suppose your patch allows to do testing, which is an enhancement. But, at least on one FIPS system I get failure due missing proc file:

tst_fips.c:22: TINFO: FIPS: on
sctp_big_chunk.c:153: TBROK: Failed to open FILE '/proc/sys/net/sctp/cookie_hmac_alg' for reading: ENOENT (2)

The system has CONFIG_IP_SCTP=m, I don't know why module is not loaded. Maybe it's not installed on the system (would require package with extra modules), but still this would be a regression, we should check for presence of the file.

NOTE We have .save_restore [1] helper, generally we'd use it with TST_SR_TCONF_MISSING, but in this case I'd use access() to check, because whole SAFE_FILE_SCANF() should be applied only when needed (in tst_fips_enabled()).

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--restoring-procsys-values

Quoted 2 lines

Thanks,
Ashwin

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw
Quoted 6 lines

Hi Ashwin,

Quoted 3 lines
Quoted 3 lines

Out of curiosity, which errno is reported on listen?

In our case in FIPS ENOSYS is returned, thus handled as TCONF.

Quoted 8 lines
Quoted 1 line

I am seeing the ENOSYS (38) error and it’s true that it is handled as TCONF. The intention of the patch is to fix the same.

TCONF means skipped, i.e. OK. I suppose your patch allows to do testing, which is an enhancement. But, at least on one FIPS system I get failure due missing proc file:

tst_fips.c:22: TINFO: FIPS: on
sctp_big_chunk.c:153: TBROK: Failed to open FILE '/proc/sys/net/sctp/cookie_hmac_alg' for reading: ENOENT (2)

OK, this problem is on all systems which haven't used sctp so far. We really need to somehow modprobe sctp before reading /proc/sys/net/sctp/cookie_hmac_alg. Maybe using .needs_drivers?

Kind regards,
Petr

Quoted 17 lines

The system has CONFIG_IP_SCTP=m, I don't know why module is not loaded. Maybe it's not installed on the system (would require package with extra modules), but still this would be a regression, we should check for presence of the file.

NOTE We have .save_restore [1] helper, generally we'd use it with TST_SR_TCONF_MISSING, but in this case I'd use access() to check, because whole SAFE_FILE_SCANF() should be applied only when needed (in tst_fips_enabled()).

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--restoring-procsys-values

Quoted 2 lines

Thanks,
Ashwin

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

On 21-Jun-2023, at 6:18 PM, Petr Vorel <[email protected]<mailto:[email protected]>> wrote:

!! External Email

Hi Ashwin,

Out of curiosity, which errno is reported on listen?

In our case in FIPS ENOSYS is returned, thus handled as TCONF.

I am seeing the ENOSYS (38) error and it’s true that it is handled as TCONF. The intention of the patch is to fix the same.

TCONF means skipped, i.e. OK. I suppose your patch allows to do testing, which is an enhancement. But, at least on one FIPS system I get failure due missing proc file:

tst_fips.c:22: TINFO: FIPS: on
sctp_big_chunk.c:153: TBROK: Failed to open FILE '/proc/sys/net/sctp/cookie_hmac_alg' for reading: ENOENT (2)

OK, this problem is on all systems which haven't used sctp so far. We really need to somehow modprobe sctp before reading /proc/sys/net/sctp/cookie_hmac_alg. Maybe using .needs_drivers?

Thank you for your valuable input. I will look into these and handle it accordingly in the next patch.

Kind regards,
Ashwin Kamat
Kind regards,
Petr

The system has CONFIG_IP_SCTP=m, I don't know why module is not loaded. Maybe it's not installed on the system (would require package with extra modules), but still this would be a regression, we should check for presence of the file.

NOTE We have .save_restore [1] helper, generally we'd use it with TST_SR_TCONF_MISSING, but in this case I'd use access() to check, because whole SAFE_FILE_SCANF() should be applied only when needed (in tst_fips_enabled()).

Kind regards,
Petr

[1] https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flinux-test-project%2Fltp%2Fwiki%2FC-Test-API%23127-saving--restoring-procsys-values&data=05%7C01%7Ckashwindayan%40vmware.com%7C2db661163d9a47a4720308db7255ccb5%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C638229485080061558%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=KfYPwUd%2FyEyfHC0AN%2BHv32qWUGa3I3V%2BTnQ0KuGQoLQ%3D&reserved=0<https://github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--restoring-procsys-values>

Thanks,
Ashwin

!! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 20 lines · Petr Vorel

!! External Email

Quoted 6 lines

Hi Ashwin,

Quoted 3 lines
Quoted 3 lines

Out of curiosity, which errno is reported on listen?

In our case in FIPS ENOSYS is returned, thus handled as TCONF.

Quoted 8 lines
Quoted 1 line

I am seeing the ENOSYS (38) error and it’s true that it is handled as TCONF. The intention of the patch is to fix the same.

TCONF means skipped, i.e. OK. I suppose your patch allows to do testing, which is an enhancement. But, at least on one FIPS system I get failure due missing proc file:

tst_fips.c:22: TINFO: FIPS: on
sctp_big_chunk.c:153: TBROK: Failed to open FILE '/proc/sys/net/sctp/cookie_hmac_alg' for reading: ENOENT (2)

Quoted 7 lines

OK, this problem is on all systems which haven't used sctp so far. We really need to somehow modprobe sctp before reading /proc/sys/net/sctp/cookie_hmac_alg. Maybe using .needs_drivers?

Kind regards,
Petr

Thank you for your valuable input. I will look into these and handle accordingly in next patchset.

Regards,
Ashwin

Quoted 19 lines
Quoted 10 lines

The system has CONFIG_IP_SCTP=m, I don't know why module is not loaded. Maybe it's not installed on the system (would require package with extra modules), but still this would be a regression, we should check for presence of the file.

NOTE We have .save_restore [1] helper, generally we'd use it with TST_SR_TCONF_MISSING, but in this case I'd use access() to check, because whole SAFE_FILE_SCANF() should be applied only when needed (in tst_fips_enabled()).

Quoted 7 lines

Kind regards,
Petr

[1] https://github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--restoring-procsys-values <https://github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--restoring-procsys-values> <https://github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--restoring-procsys-values> <https://github.com/linux-test-project/ltp/wiki/C-Test-API#127-saving--restoring-procsys-values&gt;>

Quoted 2 lines

Thanks,
Ashwin

!! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp