[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMkAt6rrwWteTaA4zJO1D3qd12P+8Qa68hjwsSEb+0AVcsjk7A@mail.gmail.com>
Date: Tue, 12 Nov 2019 14:23:06 -0800
From: Peter Gonda <pgonda@...gle.com>
To: "Singh, Brijesh" <brijesh.singh@....com>
Cc: "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
Joerg Roedel <joro@...tes.org>, Borislav Petkov <bp@...e.de>,
"Lendacky, Thomas" <Thomas.Lendacky@....com>,
"x86@...nel.org" <x86@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 02/11] KVM: SVM: Add KVM_SEND_UPDATE_DATA command
On Wed, Jul 10, 2019 at 1:14 PM Singh, Brijesh <brijesh.singh@....com> wrote:
> +static int sev_send_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp)
> +{
> + struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
> + struct sev_data_send_update_data *data;
> + struct kvm_sev_send_update_data params;
> + void *hdr = NULL, *trans_data = NULL;
> + struct page **guest_page = NULL;
> + unsigned long n;
> + int ret, offset;
> +
> + if (!sev_guest(kvm))
> + return -ENOTTY;
> +
> + if (copy_from_user(¶ms, (void __user *)(uintptr_t)argp->data,
> + sizeof(struct kvm_sev_send_update_data)))
> + return -EFAULT;
> +
> + data = kzalloc(sizeof(*data), GFP_KERNEL);
> + if (!data)
> + return -ENOMEM;
> +
> + /* userspace wants to query either header or trans length */
> + if (!params.trans_len || !params.hdr_len)
> + goto cmd;
> +
> + ret = -EINVAL;
> + if (!params.trans_uaddr || !params.guest_uaddr ||
> + !params.guest_len || !params.hdr_uaddr)
> + goto e_free;
> +
> + /* Check if we are crossing the page boundry */
> + ret = -EINVAL;
> + offset = params.guest_uaddr & (PAGE_SIZE - 1);
> + if ((params.guest_len + offset > PAGE_SIZE))
> + goto e_free;
> +
> + ret = -ENOMEM;
> + hdr = kmalloc(params.hdr_len, GFP_KERNEL);
> + if (!hdr)
> + goto e_free;
Should we be checking params.hdr_len against SEV_FW_BLOB_MAX_SIZE?
> +
> + data->hdr_address = __psp_pa(hdr);
> + data->hdr_len = params.hdr_len;
> +
> + ret = -ENOMEM;
> + trans_data = kmalloc(params.trans_len, GFP_KERNEL);
> + if (!trans_data)
> + goto e_free;
Ditto, should we be checking params.hdr_len against SEV_FW_BLOB_MAX_SIZE?
Powered by blists - more mailing lists