]> git.ipfire.org Git - thirdparty/linux.git/commit
KVM: TDX: Use struct_size to simplify tdx_get_capabilities()
authorSean Christopherson <seanjc@google.com>
Mon, 10 Nov 2025 21:24:53 +0000 (13:24 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 13 Nov 2025 16:30:07 +0000 (08:30 -0800)
commit398180f93cf3c7bb0ee3f512b139ad01843f3ddf
treeb611205efc331f1978b4b5c12923bb571e4ab236
parent11b79f8318aefc7ddfd12668fd1d80bde1c9f7bc
KVM: TDX: Use struct_size to simplify tdx_get_capabilities()

Use struct_size() instead of manually calculating the number of bytes to
allocate for 'caps', including the nested flexible array, and copy all of
'caps' to user space with a single copy_to_user() call (thanks to the full
size being provided by struct_size()).

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Tested-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Link: https://patch.msgid.link/20251017213914.167301-1-thorsten.blum@linux.dev
[sean: separate from swap of get_user() vs. kzalloc() ordering]
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/tdx.c