All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled
@ 2023-03-22 14:04 Ashwin Dayanand Kamat
  2023-03-22 20:46 ` Simon Horman
  0 siblings, 1 reply; 6+ messages in thread
From: Ashwin Dayanand Kamat @ 2023-03-22 14:04 UTC (permalink / raw)
  To: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-sctp, netdev, linux-kernel
  Cc: Ashwin Dayanand Kamat, srivatsab, srivatsa, amakhalov,
	vsirnapalli, akaher, tkundu, keerthanak

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled
  2023-03-22 14:04 [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled Ashwin Dayanand Kamat
@ 2023-03-22 20:46 ` Simon Horman
       [not found]   ` <4BCFED42-2BBD-42B0-91C5-B12FEE000812@vmware.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2023-03-22 20:46 UTC (permalink / raw)
  To: Ashwin Dayanand Kamat
  Cc: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-sctp, netdev, linux-kernel, srivatsab, srivatsa, amakhalov,
	vsirnapalli, akaher, tkundu, keerthanak

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@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))

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
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled
       [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
  0 siblings, 1 reply; 6+ messages in thread
From: Ashwin Dayanand Kamat @ 2023-03-25  6:33 UTC (permalink / raw)
  To: simon.horman
  Cc: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-sctp, netdev, linux-kernel, Srivatsa Bhat, srivatsa,
	Alexey Makhalov, Vasavi Sirnapalli, Ajay Kaher, Tapas Kundu,
	Keerthana Kalyanasundaram


> On 23-Mar-2023, at 2:16 AM, Simon Horman <simon.horman@corigine.com> wrote:
> 
> !! External Email
> 
> 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@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))
> 
> 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

>> + 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
>> 
> 
> !! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled
  2023-03-25  6:33     ` Ashwin Dayanand Kamat
@ 2023-05-27  7:49       ` Ashwin Dayanand Kamat
  2023-05-27 14:13         ` Simon Horman
  0 siblings, 1 reply; 6+ messages in thread
From: Ashwin Dayanand Kamat @ 2023-05-27  7:49 UTC (permalink / raw)
  To: Simon Horman
  Cc: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-sctp, netdev, linux-kernel, Srivatsa Bhat, srivatsa,
	Alexey Makhalov, Vasavi Sirnapalli, Ajay Kaher, Tapas Kundu,
	Keerthana Kalyanasundaram



> On 25-Mar-2023, at 12:03 PM, Ashwin Dayanand Kamat <kashwindayan@vmware.com> wrote:
> 
> 
>> On 23-Mar-2023, at 2:16 AM, Simon Horman <simon.horman@corigine.com> wrote:
>> 
>> !! External Email
>> 
>> 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@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))
>> 
>> 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
> 
Hi Team,
Any update on this?

Thanks,
Ashwin Kamat
>>> + 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
>>> 
>> 
>> !! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled
  2023-05-27  7:49       ` Ashwin Dayanand Kamat
@ 2023-05-27 14:13         ` Simon Horman
  2023-06-01 18:21           ` Ashwin Dayanand Kamat
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Horman @ 2023-05-27 14:13 UTC (permalink / raw)
  To: Ashwin Dayanand Kamat
  Cc: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-sctp, netdev, linux-kernel, Srivatsa Bhat, srivatsa,
	Alexey Makhalov, Vasavi Sirnapalli, Ajay Kaher, Tapas Kundu,
	Keerthana Kalyanasundaram

On Sat, May 27, 2023 at 07:49:26AM +0000, Ashwin Dayanand Kamat wrote:
> 
> 
> > On 25-Mar-2023, at 12:03 PM, Ashwin Dayanand Kamat <kashwindayan@vmware.com> wrote:
> > 
> > 
> >> On 23-Mar-2023, at 2:16 AM, Simon Horman <simon.horman@corigine.com> wrote:
> >> 
> >> !! External Email
> >> 
> >> 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@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))
> >> 
> >> 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
> > 
> 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.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled
  2023-05-27 14:13         ` Simon Horman
@ 2023-06-01 18:21           ` Ashwin Dayanand Kamat
  0 siblings, 0 replies; 6+ messages in thread
From: Ashwin Dayanand Kamat @ 2023-06-01 18:21 UTC (permalink / raw)
  To: Simon Horman
  Cc: Vlad Yasevich, Neil Horman, Marcelo Ricardo Leitner,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-sctp, netdev, linux-kernel, Alexey Makhalov,
	Vasavi Sirnapalli, Ajay Kaher, Tapas Kundu,
	Keerthana Kalyanasundaram



> On 27-May-2023, at 7:43 PM, Simon Horman <simon.horman@corigine.com> wrote:
> 
> !! External Email
> 
> On Sat, May 27, 2023 at 07:49:26AM +0000, Ashwin Dayanand Kamat wrote:
>> 
>> 
>>> On 25-Mar-2023, at 12:03 PM, Ashwin Dayanand Kamat <kashwindayan@vmware.com> wrote:
>>> 
>>> 
>>>> On 23-Mar-2023, at 2:16 AM, Simon Horman <simon.horman@corigine.com> wrote:
>>>> 
>>>> !! External Email
>>>> 
>>>> 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@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))
>>>> 
>>>> 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
>>> 
>> 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.

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-01 18:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 14:04 [PATCH v2] net/sctp: Make sha1 as default algorithm if fips is enabled Ashwin Dayanand Kamat
2023-03-22 20:46 ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.