Re: [PATCH v9 42/43] virt: sevguest: Add support to derive key

From: Dov Murik
Date: Mon Feb 07 2022 - 14:16:50 EST




On 07/02/2022 18:23, Brijesh Singh wrote:
>
>
> On 2/7/22 2:52 AM, Borislav Petkov wrote:
>> Those are allocated on stack, why are you clearing them?
>
> Yep, no need to explicitly clear it. I'll take it out in next rev.
>

Wait, this is key material generated by PSP and passed to userspace.
Why leave copies of it floating around kernel memory? I thought that's
the whole reason for these memzero_explicit() calls (maybe add a comment?).

As an example, in arch/x86/crypto/aesni-intel_glue.c there are two calls
to memzero_explicit(), both on stack variables; the only reason for
these calls (as I understand it) is to avoid some future possible leak
of this sensitive data (keys, cipher context, etc.). I'm sure there are
other examples in the kernel code.


-Dov