[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ZBtpJO3ycoNHXj0p@corigine.com>
Date: Wed, 22 Mar 2023 21:46:28 +0100
From: Simon Horman <simon.horman@...igine.com>
To: Ashwin Dayanand Kamat <kashwindayan@...are.com>
Cc: 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,
srivatsab@...are.com, srivatsa@...il.mit.edu, amakhalov@...are.com,
vsirnapalli@...are.com, akaher@...are.com, tkundu@...are.com,
keerthanak@...are.com
Subject: Re: [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is
enabled
On Wed, Mar 22, 2023 at 07:34:40PM +0530, Ashwin Dayanand Kamat wrote:
> 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@...are.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))
I'm probably misunderstanding things, but would
IS_ENABLED(CONFIG_SCTP_COOKIE_HMAC_SHA1)
be more appropriate here?
> + 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
>
Powered by blists - more mailing lists