From: David CARLIER <devnexen@gmail.com>
To: musl@lists.openwall.com
Subject: [PATCH] proposal adding explicit_bzero
Date: Fri, 15 Jun 2018 13:37:43 +0000 [thread overview]
Message-ID: <CA+XhMqziR9XUMxh9uRPmH3CAtP4NauMY9a9n0C0NsDu7zS3CXw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 109 bytes --]
Hi dear lists,
this is my first message so forgive me if this idea had already been rejected.
Kind regards.
[-- Attachment #2: 0001-string-adding-simple-explicit_bzero-implementation.patch --]
[-- Type: text/x-patch, Size: 1284 bytes --]
From c0a16cf96b96b009097d6ed656a2a7b8969e8399 Mon Sep 17 00:00:00 2001
From: David Carlier <dcarlier@afilias.info>
Date: Fri, 15 Jun 2018 13:30:09 +0000
Subject: [PATCH] string: adding simple explicit_bzero implementation.
glibc implementing it and modern security based code starting
using it widely, here a simple implementation using memory barrier.
---
include/string.h | 1 +
src/string/explicit_bzero.c | 8 ++++++++
2 files changed, 9 insertions(+)
create mode 100644 src/string/explicit_bzero.c
diff --git a/include/string.h b/include/string.h
index ce1dc300..795a2abc 100644
--- a/include/string.h
+++ b/include/string.h
@@ -82,6 +82,7 @@ void *memccpy (void *__restrict, const void *__restrict, int, size_t);
char *strsep(char **, const char *);
size_t strlcat (char *, const char *, size_t);
size_t strlcpy (char *, const char *, size_t);
+void explicit_bzero (void *, size_t);
#endif
#ifdef _GNU_SOURCE
diff --git a/src/string/explicit_bzero.c b/src/string/explicit_bzero.c
new file mode 100644
index 00000000..47dba3c7
--- /dev/null
+++ b/src/string/explicit_bzero.c
@@ -0,0 +1,8 @@
+#define _BSD_SOURCE
+#include <string.h>
+
+void explicit_bzero(void *d, size_t n)
+{
+ memset(d, 0, n);
+ __asm__ volatile("": "r="(d) :: "memory");
+}
--
2.14.1
next reply other threads:[~2018-06-15 13:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 13:37 David CARLIER [this message]
2018-06-26 20:43 ` Rich Felker
2018-06-26 20:48 ` David CARLIER
2018-06-26 20:53 ` Rich Felker
2018-06-26 20:54 ` David CARLIER
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+XhMqziR9XUMxh9uRPmH3CAtP4NauMY9a9n0C0NsDu7zS3CXw@mail.gmail.com \
--to=devnexen@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).