[libvirt PATCH 1/3] util: implement secure erase with explicit_bzero

Daniel P. Berrangé berrange at redhat.com
Mon Dec 12 10:32:06 UTC 2022


This is available on at least FreeBSD and GLibc >= 2.25.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 meson.build               | 1 +
 src/util/virsecureerase.c | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/meson.build b/meson.build
index f9834a36c2..553d4328d0 100644
--- a/meson.build
+++ b/meson.build
@@ -537,6 +537,7 @@ libvirt_export_dynamic = cc.first_supported_link_argument([
 
 functions = [
   'elf_aux_info',
+  'explicit_bzero',
   'fallocate',
   'getauxval',
   'getegid',
diff --git a/src/util/virsecureerase.c b/src/util/virsecureerase.c
index ead12803da..00542da99d 100644
--- a/src/util/virsecureerase.c
+++ b/src/util/virsecureerase.c
@@ -19,6 +19,8 @@
 
 #include <config.h>
 
+#include <string.h>
+
 #include "virsecureerase.h"
 
 /**
@@ -40,7 +42,11 @@ virSecureErase(void *ptr,
     if (!ptr || size == 0)
         return;
 
+#ifdef WITH_EXPLICIT_BZERO
+    explicit_bzero(ptr, size);
+#else
     memset(ptr, 0, size);
+#endif
 }
 
 /**
-- 
2.38.1



More information about the libvir-list mailing list