KEYS: Use memzero_explicit() for secret data
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 9 Feb 2017 17:18:00 +0000 (17:18 +0000)
committerJames Morris <james.l.morris@oracle.com>
Fri, 10 Feb 2017 01:43:51 +0000 (12:43 +1100)
I don't think GCC has figured out how to optimize the memset() away, but
they might eventually so let's future proof this code a bit.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
security/keys/encrypted-keys/encrypted.c

index d7a4969..4fb315c 100644 (file)
@@ -985,7 +985,7 @@ static void encrypted_destroy(struct key *key)
        if (!epayload)
                return;
 
-       memset(epayload->decrypted_data, 0, epayload->decrypted_datalen);
+       memzero_explicit(epayload->decrypted_data, epayload->decrypted_datalen);
        kfree(key->payload.data[0]);
 }