mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2026-10-20 19:23:40 +00:00
KVM: TDX: Replace kmalloc + copy_from_user with memdup_user in tdx_td_init()
Use get_user() to retrieve the number of entries instead of allocating memory for 'init_vm' with the maximum size, copying 'cmd->data' to it, only to then read the actual entry count 'cpuid.nent' from the copy. Use memdup_user() to allocate just enough memory to fit all entries and to copy 'cmd->data' from userspace. Use struct_size() instead of manually calculating the number of bytes to allocate and copy. No functional changes intended. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Link: https://lore.kernel.org/r/20250916213129.2535597-2-thorsten.blum@linux.dev [sean: s/user_init_vm/user_data] Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
f505c7b16f
commit
0bd0a4a142
1 changed files with 10 additions and 20 deletions
Loading…
Add table
Add a link
Reference in a new issue