Re: [Part2 PATCH v6 32/38] KVM: SVM: Add support for SEV DEBUG_DECRYPT command

From: Borislav Petkov
Date: Mon Oct 30 2017 - 11:12:39 EST


On Mon, Oct 30, 2017 at 08:56:13AM -0500, Brijesh Singh wrote:
> I am not able to reproduce the build warning in my setup, what config
> option or compiler you are using to trigger this issue ?

gcc7 has gotten smarter.

> I am on Fedora with gcc 6.4.x. Logically, the code looks okay. I can
> try to rearrange code to fix the warning. I have not touched this
> function since couple of rev, have u seen similar warning in previous
> versions (v5, v4 etc). thanks

Lemme see:

sev_dbg_crypt() does

ret = __sev_dbg_decrypt(kvm,
__sme_page_pa(src_p[0]) + s_off,
dst_vaddr, 0,
__sme_page_pa(dst_p[0]) + d_off,
len, &argp->error);

and that 4th argument is 0. IINM, that's dst_kaddr and you're doing

memcpy((void *)dst_kaddr, page_address(tpage) + offset, size);
^^^^^^^^^^^^^^^^

BOOM!

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.