Re: [PATCH v11 8/8] x86/vmware: Add TDX hypercall support

Dave Hansen
2024-06-14T16:03:25Z

On 6/13/24 12:16, Alexey Makhalov wrote:
> +unsigned long vmware_tdx_hypercall(unsigned long cmd,
> + unsigned long in1, unsigned long in3,
> + unsigned long in4, unsigned long in5,
> + u32 *out1, u32 *out2, u32 *out3,
> + u32 *out4, u32 *out5)
> +{
> + struct tdx_module_args args;
> +
> + if (!hypervisor_is_type(X86_HYPER_VMWARE)) {
> + pr_warn_once("Incorrect usage\n");
> + return ULONG_MAX;
> + }
> +
> + if (cmd & ~VMWARE_CMD_MASK) {
> + pr_warn_once("Out of range command %lx\n", cmd);
> + return ULONG_MAX;
> + }
> +
> + args.rbx = in1;
> + args.rdx = in3;
> + args.rsi = in4;
> + args.rdi = in5;
> + args.r10 = VMWARE_TDX_VENDOR_LEAF;
> + args.r11 = VMWARE_TDX_HCALL_FUNC;
> + args.r12 = VMWARE_HYPERVISOR_MAGIC;
> + args.r13 = cmd;
> + args.r15 = 0; /* CPL */

I believe this leaks stack data into the hypervisor. Or did I miss the
zeroing of rcx/r8/r9/r14?

You need to zero out all of 'args' somehow.