All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libuuid: use explicit_bzero() in uuid_clear() when possible
@ 2017-10-16 21:37 Sami Kerola
  2017-10-18  7:15 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Sami Kerola @ 2017-10-16 21:37 UTC (permalink / raw)
  To: util-linux; +Cc: Sami Kerola

This ensures value is blanked.  It is possible compiler optimization removed
earlier uuid_clear() calls as unnecessary if value was not used after clear.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
 libuuid/src/clear.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libuuid/src/clear.c b/libuuid/src/clear.c
index 2d91fee93..5b1392464 100644
--- a/libuuid/src/clear.c
+++ b/libuuid/src/clear.c
@@ -38,6 +38,10 @@
 
 void uuid_clear(uuid_t uu)
 {
+#ifdef HAVE_EXPLICIT_BZERO
+	explicit_bzero(uu, 16);
+#else
 	memset(uu, 0, 16);
+#endif
 }
 
-- 
2.14.2


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

* Re: [PATCH] libuuid: use explicit_bzero() in uuid_clear() when possible
  2017-10-16 21:37 [PATCH] libuuid: use explicit_bzero() in uuid_clear() when possible Sami Kerola
@ 2017-10-18  7:15 ` Christoph Hellwig
  2017-10-23 19:38   ` Sami Kerola
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2017-10-18  7:15 UTC (permalink / raw)
  To: Sami Kerola; +Cc: util-linux

On Mon, Oct 16, 2017 at 10:37:34PM +0100, Sami Kerola wrote:
> This ensures value is blanked.  It is possible compiler optimization removed
> earlier uuid_clear() calls as unnecessary if value was not used after clear.

Can you explain the logic behind this a bit more?  If no one uses the
uuid later it doesn't matter if we cleared it or not.

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

* Re: [PATCH] libuuid: use explicit_bzero() in uuid_clear() when possible
  2017-10-18  7:15 ` Christoph Hellwig
@ 2017-10-23 19:38   ` Sami Kerola
  2017-10-24  9:30     ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Sami Kerola @ 2017-10-23 19:38 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: util-linux

On 18 October 2017 at 08:15, Christoph Hellwig <hch@infradead.org> wrote:
> On Mon, Oct 16, 2017 at 10:37:34PM +0100, Sami Kerola wrote:
>> This ensures value is blanked.  It is possible compiler optimization removed
>> earlier uuid_clear() calls as unnecessary if value was not used after clear.
>
> Can you explain the logic behind this a bit more?  If no one uses the
> uuid later it doesn't matter if we cleared it or not.

When value is not used compiler might deside to remove such clearning
altogether. To me uuid_clear() is promise that the value disappears, and
that is what the function should do. Who knows, maybe someone uses
uuids to something sensitive that must be cleared not to leak secrets.
In that sort of context one really hopes promise of clearing is kept.

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

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

* Re: [PATCH] libuuid: use explicit_bzero() in uuid_clear() when possible
  2017-10-23 19:38   ` Sami Kerola
@ 2017-10-24  9:30     ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-10-24  9:30 UTC (permalink / raw)
  To: kerolasa; +Cc: Christoph Hellwig, util-linux

On Mon, Oct 23, 2017 at 08:38:20PM +0100, Sami Kerola wrote:
> > Can you explain the logic behind this a bit more?  If no one uses the
> > uuid later it doesn't matter if we cleared it or not.
> 
> When value is not used compiler might deside to remove such clearning
> altogether. To me uuid_clear() is promise that the value disappears, and
> that is what the function should do. Who knows, maybe someone uses
> uuids to something sensitive that must be cleared not to leak secrets.
> In that sort of context one really hopes promise of clearing is kept.

That's not how uuid_clear is documented.  From the man page:

NAME
       uuid_clear - reset value of UUID variable to the NULL value

SYNOPSIS
       #include <uuid.h>

       void uuid_clear(uuid_t uu);

DESCRIPTION
       The uuid_clear function sets the value of the supplied uuid variable uu to the NULL value.

If the variable isn't used it obviously must not be cleared.

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

end of thread, other threads:[~2017-10-24  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-16 21:37 [PATCH] libuuid: use explicit_bzero() in uuid_clear() when possible Sami Kerola
2017-10-18  7:15 ` Christoph Hellwig
2017-10-23 19:38   ` Sami Kerola
2017-10-24  9:30     ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.