[lkml]   [2017]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 3/5] KEYS: encrypted: sanitize all key material
On Fri, Apr 21, 2017 at 03:31:08PM +0100, David Howells wrote:
> Eric Biggers <> wrote:
> > - memzero_explicit(epayload->decrypted_data, epayload->decrypted_datalen);
> > - kfree(key->[0]);
> > + kzfree(key->[0]);
> Should kzfree() be using memzero_explicit() rather than memset()?
> David

It's not actually needed because it's impossible for the compiler to optimize
away the memset(). memzero_explicit() is only needed on stack data.

The reason I still used memzero_explicit() for heap data in a couple of my
patches, even though it's unnecessary, is just that it makes it clearer that
it's being done for sanitization purposes, as opposed to some random memset.

That's not as much of an issue for kzfree(), since it's explicitly for
sanitization purposes already.

As a separate note, something that might make sense at some point would be to
skip the memset in kzfree() if slab poisoning is enabled.


 \ /
  Last update: 2017-04-21 20:26    [W:0.151 / U:9.472 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site