lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1685643474-18654-1-git-send-email-kashwindayan@vmware.com>
Date: Thu,  1 Jun 2023 23:47:54 +0530
From: Ashwin Dayanand Kamat <kashwindayan@...are.com>
To: Vlad Yasevich <vyasevich@...il.com>,
	Neil Horman <nhorman@...driver.com>,
	Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
	"David S . Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>,
	linux-sctp@...r.kernel.org,
	netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Ashwin Dayanand Kamat <kashwindayan@...are.com>,
	Simon Horman <simon.horman@...igine.com>,
	amakhalov@...are.com,
	vsirnapalli@...are.com,
	akaher@...are.com,
	tkundu@...are.com,
	keerthanak@...are.com
Subject: [PATCH v3] 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.
The issue fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"

Signed-off-by: Ashwin Dayanand Kamat <kashwindayan@...are.com>
---
v3:
* Resolved hunk failures.
* Changed the ratelimited notice to be more meaningful.
* Used ternary condition for if/else condtion.
v2:
* The listener can still fail if fips mode is enabled after
  that the netns is initialized.
* Fixed this in sctp_listen_start() as suggested by
  Paolo Abeni <pabeni@...hat.com>
---
 net/sctp/socket.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index cda8c2874691..d7cde9cc706e 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>
@@ -8501,6 +8502,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")) {
+		sp->sctp_hmac_alg = IS_ENABLED(CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1) ?
+				    "sha1" : NULL;
+
+		net_info_ratelimited("changing the hmac algorithm to %s "
+				     "as md5 is not supported when fips is enabled",
+				      sp->sctp_hmac_alg);
+	}
+
 	/* Allocate HMAC for generating cookie. */
 	if (!sp->hmac && sp->sctp_hmac_alg) {
 		sprintf(alg, "hmac(%s)", sp->sctp_hmac_alg);
-- 
2.39.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