diff mbox series

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

Message ID 1685643474-18654-1-git-send-email-kashwindayan@vmware.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v3] net/sctp: Make sha1 as default algorithm if fips is enabled | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 1 maintainers not CCed: lucien.xin@gmail.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch warning WARNING: line length of 86 exceeds 80 columns WARNING: quoted string split across lines
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ashwin Dayanand Kamat June 1, 2023, 6:17 p.m. UTC
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@vmware.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@redhat.com>
---
 net/sctp/socket.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Simon Horman June 2, 2023, 3:15 p.m. UTC | #1
+ Xin Long

On Thu, Jun 01, 2023 at 11:47:54PM +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.
> The issue fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"
> 
> Signed-off-by: Ashwin Dayanand Kamat <kashwindayan@vmware.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@redhat.com>

FWIIW, this seems reasonable to me.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Xin Long June 2, 2023, 11:16 p.m. UTC | #2
On Fri, Jun 2, 2023 at 11:15 AM Simon Horman <simon.horman@corigine.com> wrote:
>
> + Xin Long
>
> On Thu, Jun 01, 2023 at 11:47:54PM +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.
> > The issue fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"
Hi, Ashwin,

I have the same question as Paolo about "this patch gets fips compliance
_disabling_ the encryption", is it from any standard?

If not,  can't you fix the ltp testcase for fips environment by sysctl?
or set 'CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1=y' instead in config.

Sorry if I don't understand this well. You're trying to avoid SCTP code
calling crypto_alloc_shash(MD5), right? What about other places
where it may also do it in kernel? (where ltp just doesn't cover)

I don't think it makes sense to let SCTP have some code reply on
FIPS only to make ltp testcase happy, while we can actually fix it
in ltp by "sysctl".

Thanks.


> >
> > Signed-off-by: Ashwin Dayanand Kamat <kashwindayan@vmware.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@redhat.com>
>
> FWIIW, this seems reasonable to me.
>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
Ashwin Dayanand Kamat June 22, 2023, 2:54 p.m. UTC | #3
> On 03-Jun-2023, at 4:46 AM, Xin Long <lucien.xin@gmail.com> wrote:
> 
> !! External Email
> 
> On Fri, Jun 2, 2023 at 11:15 AM Simon Horman <simon.horman@corigine.com> wrote:
>> 
>> + Xin Long
>> 
>> On Thu, Jun 01, 2023 at 11:47:54PM +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.
>>> The issue fixes ltp testcase failure "cve-2018-5803 sctp_big_chunk"
> Hi, Ashwin,
> 
> I have the same question as Paolo about "this patch gets fips compliance
> _disabling_ the encryption", is it from any standard?
> 
> If not,  can't you fix the ltp testcase for fips environment by sysctl?
> or set 'CONFIG_SCTP_DEFAULT_COOKIE_HMAC_SHA1=y' instead in config.
> 
> Sorry if I don't understand this well. You're trying to avoid SCTP code
> calling crypto_alloc_shash(MD5), right? What about other places
> where it may also do it in kernel? (where ltp just doesn't cover)
> 
> I don't think it makes sense to let SCTP have some code reply on
> FIPS only to make ltp testcase happy, while we can actually fix it
> in ltp by "sysctl".
> 
> Thanks.
> 
Hi Xi,
Thanks for your inputs. I have sent the patches to ltp upstream to handle the fix from ltp codebase.

Regards,
Ashwin Kamat
>>> 
>>> Signed-off-by: Ashwin Dayanand Kamat <kashwindayan@vmware.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@redhat.com>
>> 
>> FWIIW, this seems reasonable to me.
>> 
>> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> 
> !! External Email: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender.
diff mbox series

Patch

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