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 lists.gnu.org (lists.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 1C54ED1A613 for ; Fri, 9 Jan 2026 12:48:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1veBoK-0004MH-BQ; Fri, 09 Jan 2026 07:41:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1veBoE-0003xh-Ez for qemu-devel@nongnu.org; Fri, 09 Jan 2026 07:41:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1veBoA-0007Lt-BO for qemu-devel@nongnu.org; Fri, 09 Jan 2026 07:41:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767962496; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=nMpYXW9meLSUzxVDZTHSFAAkKl4E5nHrrDYTRCdlJDE=; b=c8gJg/Pt/zlvJAf0LV8UfVH+NI+rh8cxPAFML+2Rcsudt9pUmeoQK7zL+Y4opBWQFytKd4 8NCcw+9SjgUdONkhzvwMNhccQgHFB8/9V4jfoZmobAsgpG6RGF1hwpBbvaVVvn6zVMMTlV EUz5RF4/3oJvy4tZFsB7Hnfa9rkElMY= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-399-Dbw2CB__N6W-F20kriGafA-1; Fri, 09 Jan 2026 07:41:35 -0500 X-MC-Unique: Dbw2CB__N6W-F20kriGafA-1 X-Mimecast-MFC-AGG-ID: Dbw2CB__N6W-F20kriGafA_1767962494 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-b7a29e6f9a0so407818566b.1 for ; Fri, 09 Jan 2026 04:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1767962494; x=1768567294; darn=nongnu.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=nMpYXW9meLSUzxVDZTHSFAAkKl4E5nHrrDYTRCdlJDE=; b=QfiUsJhRsxB/oouUfW7xZFp8iOmIuTIalm3tGyeQyn5oV22Wu3XQz2G6lcJdoYQ7qX /AowS3UoueMr2FbdKUpGUQCfYR38uqFA9S2ONGAASI3F7nLlmk4eVRDRoGLAVESyPrQ+ 4+2UEv7HXlkPSEJgRPKqjLdLzcoAGGvoIf8n0v9BTzIWVs+WUTwQlB+hoNgOmS0QvNDU 8Sc7wH4WNu2j68SY93ZZpHloEoeeDqdca1Wc1IymlqQNNMCHex/yE3qzDJGWohwgNhZM MXXsib6+tTSWqr9BXxu81VJCD8lcA1scjtlR5CVFLRt6O7pxuGhZiWt2TsUXgjuU5Tub Tamw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767962494; x=1768567294; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nMpYXW9meLSUzxVDZTHSFAAkKl4E5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:907:961d:b0:b83:975:f8a6 with SMTP id a640c23a62f3a-b844536955dmr882763966b.43.1767962493999; Fri, 09 Jan 2026 04:41:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3FPX2gGAORDXIEnDGpxpn4QLfvuvRYvlGEi/K8hDd9NuyzNp670Ed7V9zIu9GgDB2ykahOQ== X-Received: by 2002:a17:907:961d:b0:b83:975:f8a6 with SMTP id a640c23a62f3a-b844536955dmr882760766b.43.1767962493443; Fri, 09 Jan 2026 04:41:33 -0800 (PST) Received: from [192.168.0.9] ([47.64.114.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b842a517cf1sm1091066566b.59.2026.01.09.04.41.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Jan 2026 04:41:33 -0800 (PST) Message-ID: <75ea4764-6344-4584-b583-2e7316ddb81c@redhat.com> Date: Fri, 9 Jan 2026 13:41:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v7 09/29] s390x/diag: Implement DIAG 320 subcode 2 To: Zhuoying Cai , berrange@redhat.com, richard.henderson@linaro.org, david@redhat.com, jrossi@linux.ibm.com, qemu-s390x@nongnu.org, qemu-devel@nongnu.org, brueckner@linux.ibm.com Cc: 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, alifm@linux.ibm.com References: <20251208213247.702569-1-zycai@linux.ibm.com> <20251208213247.702569-10-zycai@linux.ibm.com> Content-Language: en-US From: Thomas Huth Autocrypt: addr=thuth@redhat.com; keydata= xsFNBFH7eUwBEACzyOXKU+5Pcs6wNpKzrlJwzRl3VGZt95VCdb+FgoU9g11m7FWcOafrVRwU yYkTm9+7zBUc0sW5AuPGR/dp3pSLX/yFWsA/UB4nJsHqgDvDU7BImSeiTrnpMOTXb7Arw2a2 4CflIyFq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SWj6XBDfA1AEdQkBOn ZH1Qt7HJesk+qNSnLv6+jP4VwqK5AFMrKJ6IjE7jqgzGxtcZnvSjeDGPF1h2CKZQPpTw890k fy18AvgFHkVk2Oylyexw3aOBsXg6ukN44vIFqPoc+YSU0+0QIdYJp/XFsgWxnFIMYwDpxSHS 5fdDxUjsk3UBHZx+IhFjs2siVZi5wnHIqM7eK9abr2cK2weInTBwXwqVWjsXZ4tq5+jQrwDK cvxIcwXdUTLGxc4/Z/VRH1PZSvfQxdxMGmNTGaXVNfdFZjm4fz0mz+OUi6AHC4CZpwnsliGV ODqwX8Y1zic9viSTbKS01ZNp175POyWViUk9qisPZB7ypfSIVSEULrL347qY/hm9ahhqmn17 Ng255syASv3ehvX7iwWDfzXbA0/TVaqwa1YIkec+/8miicV0zMP9siRcYQkyTqSzaTFBBmqD oiT+z+/E59qj/EKfyce3sbC9XLjXv3mHMrq1tKX4G7IJGnS989E/fg6crv6NHae9Ckm7+lSs IQu4bBP2GxiRQ+NV3iV/KU3ebMRzqIC//DCOxzQNFNJAKldPe/bKZMCxEqtVoRkuJtNdp/5a yXFZ6TfE1hGKrDBYAm4vrnZ4CXFSBDllL59cFFOJCkn4Xboj/aVxxJxF30bn In-Reply-To: <20251208213247.702569-10-zycai@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 On 08/12/2025 22.32, Zhuoying Cai wrote: > DIAG 320 subcode 2 provides verification-certificates (VCs) that are in the > certificate store. Only X509 certificates in DER format and SHA-256 hash > type are recognized. > > The subcode value is denoted by setting the second-left-most bit > of an 8-byte field. > > The Verification Certificate Block (VCB) contains the output data > when the operation completes successfully. It includes a common > header followed by zero or more Verification Certificate Entries (VCEs), > depending on the VCB input length and the VC range (from the first VC > index to the last VC index) in the certificate store. > > Each VCE contains information about a certificate retrieved from > the S390IPLCertificateStore, such as the certificate name, key type, > key ID length, hash length, and the raw certificate data. > The key ID and hash are extracted from the raw certificate by the crypto API. > > Note: SHA2-256 VC hash type is required for retrieving the hash > (fingerprint) of the certificate. > > Signed-off-by: Zhuoying Cai > --- ... > +struct VCEntry { > + uint32_t len; > + uint8_t flags; > + uint8_t key_type; > + uint16_t cert_idx; > + uint32_t name[16]; Why is this defined as an array of uint32_t when it is rather a string instead? > + uint8_t format; > + uint8_t reserved0; > + uint16_t keyid_len; > + uint8_t reserved1; > + uint8_t hash_type; > + uint16_t hash_len; > + uint32_t reserved2; > + uint32_t cert_len; > + uint32_t reserved3[2]; > + uint16_t hash_offset; > + uint16_t cert_offset; > + uint32_t reserved4[7]; > + uint8_t cert_buf[]; > +}; > +typedef struct VCEntry VCEntry; ... > diff --git a/target/s390x/diag.c b/target/s390x/diag.c > index 0e1897e03d..1498b29a0d 100644 > --- a/target/s390x/diag.c > +++ b/target/s390x/diag.c > @@ -17,6 +17,7 @@ > #include "s390x-internal.h" > #include "hw/watchdog/wdt_diag288.h" > #include "system/cpus.h" > +#include "hw/s390x/cert-store.h" > #include "hw/s390x/ipl.h" > #include "hw/s390x/ipl/diag320.h" > #include "hw/s390x/s390-virtio-ccw.h" > @@ -24,6 +25,7 @@ > #include "kvm/kvm_s390x.h" > #include "target/s390x/kvm/pv.h" > #include "qemu/error-report.h" > +#include "crypto/x509-utils.h" > > > static inline bool diag_parm_addr_valid(uint64_t addr, size_t size, bool write) > @@ -231,8 +233,330 @@ static int handle_diag320_query_vcsi(S390CPU *cpu, uint64_t addr, uint64_t r1, > return DIAG_320_RC_OK; > } > > +static bool is_cert_valid(S390IPLCertificate cert) You're using call-by-value for all S390IPLCertificate parameters in this patch ... that's quite cumbersome since the struct has a size of ~80 bytes. Unless there is a very good reason for doing so, I'd suggest that you switch the code to use (const) pointers instead of passing around that struct on the stack. > +{ > + int rc; > + Error *err = NULL; > + > + rc = qcrypto_x509_check_cert_times(cert.raw, cert.size, &err); > + if (rc != 0) { > + error_report_err(err); > + return false; > + } > + > + return true; > +} > + > +static void handle_key_id(VCEntry *vce, S390IPLCertificate cert) > +{ > + int rc; > + g_autofree unsigned char *key_id_data = NULL; > + size_t key_id_len; > + Error *err = NULL; > + > + key_id_len = CERT_KEY_ID_LEN; > + /* key id and key id len */ > + rc = qcrypto_x509_get_cert_key_id(cert.raw, cert.size, > + QCRYPTO_HASH_ALGO_SHA256, > + &key_id_data, &key_id_len, &err); > + if (rc < 0) { > + error_report_err(err); > + return; > + } > + > + if (VCE_HEADER_LEN + key_id_len > be32_to_cpu(vce->len)) { > + error_report("Unable to write key ID: exceeds buffer bounds"); > + return; > + } > + > + vce->keyid_len = cpu_to_be16(key_id_len); > + > + memcpy(vce->cert_buf, key_id_data, key_id_len); > +} > + > +static int handle_hash(VCEntry *vce, S390IPLCertificate cert, uint16_t keyid_field_len) > +{ > + int rc; > + uint16_t hash_offset; > + g_autofree void *hash_data = NULL; > + size_t hash_len; > + Error *err = NULL; > + > + hash_len = CERT_HASH_LEN; > + /* hash and hash len */ > + hash_data = g_malloc0(hash_len); > + rc = qcrypto_get_x509_cert_fingerprint(cert.raw, cert.size, > + QCRYPTO_HASH_ALGO_SHA256, > + hash_data, &hash_len, &err); > + if (rc < 0) { > + error_report_err(err); > + return -1; > + } > + > + hash_offset = VCE_HEADER_LEN + keyid_field_len; > + if (hash_offset + hash_len > be32_to_cpu(vce->len)) { > + error_report("Unable to write hash: exceeds buffer bounds"); > + return -1; > + } > + > + vce->hash_len = cpu_to_be16(hash_len); > + vce->hash_type = DIAG_320_VCE_HASHTYPE_SHA2_256; > + vce->hash_offset = cpu_to_be16(hash_offset); > + > + memcpy((uint8_t *)vce + hash_offset, hash_data, hash_len); > + > + return 0; > +} > + > +static int handle_cert(VCEntry *vce, S390IPLCertificate cert, uint16_t hash_field_len) > +{ > + int rc; > + uint16_t cert_offset; > + g_autofree uint8_t *cert_der = NULL; > + Error *err = NULL; > + > + /* certificate in DER format */ > + rc = qcrypto_x509_convert_cert_der(cert.raw, cert.size, > + &cert_der, &cert.der_size, &err); > + if (rc < 0) { > + error_report_err(err); > + return -1; > + } > + > + cert_offset = be16_to_cpu(vce->hash_offset) + hash_field_len; > + if (cert_offset + cert.der_size > be32_to_cpu(vce->len)) { > + error_report("Unable to write certificate: exceeds buffer bounds"); > + return -1; > + } > + > + vce->format = DIAG_320_VCE_FORMAT_X509_DER; > + vce->cert_len = cpu_to_be32(cert.der_size); > + vce->cert_offset = cpu_to_be16(cert_offset); > + > + memcpy((uint8_t *)vce + cert_offset, cert_der, cert.der_size); > + > + return 0; > +} > + > +static int get_key_type(S390IPLCertificate cert) > +{ > + int algo; > + int rc; > + Error *err = NULL; > + > + /* public key algorithm */ > + algo = qcrypto_x509_get_pk_algorithm(cert.raw, cert.size, &err); > + if (algo < 0) { > + error_report_err(err); > + return -1; > + } > + > + if (algo == QCRYPTO_PK_ALGO_ECDSA) { > + rc = qcrypto_x509_check_ecc_curve_p521(cert.raw, cert.size, &err); > + if (rc == -1) { > + error_report_err(err); > + return -1; > + } > + > + return (rc == 1) ? DIAG_320_VCE_KEYTYPE_ECDSA_P521 : > + DIAG_320_VCE_KEYTYPE_SELF_DESCRIBING; > + } > + > + return DIAG_320_VCE_KEYTYPE_SELF_DESCRIBING; > +} > + > +static int build_vce_header(VCEntry *vce, S390IPLCertificate cert, int idx) > +{ > + int key_type; > + > + vce->len = cpu_to_be32(VCE_HEADER_LEN); > + vce->cert_idx = cpu_to_be16(idx + 1); > + strncpy((char *)vce->name, (char *)cert.vc_name, VC_NAME_LEN_BYTES); strncpy is often tripping up static analyzers when you use it like this. Please consider using memcpy(), pstrcpy() or strpadcpy() instead. (I guess memcpy is the right thing to use here since vc_name has already been initialized with strpadcpy ?) > + key_type = get_key_type(cert); > + if (key_type == -1) { > + return -1; > + } > + vce->key_type = key_type; > + > + return 0; > +} Thomas