From nobody Sat Jul 25 19:30:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784021711; cv=none; d=zohomail.com; s=zohoarc; b=jiTzkmaE6JnEPW02x74PZ/CI+EEkL6qIYNnLdarCTPPBmo7wx3b92kud92zRuOW939EVOU7Mz6sUitIjhbYNi+mD6DLrRaF6SnDB78qH45jrfzC7CSSyWlAwi1IL2GRV4lWLlzPyGnqT9qJa1c4vfgDkK8a8JZbQTSVrr/rdSe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784021711; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RpqPu6Ft673rxadU8U4q5p7PwhY65vWe7XWmoTLN7tM=; b=n9H4HcHFar/jtS3LJpC3AiEJb/TMKN7AfTpWp9hQbqgfJ0p6lhOHmzXY75BPcc+uZh6gDa8FjBqJbQheqn85uwwTtxsMlGeJ5NLDRKLha8msNNEh43n9Sm9K2WOUH+Ecf0VrOjrBWZ5iIXfvBaZKPVlmZWPJEmo8BPBeMTQ3p7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784021711388240.47415379488723; Tue, 14 Jul 2026 02:35:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wjZXe-0005dE-Lh; Tue, 14 Jul 2026 05:35:06 -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 1wjZXd-0005cr-D6 for qemu-devel@nongnu.org; Tue, 14 Jul 2026 05:35:05 -0400 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 1wjZXb-00019W-LQ for qemu-devel@nongnu.org; Tue, 14 Jul 2026 05:35:05 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-690-qtVcUgfdPK29frIrDXJNzQ-1; Tue, 14 Jul 2026 05:33:10 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AA699195605A; Tue, 14 Jul 2026 09:33:08 +0000 (UTC) Received: from gondolin.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8FBF0D6E; Tue, 14 Jul 2026 09:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784021702; 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; bh=RpqPu6Ft673rxadU8U4q5p7PwhY65vWe7XWmoTLN7tM=; b=U+S43YdK1ZvyJjRNRpAHJPUisgG4eVvp4v3euE0rbJYCfeyjVuk1WXFhhzaUOHXCf6CXUM INM0EALuHuKXPohMqkvHOlK1hzcsmBbIuLT3r2ES8MkF0/R8AkmbFM/CHfGfCAwbFErUxS 0EL1BL+jE1mgChC4S5CusYUFvoljsUk= X-MC-Unique: qtVcUgfdPK29frIrDXJNzQ-1 X-Mimecast-MFC-AGG-ID: qtVcUgfdPK29frIrDXJNzQ_1784021588 From: Cornelia Huck To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, Christian Borntraeger , qemu-stable@nongnu.org, Matthew Rosato , Eric Farman , Collin Walling , Cornelia Huck Subject: [PULL for-11.1 1/3] s390x/sclp: prevent re-reading the sclp header Date: Tue, 14 Jul 2026 11:32:58 +0200 Message-ID: <20260714093300.2193848-2-cohuck@redhat.com> In-Reply-To: <20260714093300.2193848-1-cohuck@redhat.com> References: <20260714093300.2193848-1-cohuck@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: permerror client-ip=170.10.129.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1784021713255158500 Content-Type: text/plain; charset="utf-8" From: Christian Borntraeger We verify the sccb length and then allocate based on that length. The following access re-reads the sccb again. This can race against other vCPUs overwriting the length field. sclp_service_call_protected does not need a change as the ultravisor provides a consistent snapshot. Fixes: c1db53a5910f ("s390/sclp: read sccb from mem based on provided lengt= h") Cc: qemu-stable@nongnu.org Signed-off-by: Christian Borntraeger Reviewed-by: Matthew Rosato Reviewed-by: Eric Farman Reviewed-by: Collin Walling Message-ID: <20260709142906.197474-2-borntraeger@linux.ibm.com> Signed-off-by: Cornelia Huck --- hw/s390x/sclp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 2d2cde7803ff..3c8cb164888f 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -329,7 +329,8 @@ int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint= 32_t code) /* * we want to work on a private copy of the sccb, to prevent guests * from playing dirty tricks by modifying the memory content after - * the host has checked the values + * the host has checked the values. + * Reuse the previously fetched header */ work_sccb =3D g_malloc0(be16_to_cpu(header.length)); ret =3D address_space_read(as, sccb, attrs, @@ -337,6 +338,7 @@ int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint= 32_t code) if (ret !=3D MEMTX_OK) { return -PGM_ADDRESSING; } + work_sccb->h =3D header; =20 if (!sclp_command_code_valid(code)) { work_sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_CO= MMAND); --=20 2.55.0 From nobody Sat Jul 25 19:30:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784021642; cv=none; d=zohomail.com; s=zohoarc; b=fUAL/CdQxA1Z3QUYde9CestcLWum3wB0Y07E3CKoq4HeurYV8DKRIJHradHtsYUvamaoVM2rIgFywpSFYNt72KzQy3uKE0IBj32cyQVZSlSc3/5K+Skskc2McxgWDpf5ljNU605yAEdiy3j5Nh3L6XIsB/XqeZSC0owFyJXJ6Js= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784021642; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=iDKgAs2x1Nfh0CRXksnOX3J7Z0BVFqSTf5B3EBdO7Og=; b=Iq3+lWUrxNRSNxIdszk/mOLPvwF47YkjM+FYlwtj1T5sLOvbKn+XaNMEuaXaJ2ionf4Mrw/dJ80ZuCdR6kUizC5iVLPfIjnxKB2tjuK/lMzVYzKYiXEtDcYDTTpSOZu7lCBX5fNoMB2rv4xGP82i8So3jD/v+fjchcQPybGH5bE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784021642297363.1222244483997; Tue, 14 Jul 2026 02:34:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wjZVy-0003uL-8n; Tue, 14 Jul 2026 05:33:22 -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 1wjZVv-0003sD-52 for qemu-devel@nongnu.org; Tue, 14 Jul 2026 05:33:19 -0400 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 1wjZVt-000114-Nm for qemu-devel@nongnu.org; Tue, 14 Jul 2026 05:33:18 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-201-p7WE2GvSO5qKUszCFTP12w-1; Tue, 14 Jul 2026 05:33:12 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F2478195606A; Tue, 14 Jul 2026 09:33:10 +0000 (UTC) Received: from gondolin.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 10033D6E; Tue, 14 Jul 2026 09:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784021597; 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; bh=iDKgAs2x1Nfh0CRXksnOX3J7Z0BVFqSTf5B3EBdO7Og=; b=J/2zAD/BU9tZ5sUO7+dqNICLYIM27J2/rRm8rHz8VhzRejRMvnVtSDHs+YONFg+UXBtsG1 /KpfhqOtXntTFW4TROSrBbngwCaL/4aFyNfAfeEUiLeAg3RBW5bRFfGq9RxBz862A7NHHO ob9VfrigJV/G/1nGwUpaao+DuoUb6Us= X-MC-Unique: p7WE2GvSO5qKUszCFTP12w-1 X-Mimecast-MFC-AGG-ID: p7WE2GvSO5qKUszCFTP12w_1784021591 From: Cornelia Huck To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, Christian Borntraeger , qemu-stable@nongnu.org, Matthew Rosato , Janosch Frank , Eric Farman , Cornelia Huck Subject: [PULL for-11.1 2/3] s390x/sclpcpi: check event length field before reading from buffer Date: Tue, 14 Jul 2026 11:32:59 +0200 Message-ID: <20260714093300.2193848-3-cohuck@redhat.com> In-Reply-To: <20260714093300.2193848-1-cohuck@redhat.com> References: <20260714093300.2193848-1-cohuck@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: permerror client-ip=170.10.129.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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.01, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 autolearn=no 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1784021644752158500 Content-Type: text/plain; charset="utf-8" From: Christian Borntraeger A guest might send a too short SCCB with SCLP_EVENT_CTRL_PGM_ID. QEMU would fill its data structures with garbage data. Check for the precise length of the CBI data structure and reject otherwise. Fixes: f345978f24be ("hw/s390x: add Control-Program Identification to QOM") Cc: qemu-stable@nongnu.org Signed-off-by: Christian Borntraeger Reviewed-by: Matthew Rosato Reviewed-by: Janosch Frank Reviewed-by: Eric Farman Message-ID: <20260709142906.197474-3-borntraeger@linux.ibm.com> Signed-off-by: Cornelia Huck --- hw/s390x/sclpcpi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/s390x/sclpcpi.c b/hw/s390x/sclpcpi.c index 68fc1b809bf3..ec4bdf23509b 100644 --- a/hw/s390x/sclpcpi.c +++ b/hw/s390x/sclpcpi.c @@ -97,6 +97,11 @@ static int write_event_data(SCLPEvent *event, EventBuffe= rHeader *evt_buf_hdr) ebh); SCLPEventCPI *e =3D SCLP_EVENT_CPI(event); =20 + /* Caller checks sccb length, buffer header checking is our duty */ + if (be16_to_cpu(evt_buf_hdr->length) !=3D sizeof(ControlProgramIdMsg))= { + return SCLP_RC_INCONSISTENT_LENGTHS; + } + ascii_put(e->system_type, (char *)cpim->data.system_type, sizeof(cpim->data.system_type)); ascii_put(e->system_name, (char *)cpim->data.system_name, --=20 2.55.0 From nobody Sat Jul 25 19:30:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1784021637; cv=none; d=zohomail.com; s=zohoarc; b=PZN5AZBPMxvPrCzPpJ8RxWF+deVIDUusBj8JnrCSeouhAYkbkKyxaFsld8wk4sdi8s7s2fOzEbfley9PvKr8PZ9udD4K9JyYHD9Pgpq+kJTOaggSCVF/TbD1lkW2VBPYqc1u3i2nsGx7VDSKIO71bQG5FLkdc2wpHBInaSw7R7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784021637; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6ktwNSG+9SYLt3awQYC3iZDbrlo8kvB62BAXH9bVMoY=; b=DQ7Ke8NvP9/V2QJreUaE2+aT7uspfNXCJ3kufQFozsDxti9ODeG7nnZi9PH0vUERnTWUtV4rwNA7SNLvKHDcLOwEVm+MjBrY1zo6yXtqMdYNsCM3WBnE9CEm+Lg4FC3WbijhenuTobbMTCQW1lgBM5hI86/8AQ+cN03lInAAD0c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1784021637192886.5811345574571; Tue, 14 Jul 2026 02:33:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wjZVx-0003tc-RB; Tue, 14 Jul 2026 05:33:21 -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 1wjZVu-0003sB-LE for qemu-devel@nongnu.org; Tue, 14 Jul 2026 05:33:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wjZVs-00010v-Vb for qemu-devel@nongnu.org; Tue, 14 Jul 2026 05:33:18 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-582-uCvt9NDkMGyGLT9XoGidsg-1; Tue, 14 Jul 2026 05:33:14 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2D8DB1802666; Tue, 14 Jul 2026 09:33:13 +0000 (UTC) Received: from gondolin.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 57DEDD6E; Tue, 14 Jul 2026 09:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1784021596; 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; bh=6ktwNSG+9SYLt3awQYC3iZDbrlo8kvB62BAXH9bVMoY=; b=guccBWolR4N2ZLIrKssgXgsSxB35ZHBEHPWTdNN1FGyfAYtsAq4iVGgA61zTbPREoEQcQQ 74TWMECKhNVy1uVbv75lAEE/V6rUwjcjtAIKyJduSFae0bcIEKK+u9Xp8SistmGCsFSt8k JXf4X2zEMBdC7OuxDmqFMxZyFX3FBFM= X-MC-Unique: uCvt9NDkMGyGLT9XoGidsg-1 X-Mimecast-MFC-AGG-ID: uCvt9NDkMGyGLT9XoGidsg_1784021593 From: Cornelia Huck To: qemu-devel@nongnu.org Cc: qemu-s390x@nongnu.org, Eric Farman , qemu-stable@nongnu.org, Christian Borntraeger , Farhan Ali , Cornelia Huck Subject: [PULL for-11.1 3/3] s390x/css: firm up handling of chained TIC CCWs Date: Tue, 14 Jul 2026 11:33:00 +0200 Message-ID: <20260714093300.2193848-4-cohuck@redhat.com> In-Reply-To: <20260714093300.2193848-1-cohuck@redhat.com> References: <20260714093300.2193848-1-cohuck@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: permerror client-ip=170.10.133.124; envelope-from=cohuck@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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, T_SPF_PERMERROR=0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1784021639005158500 Content-Type: text/plain; charset="utf-8" From: Eric Farman The logic in css_interpret_ccw() correctly returns -EINVAL if a Transfer-In-Channel (TIC) CCW is command chained to another TIC CCW. The same routine also correctly returns -EINVAL if 256 CCWs do not perform a data transfer as part of the I/O operation [0]. What is missing, however, is a combination of these two, where a loop can be generated that will continue processing CCWs but without providing an opportunity to catch a breath. Fix this by capping the number of TIC CCWs in a channel program at the same limit as the CCWs without data transfer. [0] See "Invalid Sequence" in z/Architecture Principles of Operation (SA22-7832-14), p16-27 Cc: qemu-stable@nongnu.org Signed-off-by: Eric Farman Acked-by: Christian Borntraeger Reviewed-by: Farhan Ali Signed-off-by: Christian Borntraeger Message-ID: <20260713074708.884282-1-borntraeger@linux.ibm.com> Signed-off-by: Cornelia Huck --- hw/s390x/css.c | 7 +++++++ include/hw/s390x/css.h | 1 + 2 files changed, 8 insertions(+) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 29ba39f79ea1..3a67b6705319 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1078,6 +1078,12 @@ static int css_interpret_ccw(SubchDev *sch, hwaddr c= cw_addr, ret =3D -EINVAL; break; } + /* Limit the number of TICs in a given channel program */ + if (sch->ccw_tic_cnt =3D=3D 255) { + ret =3D -EINVAL; + break; + } + sch->ccw_tic_cnt++; sch->channel_prog =3D ccw.cda; ret =3D -EAGAIN; break; @@ -1129,6 +1135,7 @@ static void sch_handle_start_func_virtual(SubchDev *s= ch) sch->ccw_fmt_1 =3D !!(orb->ctrl0 & ORB_CTRL0_MASK_FMT); schib->scsw.flags |=3D (sch->ccw_fmt_1) ? SCSW_FLAGS_MASK_FMT : 0; sch->ccw_no_data_cnt =3D 0; + sch->ccw_tic_cnt =3D 0; suspend_allowed =3D !!(orb->ctrl0 & ORB_CTRL0_MASK_SPND); } else { /* Start Function resumed via rsch */ diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index d3326237c9f0..79b41f305e8c 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -132,6 +132,7 @@ struct SubchDev { bool ccw_fmt_1; bool thinint_active; uint8_t ccw_no_data_cnt; + uint8_t ccw_tic_cnt; uint16_t migrated_schid; /* used for mismatch detection */ CcwDataStream cds; /* transport-provided data: */ --=20 2.55.0