public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [crng-random:master 2/2] arch/x86/coco/core.c:189:2: error: call to undeclared function 'memzero_explicit'; ISO C99 and later do not support implicit function declarations
@ 2024-03-24  1:15 kernel test robot
  2024-03-25 12:57 ` Kirill A. Shutemov
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2024-03-24  1:15 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: llvm, oe-kbuild-all, zx2c4, Elena Reshetova, Kirill A. Shutemov,
	Theodore Ts'o

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git master
head:   6fba9af4a847c5ee67715bc6f7959e9ab6394275
commit: 6fba9af4a847c5ee67715bc6f7959e9ab6394275 [2/2] x86/coco: Require seeding RNG with RDRAND on CoCo systems
config: x86_64-rhel-8.3-bpf (https://download.01.org/0day-ci/archive/20240324/202403240934.Nf4UUK5L-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240324/202403240934.Nf4UUK5L-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403240934.Nf4UUK5L-lkp@intel.com/

All errors (new ones prefixed by >>):

>> arch/x86/coco/core.c:189:2: error: call to undeclared function 'memzero_explicit'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     189 |         memzero_explicit(rng_seed, sizeof(rng_seed));
         |         ^
   1 error generated.


vim +/memzero_explicit +189 arch/x86/coco/core.c

   154	
   155	__init void cc_random_init(void)
   156	{
   157		/*
   158		 * The seed is 32 bytes (in units of longs), which is 256 bits, which
   159		 * is the security level that the RNG is targeting.
   160		 */
   161		unsigned long rng_seed[32 / sizeof(long)];
   162		size_t i, longs;
   163	
   164		if (!cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
   165			return;
   166	
   167		/*
   168		 * Since the CoCo threat model includes the host, the only reliable
   169		 * source of entropy that can be neither observed nor manipulated is
   170		 * RDRAND. Usually, RDRAND failure is considered tolerable, but since
   171		 * CoCo guests have no other unobservable source of entropy, it's
   172		 * important to at least ensure the RNG gets some initial random seeds.
   173		 */
   174		for (i = 0; i < ARRAY_SIZE(rng_seed); i += longs) {
   175			longs = arch_get_random_longs(&rng_seed[i], ARRAY_SIZE(rng_seed) - i);
   176	
   177			/*
   178			 * A zero return value means that the guest doesn't have RDRAND
   179			 * or the CPU is physically broken, and in both cases that
   180			 * means most crypto inside of the CoCo instance will be
   181			 * broken, defeating the purpose of CoCo in the first place. So
   182			 * just panic here because it's absolutely unsafe to continue
   183			 * executing.
   184			 */
   185			if (longs == 0)
   186				panic("RDRAND is defective.");
   187		}
   188		add_device_randomness(rng_seed, sizeof(rng_seed));
 > 189		memzero_explicit(rng_seed, sizeof(rng_seed));

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [crng-random:master 2/2] arch/x86/coco/core.c:189:2: error: call to undeclared function 'memzero_explicit'; ISO C99 and later do not support implicit function declarations
  2024-03-24  1:15 [crng-random:master 2/2] arch/x86/coco/core.c:189:2: error: call to undeclared function 'memzero_explicit'; ISO C99 and later do not support implicit function declarations kernel test robot
@ 2024-03-25 12:57 ` Kirill A. Shutemov
  0 siblings, 0 replies; 2+ messages in thread
From: Kirill A. Shutemov @ 2024-03-25 12:57 UTC (permalink / raw)
  To: kernel test robot
  Cc: Jason A. Donenfeld, llvm, oe-kbuild-all, Elena Reshetova,
	Theodore Ts'o

On Sun, Mar 24, 2024 at 09:15:17AM +0800, kernel test robot wrote:
> tree:   git://git.kernel.org/pub/scm/linux/kernel/git/crng/random.git master
> head:   6fba9af4a847c5ee67715bc6f7959e9ab6394275
> commit: 6fba9af4a847c5ee67715bc6f7959e9ab6394275 [2/2] x86/coco: Require seeding RNG with RDRAND on CoCo systems
> config: x86_64-rhel-8.3-bpf (https://download.01.org/0day-ci/archive/20240324/202403240934.Nf4UUK5L-lkp@intel.com/config)
> compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240324/202403240934.Nf4UUK5L-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202403240934.Nf4UUK5L-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
> >> arch/x86/coco/core.c:189:2: error: call to undeclared function 'memzero_explicit'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>      189 |         memzero_explicit(rng_seed, sizeof(rng_seed));
>          |         ^
>    1 error generated.

There's also issue with WARN_ON() in archrandom.h.

Fixup for these two issues:

diff --git a/arch/x86/coco/core.c b/arch/x86/coco/core.c
index 95e27dca9328..67edebb235e1 100644
--- a/arch/x86/coco/core.c
+++ b/arch/x86/coco/core.c
@@ -11,6 +11,7 @@
 #include <linux/export.h>
 #include <linux/cc_platform.h>
 #include <linux/random.h>
+#include <linux/string.h>
 
 #include <asm/archrandom.h>
 #include <asm/coco.h>
diff --git a/arch/x86/include/asm/archrandom.h b/arch/x86/include/asm/archrandom.h
index 1cc01ecd5e75..3066b339d4ce 100644
--- a/arch/x86/include/asm/archrandom.h
+++ b/arch/x86/include/asm/archrandom.h
@@ -12,6 +12,7 @@
 
 #include <asm/processor.h>
 #include <asm/cpufeature.h>
+#include <asm/bug.h>
 
 /* Unconditional execution of RDRAND and RDSEED */
 
-- 
  Kiryl Shutsemau / Kirill A. Shutemov

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

end of thread, other threads:[~2024-03-25 12:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-24  1:15 [crng-random:master 2/2] arch/x86/coco/core.c:189:2: error: call to undeclared function 'memzero_explicit'; ISO C99 and later do not support implicit function declarations kernel test robot
2024-03-25 12:57 ` Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox