Skip to content

Commit

Permalink
crypto: jitter - don't limit ->health_failure check to FIPS mode
Browse files Browse the repository at this point in the history
The jitterentropy's Repetition Count Test (RCT) as well as the Adaptive
Proportion Test (APT) are run unconditionally on any collected samples.
However, their result, i.e. ->health_failure, will only get checked if
fips_enabled is set, c.f. the jent_health_failure() wrapper.

I would argue that a RCT or APT failure indicates that something's
seriously off and that this should always be reported as an error,
independently of whether FIPS mode is enabled or not: it should be up to
callers whether or not and how to handle jitterentropy failures.

Make jent_health_failure() to unconditionally return ->health_failure,
independent of whether fips_enabled is set.

Note that fips_enabled isn't accessed from the jitterentropy code anymore
now. Remove the linux/fips.h include as well as the jent_fips_enabled()
wrapper.

Signed-off-by: Nicolai Stange <[email protected]>
Reviewed-by: Stephan Mueller <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
nicstange authored and herbertx committed Dec 11, 2021
1 parent 8f79772 commit b454fb7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 11 deletions.
6 changes: 0 additions & 6 deletions crypto/jitterentropy-kcapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/fips.h>
#include <linux/time.h>
#include <crypto/internal/rng.h>

Expand All @@ -60,11 +59,6 @@ void jent_zfree(void *ptr)
kfree_sensitive(ptr);
}

int jent_fips_enabled(void)
{
return fips_enabled;
}

void jent_panic(char *s)
{
panic("%s", s);
Expand Down
4 changes: 0 additions & 4 deletions crypto/jitterentropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,6 @@ static int jent_stuck(struct rand_data *ec, __u64 current_delta)
*/
static int jent_health_failure(struct rand_data *ec)
{
/* Test is only enabled in FIPS mode */
if (!jent_fips_enabled())
return 0;

return ec->health_failure;
}

Expand Down
1 change: 0 additions & 1 deletion crypto/jitterentropy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

extern void *jent_zalloc(unsigned int len);
extern void jent_zfree(void *ptr);
extern int jent_fips_enabled(void);
extern void jent_panic(char *s);
extern void jent_memcpy(void *dest, const void *src, unsigned int n);
extern void jent_get_nstime(__u64 *out);
Expand Down

0 comments on commit b454fb7

Please sign in to comment.