From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> This breaks uABI as the current code doesn't check padding and sev_fd when unused. Signed-off-by: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> --- 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