Re: [PATCH] x86/sev: Fix overflow when computing address for PVALIDATE

From: Dave Hansen
Date: Sun Nov 12 2023 - 01:50:06 EST


On 11/10/23 18:00, Michael Roth wrote:
> - vaddr = (unsigned long)pfn_to_kaddr(e->gfn);
> + vaddr = (unsigned long)pfn_to_kaddr((unsigned long)e->gfn);
> size = e->pagesize ? RMP_PG_SIZE_2M : RMP_PG_SIZE_4K;
> validate = e->operation == SNP_PAGE_STATE_PRIVATE;
>

... and people wonder why some of us avoid bitfields.

Shouldn't we just fix this permanently in pfn_to_kaddr()? Surely more
of these are lurking around. Anything doing a large shift up on a
little type is asking for trouble.