Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75EC9C44506 for ; Tue, 7 Jul 2026 23:13:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1whExg-0006tX-HO; Tue, 07 Jul 2026 19:12:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1whExd-0006s0-1F; Tue, 07 Jul 2026 19:12:18 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1whExa-0008JS-5t; Tue, 07 Jul 2026 19:12:15 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 667Mmdw9184831; Tue, 7 Jul 2026 23:12:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=zlFBXdYXtqnpNmqU/ hlv3/B8V8U3kKjlERrzui/5cL0=; b=Tolt7Jq3mUYEVMzsIro2DWwBicWDQdddt ZO4jSVTYGM31Hq9hl9NIuDSy8ZYzJrHAE1FK2TD49f64kwz2yBJ7WiZpfj1fDdIE KZaQeTdRnDwtW6SmpfQlxCIbprfoZutl3wT2Xfrc6yGhoefObZVoHqacgjEgq7G1 /myeEWdTPEU/9Iuzv6vbEScIwQ5wssD0iMQSZ6nQOgjGZmKbiNSiUS86uREK0ZkL xBTTyribBsGKvYCsOLfrhoZ4VS//Ur1qsOmPHoEtuDINHL08wZNn60uHCq9BGNJo XwNwrFgJ/dLqvCiRJsfXoaTLD+YEF5bxeqoiPxXie86bqjzDVyGbg== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4f6rkdt8hj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2026 23:12:11 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 667N4fYd017948; Tue, 7 Jul 2026 23:12:10 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4f7dgk52rc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2026 23:12:10 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 667NC9eD61473208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Jul 2026 23:12:09 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A8E958045; Tue, 7 Jul 2026 23:12:09 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 604C858056; Tue, 7 Jul 2026 23:12:06 +0000 (GMT) Received: from fedora-workstation.ibmuc.com (unknown [9.61.32.2]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 7 Jul 2026 23:12:06 +0000 (GMT) From: Zhuoying Cai To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Cc: jrossi@linux.ibm.com, cohuck@redhat.com, berrange@redhat.com, richard.henderson@linaro.org, david@kernel.org, walling@linux.ibm.com, jjherne@linux.ibm.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, mjrosato@linux.ibm.com, iii@linux.ibm.com, eblake@redhat.com, armbru@redhat.com, zycai@linux.ibm.com, alifm@linux.ibm.com, brueckner@linux.ibm.com, pierrick.bouvier@oss.qualcomm.com, jdaley@linux.ibm.com Subject: [PATCH v16 10/33] hw/s390x: Define finite size for single entry VCEntry Date: Tue, 7 Jul 2026 19:11:08 -0400 Message-ID: <20260707231132.2492104-11-zycai@linux.ibm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260707231132.2492104-1-zycai@linux.ibm.com> References: <20260707231132.2492104-1-zycai@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=M7J97Sws c=1 sm=1 tr=0 ts=6a4d87cb cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=HeWPiYe96b1ufxwsDYQA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzA3MDIyNCBTYWx0ZWRfX0BYdClRJITx4 Rp1b8zmBwcDmfOWX3g1vBV+WU3bM0J95HVIa9uSumetMYV4f+YE0IJcD7x2ULtlGBLpfJamC+Bm oeC0Tpwe5gi/WNtJqz+65/5Bok2mA4POVQ2ZrERXrCcxgCcpCAnNAs9boQqkG427RZvUcCWFymJ UmtfcH3NO0VJ1WaEz5992bVNFDi0q90jts1pRQ04x6Yu0zmOGJSEtAXP0/ExAvQr5NaoxR7A2Q3 dSBQSoZ5VQqFFAT1AAT7NcAlADHERk80bIQM02YfWBDBDZHDsGXcOQCFLqPX4oHUOfPEjmTBdYp h7+zclRWWPs4mB3DzAfAx2sXtASXwMRDRTubHj7Kg5oeHbpwpuFPxg4yXDJAq4nnVXje/oXXAh+ RT+ahn9P6fUHjbvYQudLvPuvBB/KmA0kAD90NtBB4iY/mpJEqIQ4cnVZwFf4tf7LyrYgVUm1xgK QNKGiiHnfs8wb+pjBgQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzA3MDIyNCBTYWx0ZWRfX5ha2tdIsidxN tpwCnx0GrVE7HyVaNndOeWHi66jLk2tIekC9PiqC8gAASLKvuWW5qmyjCXkcgOHI4NdtkCN4vTs jc0/svYZXcluQtcfu3o90I1yWqiP6fI= X-Proofpoint-GUID: CIabpiMC36OIxJ4ixIZmw0d3g9g2t6rH X-Proofpoint-ORIG-GUID: CIabpiMC36OIxJ4ixIZmw0d3g9g2t6rH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-07_06,2026-07-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 priorityscore=1501 bulkscore=0 spamscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607070224 Received-SPF: pass client-ip=148.163.158.5; envelope-from=zycai@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 Reviewed-by: Matthew Rosato Reviewed-by: Eric Farman --- hw/s390x/cert-store.c | 6 ++++++ include/hw/s390x/ipl/diag320.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/hw/s390x/cert-store.c b/hw/s390x/cert-store.c index c679406c2c..c086e75f75 100644 --- a/hw/s390x/cert-store.c +++ b/hw/s390x/cert-store.c @@ -91,6 +91,12 @@ static int update_cert_store(S390IPLCertificateStore *cert_store, cert_buf_size = ROUND_UP(cert->der_size, 4); data_buf_size = keyid_buf_size + hash_buf_size + cert_buf_size; + if (data_buf_size > CERT_BUF_MAX_LEN) { + error_report("Certificate data size %zu exceeds maximum buffer size %zu", + data_buf_size, CERT_BUF_MAX_LEN); + return -1; + } + if (cert_store->largest_cert_size < data_buf_size) { cert_store->largest_cert_size = data_buf_size; } diff --git a/include/hw/s390x/ipl/diag320.h b/include/hw/s390x/ipl/diag320.h index 7fda2d44fd..f3c23a3176 100644 --- a/include/hw/s390x/ipl/diag320.h +++ b/include/hw/s390x/ipl/diag320.h @@ -92,6 +92,9 @@ struct VCEntry { }; typedef struct VCEntry VCEntry; +#define MAX_VCENTRY_SIZE (8 * 1024) +#define CERT_BUF_MAX_LEN (MAX_VCENTRY_SIZE - sizeof(VCEntryHeader)) + struct VCBlockHeader { uint32_t in_len; uint32_t reserved0; -- 2.54.0