Re: [PATCH v3 05/11] KVM: SVM: Add KVM_SEV_RECEIVE_UPDATE_DATA command

From: Peter Gonda
Date: Thu Nov 14 2019 - 16:02:43 EST


> +
> + /* Check if we are crossing the page boundry */
> + offset = params.guest_uaddr & (PAGE_SIZE - 1);
> + if ((params.guest_len + offset > PAGE_SIZE))
> + return -EINVAL;

Just curious spec only says that "System physical of the guest memory
region. Must be 16 B aligned with the C-bit set." and "Length of guest
memory region. Must be a multiple of 16 B and no more than 16 kB". Why
do we want to avoid crossing a page boundary?

Also is there an overflow concern in the conditional because
params.guest_len is not checked before this?

> +
> + data = kzalloc(sizeof(*data), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
> +
> + hdr = psp_copy_user_blob(params.hdr_uaddr, params.hdr_len);
> + if (IS_ERR(hdr)) {
> + ret = PTR_ERR(hdr);
> + goto e_free;
> + }
> +