Re: [PATCH v4 2/4] virt: tdx-guest: Calculate the Quote buffer size safely

From
Kiryl Shutsemau <kas@kernel.org>
Date
2026-09-16 12:26:25
Also in
kvm, lkml
Reply to
Peter Fang, 2026-09-15
On Tue, Sep 15, 2026 at 02:26:01AM -0700, Peter Fang wrote:
struct tdx_quote_buf has a trailing flexible array member.
struct_size_t() calculates the size of this kind of struct safely. It
handles overflow, which helps since the Quote size comes from the host.

Use it to rewrite the bounds check logic, since

  "header_size + data_len > buf_size"

...is more readable than "data_len > buf_size - header_size".

Signed-off-by: Peter Fang <redacted>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Tony Lindgren <redacted>
Reviewed-by: Xiaoyao Li <redacted>
Reviewed-by: Binbin Wu <redacted>
Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>

-- 
  Kiryl Shutsemau / Kirill A. Shutemov
Thread (29 messages) 29 messages, 6 authors, last reply 2026-09-22
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help