Skip to contentSkip to conversation

net/sctp: Make sha1 as default algorithm if fips is enabled

PATCH Superseded Ashwin Dayanand Kamat 2 participants 6 messages Mar 22, 2023 – Jun 1, 2023 1 message not in the archive

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/sctp: Make sha1 as default algorithm if fips is enabled

MD5 is not FIPS compliant. But still md5 was used as the default algorithm for sctp if fips was enabled.
Due to this, listen() system call in ltp tests was failing for sctp in fips environment, with below error message.

[ 6397.892677] sctp: failed to load transform for md5: -2

Fix is to not assign md5 as default algorithm for sctp if fips_enabled is true. Instead make sha1 as default algorithm.

Fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"

---
v2:
the listener can still fail if fips mode is enabled after that the netns is initialized. So taking action in sctp_listen_start() and buming a ratelimited notice the selected hmac is changed due to fips.

---
 net/sctp/socket.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
net/sctp/socket.c +10 -0
index b91616f819de..a1107f42869e 100644
@@ -49,6 +49,7 @@
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/fips.h>
 #include <linux/file.h>
 #include <linux/compat.h>
 #include <linux/rhashtable.h>
@@ -8496,6 +8497,15 @@ static int sctp_listen_start(struct sock *sk, int backlog)
 	struct crypto_shash *tfm = NULL;
 	char alg[32];
 
