[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <176350821965.2285420.6497416938072757840.b4-ty@google.com>
Date: Tue, 18 Nov 2025 15:27:54 -0800
From: Sean Christopherson <seanjc@...gle.com>
To: Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini <pbonzini@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>, "Kirill A. Shutemov" <kas@...nel.org>,
Rick Edgecombe <rick.p.edgecombe@...el.com>, Thorsten Blum <thorsten.blum@...ux.dev>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-coco@...ts.linux.dev
Subject: Re: [PATCH] KVM: TDX: Use struct_size and simplify tdx_get_capabilities
On Fri, 17 Oct 2025 23:39:14 +0200, Thorsten Blum wrote:
> Retrieve the number of user entries with get_user() first and return
> -E2BIG early if 'user_caps' is too small to fit 'caps'.
>
> Allocate memory for 'caps' only after checking the user buffer's number
> of entries, thus removing two gotos and the need for premature freeing.
>
> Use struct_size() instead of manually calculating the number of bytes to
> allocate for 'caps', including the nested flexible array.
>
> [...]
Applied to kvm-x86 tdx, with Rick's tags and suggested fixups from the RESEND[*]
(I had already applied the original patches, and now that these have been in
linux-next for a while, I don't want to modify the hashes just to change the
patch Link).
[*] https://lore.kernel.org/all/20251112171630.3375-1-thorsten.blum@linux.dev
[1/2] KVM: TDX: Check size of user's kvm_tdx_capabilities array before allocating
https://github.com/kvm-x86/linux/commit/11b79f8318ae
[2/2] KVM: TDX: Use struct_size to simplify tdx_get_capabilities()
https://github.com/kvm-x86/linux/commit/398180f93cf3
--
https://github.com/kvm-x86/linux/tree/next
Powered by blists - more mailing lists