The tpm-tools package fails annocheck hardened check due to
__memset being marked __no_optimize. Use an asm memory barrier
instead.

Signed-off-by: Jerry Snitselaar <[email protected]>
---
 include/tpm_utils.h | 2 +-
 lib/tpm_utils.c     | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/tpm_utils.h b/include/tpm_utils.h
index 690f45e..7fbc75d 100644
--- a/include/tpm_utils.h
+++ b/include/tpm_utils.h
@@ -71,7 +71,7 @@
 #define __no_optimize
 #endif
 
-void * __no_optimize __memset(void *s, int c, size_t n);
+void * __memset(void *s, int c, size_t n);
 
 typedef int (*CmdOptParser)( const int aOpt, const char *aOptArg );
 typedef void (*CmdHelpFunction)( const char *aCmd );
diff --git a/lib/tpm_utils.c b/lib/tpm_utils.c
index 2c7199b..300d108 100644
--- a/lib/tpm_utils.c
+++ b/lib/tpm_utils.c
@@ -134,10 +134,12 @@ genericOptHandler( int a_iNumArgs, char **a_pszArgs,
        return 0;
 }
 
-void * __no_optimize
+void *
 __memset(void *s, int c, size_t n)
 {
-       return memset(s, c, n);
+       memset(s, c, n);
+       asm volatile("" ::: "memory");
+       return s;
 }
 
 /*
-- 
2.21.0



_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech

Reply via email to