linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ashwin Dayanand Kamat <kashwindayan@vmware.com>
To: Vlad Yasevich <vyasevich@gmail.com>,
	Neil Horman <nhorman@tuxdriver.com>,
	Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Ashwin Dayanand Kamat <kashwindayan@vmware.com>,
	srivatsab@vmware.com, srivatsa@csail.mit.edu,
	amakhalov@vmware.com, vsirnapalli@vmware.com, akaher@vmware.com,
	tkundu@vmware.com, keerthanak@vmware.com
Subject: [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled
Date: Wed, 22 Mar 2023 19:34:40 +0530	[thread overview]
Message-ID: <1679493880-26421-1-git-send-email-kashwindayan@vmware.com> (raw)

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"
Signed-off-by: Ashwin Dayanand Kamat <kashwindayan@vmware.com>
---
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(+)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index b91616f819de..a1107f42869e 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -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);
-- 
2.39.0


             reply	other threads:[~2023-03-22 14:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-22 14:04 Ashwin Dayanand Kamat [this message]
2023-03-22 20:46 ` [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled Simon Horman
     [not found]   ` <4BCFED42-2BBD-42B0-91C5-B12FEE000812@vmware.com>
2023-03-25  6:33     ` Ashwin Dayanand Kamat
2023-05-27  7:49       ` Ashwin Dayanand Kamat
2023-05-27 14:13         ` Simon Horman
2023-06-01 18:21           ` Ashwin Dayanand Kamat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1679493880-26421-1-git-send-email-kashwindayan@vmware.com \
    --to=kashwindayan@vmware.com \
    --cc=akaher@vmware.com \
    --cc=amakhalov@vmware.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=keerthanak@vmware.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sctp@vger.kernel.org \
    --cc=marcelo.leitner@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=pabeni@redhat.com \
    --cc=srivatsa@csail.mit.edu \
    --cc=srivatsab@vmware.com \
    --cc=tkundu@vmware.com \
    --cc=vsirnapalli@vmware.com \
    --cc=vyasevich@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).