hw/s390x: Define finite size for single entry VCEntry
Define MAX_VCENTRY_SIZE(8KB) and CERT_BUF_MAX_LEN to establish a finite size for a single entry VCEntry. Add validation in update_cert_store() to ensure certificate data does not exceed this limit. This finite size definition is needed for proper memory allocation and will be used in a later commit to handle VCEntry structures with known size constraints. Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Reviewed-by: Eric Farman <farman@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260730214624.2328883-11-zycai@linux.ibm.com Signed-off-by: Eric Farman <farman@linux.ibm.com>
Zhuoying Cai committed
Jul 30, 2026 at 17:45 UTC
327a56d0dc901340edfebc2bb53cc6b740869302
2 files changed
+9
hw/s390x/cert-store.c
+6
@@ -91,6 +91,12 @@ static int update_cert_store(S390IPLCertificateStore *cert_store,
91
cert_buf_size = ROUND_UP(cert->der_size, 4);
92
data_buf_size = keyid_buf_size + hash_buf_size + cert_buf_size;
93
94
+ if (data_buf_size > CERT_BUF_MAX_LEN) {
95
+ error_report("Certificate data size %zu exceeds maximum buffer size %zu",
96
+ data_buf_size, CERT_BUF_MAX_LEN);
97
+ return -1;
98
+ }
99
+
100
if (cert_store->largest_cert_size < data_buf_size) {
101
cert_store->largest_cert_size = data_buf_size;
102
}
include/hw/s390x/ipl/diag320.h
+3
@@ -92,6 +92,9 @@ struct VCEntry {
92
};
93
typedef struct VCEntry VCEntry;
94
95
+#define MAX_VCENTRY_SIZE (8 * 1024)
96
+#define CERT_BUF_MAX_LEN (MAX_VCENTRY_SIZE - sizeof(VCEntryHeader))
97
+
98
struct VCBlockHeader {
99
uint32_t in_len;
100
uint32_t reserved0;