This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/5] Add explicit_bzero()


Ok, I should have added this to the commit message. The current version is not link-time optimization safe. See discussions:

https://gcc.gnu.org/ml/gcc-help/2016-02/msg00042.html

https://gcc.gnu.org/ml/gcc/2015-09/msg00135.html

My conclusion was to wait for proper compiler support.

On 18/03/16 12:24, Corinna Vinschen wrote:
On Mar 18 11:49, Sebastian Huber wrote:
This function is used by LibreSSL and OpenSSH and is provided by the
OpenBSD libc.
[...]
+#include <string.h>
+
+/*
+ * explicit_bzero - don't let the compiler optimize away bzero
+ */
+void
+explicit_bzero(void *p, size_t n)
+{
+	bzero(p, n);
+}
The OpenSSH version looks a bit different:

   /*
    * Indirect bzero through a volatile pointer to hopefully avoid
    * dead-store optimisation eliminating the call.
    */
   static void (* volatile ssh_bzero)(void *, size_t) = bzero;

   void
   explicit_bzero(void *p, size_t n)
   {
	  ssh_bzero(p, n);
   }

Is that something we should do, too, or is that paranoia at its
finest only?


Thanks,
Corinna


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschÃftliche Mitteilung im Sinne des EHUG.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]