+	if (fips_enabled && !strcmp(sp->sctp_hmac_alg, "md5")) {
+#if (IS_ENABLED(CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1))
+		sp->sctp_hmac_alg = "sha1";
+#else
+		sp->sctp_hmac_alg = NULL;
+#endif
+		net_info_ratelimited("changing the hmac algorithm, as md5 is not supported when fips is enabled");
+	}
+
 	/* Allocate HMAC for generating cookie. */
 	if (!sp->hmac && sp->sctp_hmac_alg) {
 		sprintf(alg, "hmac(%s)", sp->sctp_hmac_alg);
Signature · 1 line
2.39.0
#1 lore raw
Quoted 34 lines · Ashwin Dayanand Kamat

MD5 is not FIPS compliant. But still md5 was used as the default algorithm for sctp if fips was enabled.
Due to this, listen() system call in ltp tests was failing for sctp in fips environment, with below error message.

[ 6397.892677] sctp: failed to load transform for md5: -2

Fix is to not assign md5 as default algorithm for sctp if fips_enabled is true. Instead make sha1 as default algorithm.

Fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"

---
v2:
the listener can still fail if fips mode is enabled after that the netns is initialized. So taking action in sctp_listen_start() and buming a ratelimited notice the selected hmac is changed due to fips.

---
 net/sctp/socket.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
net/sctp/socket.c +1 -0
index b91616f819de..a1107f42869e 100644
@@ -49,6 +49,7 @@
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/fips.h>
 #include <linux/file.h>
 #include <linux/compat.h>
 #include <linux/rhashtable.h>

net/sctp/socket.c static int sctp_listen_start(struct sock *sk, int backlog) · line 8501

Quoted 5 lines
net/sctp/socket.c +2 -0
@@ -8496,6 +8497,15 @@ static int sctp_listen_start(struct sock *sk, int backlog)
 	struct crypto_shash *tfm = NULL;
 	char alg[32];
 
+	if (fips_enabled && !strcmp(sp->sctp_hmac_alg, "md5")) {
+#if (IS_ENABLED(CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1))

I'm probably misunderstanding things, but would
IS_ENABLED(CONFIG_SCTP_COOKIE_HMAC_SHA1)
be more appropriate here?

Quoted 13 lines
net/sctp/socket.c +7 -0
+		sp->sctp_hmac_alg = "sha1";
+#else
+		sp->sctp_hmac_alg = NULL;
+#endif
+		net_info_ratelimited("changing the hmac algorithm, as md5 is not supported when fips is enabled");
+	}
+
 	/* Allocate HMAC for generating cookie. */
 	if (!sp->hmac && sp->sctp_hmac_alg) {
 		sprintf(alg, "hmac(%s)", sp->sctp_hmac_alg);
Signature · 1 line
2.39.0
#3 lore raw
In reply to a message not in the archive
Quoted 43 lines · Simon Horman

!! External Email

Quoted 37 lines · Ashwin Dayanand Kamat

MD5 is not FIPS compliant. But still md5 was used as the default algorithm for sctp if fips was enabled.
Due to this, listen() system call in ltp tests was failing for sctp in fips environment, with below error message.

[ 6397.892677] sctp: failed to load transform for md5: -2

Fix is to not assign md5 as default algorithm for sctp if fips_enabled is true. Instead make sha1 as default algorithm.

Fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"

---
v2:
the listener can still fail if fips mode is enabled after that the netns is initialized. So taking action in sctp_listen_start() and buming a ratelimited notice the selected hmac is changed due to fips.
---
net/sctp/socket.c | 10 ++++++++++

1 file changed, 10 insertions(+)
net/sctp/socket.c +1 -0
index b91616f819de..a1107f42869e 100644
@@ -49,6 +49,7 @@
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/fips.h>
 #include <linux/file.h>
 #include <linux/compat.h>
 #include <linux/rhashtable.h>
@@ -8496,6 +8497,15 @@ static int sctp_listen_start(struct sock *sk, int backlog)
 struct crypto_shash *tfm = NULL;
 char alg[32];
 
Quoted 7 lines

net/sctp/socket.c static int sctp_listen_start(struct sock *sk, int backlog) · line 8501

Quoted 2 lines
net/sctp/socket.c +2 -0
+ if (fips_enabled && !strcmp(sp->sctp_hmac_alg, "md5")) {
+#if (IS_ENABLED(CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1))

I'm probably misunderstanding things, but would
IS_ENABLED(CONFIG_SCTP_COOKIE_HMAC_SHA1)
be more appropriate here?

Hi Simon,
I have moved the same check from sctp_init() to here based on the review for v1 patch. Please let me know if there is any alternative which can be used?

Thanks,
Ashwin Kamat

Quoted 15 lines
Quoted 11 lines
net/sctp/socket.c +7 -1
+ sp->sctp_hmac_alg = "sha1";
+#else
+ sp->sctp_hmac_alg = NULL;
+#endif
+ net_info_ratelimited("changing the hmac algorithm, as md5 is not supported when fips is enabled");
+ }
+
 /* Allocate HMAC for generating cookie. */
 if (!sp->hmac && sp->sctp_hmac_alg) {
 sprintf(alg, "hmac(%s)", sp->sctp_hmac_alg);
--
Quoted 2 lines

2.39.0

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

#4 lore raw
Quoted 55 lines · Ashwin Dayanand Kamat
Quoted 44 lines · Simon Horman

!! External Email

Quoted 37 lines · Ashwin Dayanand Kamat

MD5 is not FIPS compliant. But still md5 was used as the default algorithm for sctp if fips was enabled.
Due to this, listen() system call in ltp tests was failing for sctp in fips environment, with below error message.

[ 6397.892677] sctp: failed to load transform for md5: -2

Fix is to not assign md5 as default algorithm for sctp if fips_enabled is true. Instead make sha1 as default algorithm.

Fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"

---
v2:
the listener can still fail if fips mode is enabled after that the netns is initialized. So taking action in sctp_listen_start() and buming a ratelimited notice the selected hmac is changed due to fips.
---
net/sctp/socket.c | 10 ++++++++++

1 file changed, 10 insertions(+)
net/sctp/socket.c +1 -0
index b91616f819de..a1107f42869e 100644
@@ -49,6 +49,7 @@
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/fips.h>
 #include <linux/file.h>
 #include <linux/compat.h>
 #include <linux/rhashtable.h>
@@ -8496,6 +8497,15 @@ static int sctp_listen_start(struct sock *sk, int backlog)
 struct crypto_shash *tfm = NULL;
 char alg[32];
 
Quoted 7 lines

net/sctp/socket.c static int sctp_listen_start(struct sock *sk, int backlog) · line 8501

Quoted 2 lines
net/sctp/socket.c +2 -0
+ if (fips_enabled && !strcmp(sp->sctp_hmac_alg, "md5")) {
+#if (IS_ENABLED(CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1))

I'm probably misunderstanding things, but would
IS_ENABLED(CONFIG_SCTP_COOKIE_HMAC_SHA1)
be more appropriate here?

Quoted 7 lines

Hi Simon,
I have moved the same check from sctp_init() to here based on the review for v1 patch. Please let me know if there is any alternative which can be used?

Thanks,
Ashwin Kamat

Hi Team,
Any update on this?

Thanks,
Ashwin Kamat

Quoted 20 lines
Quoted 15 lines
Quoted 11 lines
net/sctp/socket.c +7 -1
+ sp->sctp_hmac_alg = "sha1";
+#else
+ sp->sctp_hmac_alg = NULL;
+#endif
+ net_info_ratelimited("changing the hmac algorithm, as md5 is not supported when fips is enabled");
+ }
+
 /* Allocate HMAC for generating cookie. */
 if (!sp->hmac && sp->sctp_hmac_alg) {
 sprintf(alg, "hmac(%s)", sp->sctp_hmac_alg);
--
Quoted 2 lines

2.39.0

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

#5 lore raw
Quoted 59 lines · Ashwin Dayanand Kamat
Quoted 59 lines · Ashwin Dayanand Kamat
Quoted 44 lines · Simon Horman

!! External Email

Quoted 37 lines · Ashwin Dayanand Kamat

MD5 is not FIPS compliant. But still md5 was used as the default algorithm for sctp if fips was enabled.
Due to this, listen() system call in ltp tests was failing for sctp in fips environment, with below error message.

[ 6397.892677] sctp: failed to load transform for md5: -2

Fix is to not assign md5 as default algorithm for sctp if fips_enabled is true. Instead make sha1 as default algorithm.

Fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"

---
v2:
the listener can still fail if fips mode is enabled after that the netns is initialized. So taking action in sctp_listen_start() and buming a ratelimited notice the selected hmac is changed due to fips.
---
net/sctp/socket.c | 10 ++++++++++

1 file changed, 10 insertions(+)
net/sctp/socket.c +1 -0
index b91616f819de..a1107f42869e 100644
@@ -49,6 +49,7 @@
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/fips.h>
 #include <linux/file.h>
 #include <linux/compat.h>
 #include <linux/rhashtable.h>
@@ -8496,6 +8497,15 @@ static int sctp_listen_start(struct sock *sk, int backlog)
 struct crypto_shash *tfm = NULL;
 char alg[32];
 
Quoted 7 lines

net/sctp/socket.c static int sctp_listen_start(struct sock *sk, int backlog) · line 8501

Quoted 2 lines
net/sctp/socket.c +2 -0
+ if (fips_enabled && !strcmp(sp->sctp_hmac_alg, "md5")) {
+#if (IS_ENABLED(CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1))

I'm probably misunderstanding things, but would
IS_ENABLED(CONFIG_SCTP_COOKIE_HMAC_SHA1)
be more appropriate here?

Hi Simon,
I have moved the same check from sctp_init() to here based on the review for v1 patch. Please let me know if there is any alternative which can be used?

Quoted 5 lines
Quoted 3 lines

Thanks,
Ashwin Kamat

Hi Team,
Any update on this?

Hi Ashwin,

I don't recall exactly what I was thinking 2 months ago.
But looking at this a second time it seems that I may have misread your
patch: I now have no objections to it in its original form.

#6 lore raw
Quoted 69 lines · Simon Horman

!! External Email

Quoted 62 lines · Ashwin Dayanand Kamat
Quoted 62 lines · Ashwin Dayanand Kamat
Quoted 44 lines · Simon Horman

!! External Email

Quoted 37 lines · Ashwin Dayanand Kamat

MD5 is not FIPS compliant. But still md5 was used as the default algorithm for sctp if fips was enabled.
Due to this, listen() system call in ltp tests was failing for sctp in fips environment, with below error message.

[ 6397.892677] sctp: failed to load transform for md5: -2

Fix is to not assign md5 as default algorithm for sctp if fips_enabled is true. Instead make sha1 as default algorithm.

Fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"

---
v2:
the listener can still fail if fips mode is enabled after that the netns is initialized. So taking action in sctp_listen_start() and buming a ratelimited notice the selected hmac is changed due to fips.
---
net/sctp/socket.c | 10 ++++++++++

1 file changed, 10 insertions(+)
net/sctp/socket.c +1 -0
index b91616f819de..a1107f42869e 100644
@@ -49,6 +49,7 @@
 #include <linux/poll.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/fips.h>
 #include <linux/file.h>
 #include <linux/compat.h>
 #include <linux/rhashtable.h>
@@ -8496,6 +8497,15 @@ static int sctp_listen_start(struct sock *sk, int backlog)
 struct crypto_shash *tfm = NULL;
 char alg[32];
 
Quoted 7 lines

net/sctp/socket.c static int sctp_listen_start(struct sock *sk, int backlog) · line 8501

Quoted 2 lines
net/sctp/socket.c +2 -0
+ if (fips_enabled && !strcmp(sp->sctp_hmac_alg, "md5")) {
+#if (IS_ENABLED(CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1))

I'm probably misunderstanding things, but would
IS_ENABLED(CONFIG_SCTP_COOKIE_HMAC_SHA1)
be more appropriate here?

Hi Simon,
I have moved the same check from sctp_init() to here based on the review for v1 patch. Please let me know if there is any alternative which can be used?

Thanks,
Ashwin Kamat

Quoted 8 lines
Quoted 2 lines

Hi Team,
Any update on this?

Hi Ashwin,

I don't recall exactly what I was thinking 2 months ago.
But looking at this a second time it seems that I may have misread your
patch: I now have no objections to it in its original form.

Thanks Simon.
I have Updated the v3 patch with some minor changes. Please review the same.

Quoted 2 lines

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