[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <cf4e12dbe7d8d759ff87e088ade54bd710926d1e.1689893403.git.isaku.yamahata@intel.com>
Date: Thu, 20 Jul 2023 16:32:56 -0700
From: isaku.yamahata@...el.com
To: kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: isaku.yamahata@...el.com, isaku.yamahata@...il.com,
Michael Roth <michael.roth@....com>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>, erdemaktas@...gle.com,
Sagi Shahar <sagis@...gle.com>,
David Matlack <dmatlack@...gle.com>,
Kai Huang <kai.huang@...el.com>,
Zhi Wang <zhi.wang.linux@...il.com>, chen.bo@...el.com,
linux-coco@...ts.linux.dev,
Chao Peng <chao.p.peng@...ux.intel.com>,
Ackerley Tng <ackerleytng@...gle.com>,
Vishal Annapurve <vannapurve@...gle.com>,
Yuan Yao <yuan.yao@...ux.intel.com>
Subject: [RFC PATCH v4 10/10] KVM: X86: KVM_MEM_ENC_OP check if unused field (flags, error) is zero
From: Isaku Yamahata <isaku.yamahata@...el.com>
This breaks uABI as the current code doesn't check padding and sev_fd
when unused.
Signed-off-by: Isaku Yamahata <isaku.yamahata@...el.com>
---
Changes v3 -> v4:
- newly added
---
arch/x86/kvm/x86.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ab36e8940f1b..1d6085af6a00 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7055,6 +7055,22 @@ int kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg)
r = -EFAULT;
goto out;
}
+ /* No sub-command uses flags at the moment. */
+ if (cmd.flags) {
+ r = -EINVAL;
+ goto out;
+ }
+ if (cmd.id != KVM_SEV_LAUNCH_START &&
+ cmd.id != KVM_SEV_RECEIVE_START && cmd.error64) {
+ r = -EINVAL;
+ goto out;
+ }
+ if ((cmd.id == KVM_SEV_LAUNCH_START ||
+ cmd.id == KVM_SEV_RECEIVE_START) && cmd.error) {
+ r = -EINVAL;
+ goto out;
+ }
+
r = static_call(kvm_x86_mem_enc_ioctl)(kvm, &cmd);
if (copy_to_user(argp, &cmd, sizeof(cmd)))
r = -EFAULT;
--
2.25.1
Powered by blists - more mailing lists