From nobody Mon Nov 23 04:34:28 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=1794580387; cv=none; d=zohomail.com; s=zohoarc; b=AUFQpkPjmKWYMojTXqJZXZPiHsfMfiDVG/VO89tE3oSPI1qSWGqtwwhTmKh99J/OskMr/qgPtCgQAKkEqR9OmTPIncmPVbNqa5qrYxOhTJgOyxBki8fTNA41SGRGllqQDd26YS5LIQeHWI03JmXDP1Ze4uEJzdliqONxVzBsQFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794580387; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=A4CoMqg6jCKbGXca/tvttRZObeWMgEW4Le3632fL4bc=; b=ecHwIxR8hkqlPXoq9D4SuVThfjOCcZ/z+IcE8Tr37nHx7KwBx9R7RNVciCHOoqUXiewhFE3nCEYvouOTI7BPy8AKssSq0W10CyyiVxSsA03u33DEZEXOzSILtIEPlBgjDfxTxNKdKXzzeUGDgqdyWCDDmnXpfQsBzllDoHgvps0= 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 1794580387240570.0962646987504; Fri, 13 Nov 2026 06:33:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRsKl-0000pS-3q; Fri, 13 Nov 2026 09:32:56 -0500 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 1xRsJd-000850-RR for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:50 -0500 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 1xRsJc-0007HQ-6N for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:45 -0500 Received: from mx-prod-mc-06.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-678-yvaO_GF6NXi-ZFXVJX6d_A-1; Fri, 13 Nov 2026 09:31:40 -0500 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F8391800378; Fri, 13 Nov 2026 14:31:39 +0000 (UTC) Received: from eblake.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 41E84343; Fri, 13 Nov 2026 14:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794580303; 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=A4CoMqg6jCKbGXca/tvttRZObeWMgEW4Le3632fL4bc=; b=DCtI9BwDzMnqo9L8yW+ZxbH9ZwCiWBld9aVLJuKu/GE4au+iIG/1nbT0btYIF7rV3CFXDj +YzDIho6jpUiAxgsbyNRUfKArPyVAkrFc6Tqse6fzhgzN6rczlhF/Pa9R4Aiu+6KB4qmUD hAubJQh3dzmvJnDaURs1wTG7eBOF1GQ= X-MC-Unique: yvaO_GF6NXi-ZFXVJX6d_A-1 X-Mimecast-MFC-AGG-ID: yvaO_GF6NXi-ZFXVJX6d_A_1794580299 From: Eric Blake To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stefan Hajnoczi , Pierrick Bouvier Subject: [PULL v2 1/6] docs: Mention security considerations for NBD Date: Fri, 13 Nov 2026 08:30:29 -0600 Message-ID: <20261113143132.2414774-9-eblake@redhat.com> In-Reply-To: <20261113143132.2414774-8-eblake@redhat.com> References: <20261113143132.2414774-8-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=170.10.133.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794580387901158500 Document a policy that NBD connections should strongly consider using TLS and x509 certificates to filter out unwanted clients. If a malicious server or client can trigger a QEMU assertion failure on a plaintext connection, but can trivially have risk mitigated by enabling TLS to weed out unknown partners (so that a full-on attack of QEMU would first require chaining some other attack to convince a "trusted" client to break protocol in the first place), then that reduces the CVSS-BE score of the QEMU bug. In turn, our policy already states that low severity scores can be fixed without an embargo. Signed-off-by: Eric Blake Message-ID: <20261110155356.1520433-7-eblake@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Stefan Hajnoczi --- docs/system/security.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/system/security.rst b/docs/system/security.rst index 92a5d87503e..c0254fef113 100644 --- a/docs/system/security.rst +++ b/docs/system/security.rst @@ -320,3 +320,26 @@ encryption and authorization control policy on client = connections. In summary, the monitor console is considered a privileged control interfa= ce to QEMU and as such should only be made accessible to a trusted management application or user. + +Block device network protocols (NBD, NFS, etc.) +''''''''''''''''''''''''''''''''''''''''''''''' + +When using QEMU to access remote storage over a network (such as QEMU +acting as an NBD or NFS client) or to provide remote storage access +(such as QEMU acting as an NBD server), it is important to realize +that an unencrypted connection can allow any external process a +potential attack vector via the network port. When possible, QEMU +should be configured to require TLS to prevent a man-in-the-middle +attack, as well as use x509 client certificates with the +tls-creds-x509 object set with 'verify-peer=3Don' to check that the peer +is allowed to connect. It may also be worth using 'tls-authz' to +filter which certificates are allowed if the CA issues certs more +broadly. + +Proper hardening of network connections cannot prevent a client from +violating protocol, but does increase the complexity of an attack, +because a malicious actor must first find a way to convince an +authenticated client to send the bytes that will trigger any QEMU +misbehavior. Use of a hardened connection is therefore an +environmental factor used in determining the risk and severity of a +network-triggered bug. --=20 2.56.0 From nobody Mon Nov 23 04:34:28 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=1794580408; cv=none; d=zohomail.com; s=zohoarc; b=VvNpMI7MI603AcTBsg3mzHsgvnwUZP7uNvOZ5tur1haxlgSbrrHEsS0rN049Y9VtJNlK8TSYbLgFL7nOjfdf1JpTaU/wI+bwAgWMsfEI3kOmlhCpWwrkqoElkc/3JiCoQSdyE31BWaMhdCL3pLHM1nlYPDcHEq0szgo+g2c0sKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794580408; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jL1ZY5YGV4jNZ0LlyOE5AfrHB7c9oeMeQZiaZa21c20=; b=R8KIVj+akuFbJ86UX4Y20078lU5jqRx0+H+F9eXVLzwOOXwK0VSxoVsEtz0XHRlMT3eFEtRN1d9LfYONFC5r7I9tGkTgFgLsSXYSavY+ia6XGwJzz9V3YEXEBYuD/PlwkE9tXWj0jk6XiHN4ANT0dKgl3IDenkD+VU2icWLAUGc= 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 1794580408196878.711170171056; Fri, 13 Nov 2026 06:33:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRsL1-0001UQ-0z; Fri, 13 Nov 2026 09:33:13 -0500 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 1xRsJk-0008CE-8j for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:58 -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 1xRsJi-0007Jh-3U for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:51 -0500 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-433-gJ0YReMAPq2W7z7F3CJxsw-1; Fri, 13 Nov 2026 09:31:42 -0500 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 3B52F1800548; Fri, 13 Nov 2026 14:31:41 +0000 (UTC) Received: from eblake.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A461F344; Fri, 13 Nov 2026 14:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794580309; 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=jL1ZY5YGV4jNZ0LlyOE5AfrHB7c9oeMeQZiaZa21c20=; b=Fj+yVGvgM9Ot+r832J1JCYSBiDwIwfqdMeRbCs1YtWjcBnmT2kJ/329HS3cakUsK6ePpJZ Qeqo07jDVg/4ZQoF2GZfnjY4/ADqtflnlpV0fyKWkFnIIUvkjWSejjWusy/QxZFH4i0QCw NKWKJffnZNvvEMW+9YN8wyuLkh4fpHo= X-MC-Unique: gJ0YReMAPq2W7z7F3CJxsw-1 X-Mimecast-MFC-AGG-ID: gJ0YReMAPq2W7z7F3CJxsw_1794580301 From: Eric Blake To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stefan Hajnoczi , Kevin Wolf , Hanna Reitz , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org (open list:Block layer core) Subject: [PULL v2 2/6] iotests: Refactor python NBD server setup Date: Fri, 13 Nov 2026 08:30:30 -0600 Message-ID: <20261113143132.2414774-10-eblake@redhat.com> In-Reply-To: <20261113143132.2414774-8-eblake@redhat.com> References: <20261113143132.2414774-8-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=170.10.129.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: 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: 1794580410532158501 Extract code from nbd-multiconn that I plan to use in another upcoming unit test. Signed-off-by: Eric Blake Message-ID: <20261110155356.1520433-8-eblake@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Stefan Hajnoczi --- tests/qemu-iotests/iotests.py | 30 ++++++++++++++++++ tests/qemu-iotests/tests/nbd-multiconn | 44 +++++--------------------- 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 642a160bb28..7017d2016cf 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -1385,6 +1385,36 @@ def case_skip(self, reason): case_notrun(reason) self.skipTest(reason) + @contextmanager + def run_nbd_server(self, nbd_sock: str, + max_conn: Optional[int] =3D None) -> Iterator[None]: + args: Dict[str, Any] =3D { + 'addr': { + 'type': 'unix', + 'data': {'path': nbd_sock} + } + } + if max_conn is not None: + args['max-connections'] =3D max_conn + + self.vm.cmd('nbd-server-start', args) + try: + yield + finally: + self.vm.cmd('nbd-server-stop') + + def add_nbd_export(self, node_name: str, name: str, + writable: Optional[bool] =3D None) -> None: + args: Dict[str, Any] =3D { + 'type': 'nbd', + 'id': name, + 'node-name': node_name, + 'name': name, + } + if writable is not None: + args['writable'] =3D writable + + self.vm.cmd('block-export-add', args) def notrun(reason): '''Skip this test suite''' diff --git a/tests/qemu-iotests/tests/nbd-multiconn b/tests/qemu-iotests/te= sts/nbd-multiconn index 479e872f2a8..96efe01e583 100755 --- a/tests/qemu-iotests/tests/nbd-multiconn +++ b/tests/qemu-iotests/tests/nbd-multiconn @@ -62,55 +62,27 @@ class TestNbdMulticonn(iotests.QMPTestCase): except OSError: pass - @contextmanager - def run_server(self, max_connections=3DNone): - args =3D { - 'addr': { - 'type': 'unix', - 'data': {'path': nbd_sock} - } - } - if max_connections is not None: - args['max-connections'] =3D max_connections - - self.vm.cmd('nbd-server-start', args) - yield - - self.vm.cmd('nbd-server-stop') - - def add_export(self, name, writable=3DNone): - args =3D { - 'type': 'nbd', - 'id': name, - 'node-name': 'n', - 'name': name, - } - if writable is not None: - args['writable'] =3D writable - - self.vm.cmd('block-export-add', args) - def test_default_settings(self): - with self.run_server(): - self.add_export('r') - self.add_export('w', writable=3DTrue) + with self.run_nbd_server(nbd_sock): + self.add_nbd_export('n', 'r') + self.add_nbd_export('n', 'w', writable=3DTrue) with open_nbd('r') as h: self.assertTrue(h.can_multi_conn()) with open_nbd('w') as h: self.assertTrue(h.can_multi_conn()) def test_limited_connections(self): - with self.run_server(max_connections=3D1): - self.add_export('r') - self.add_export('w', writable=3DTrue) + with self.run_nbd_server(nbd_sock, max_conn=3D1): + self.add_nbd_export('n', 'r') + self.add_nbd_export('n', 'w', writable=3DTrue) with open_nbd('r') as h: self.assertFalse(h.can_multi_conn()) with open_nbd('w') as h: self.assertFalse(h.can_multi_conn()) def test_parallel_writes(self): - with self.run_server(): - self.add_export('w', writable=3DTrue) + with self.run_nbd_server(nbd_sock): + self.add_nbd_export('n', 'w', writable=3DTrue) clients =3D [nbd.NBD() for _ in range(3)] for c in clients: --=20 2.56.0 From nobody Mon Nov 23 04:34:28 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=1794580448; cv=none; d=zohomail.com; s=zohoarc; b=dQ/jLQ0kRjp+ArZWXF7NQuyQOT0hR0Yz2I1bK9+4QdvegAyZWlxM5XTLVwpyRFNRjJVbzbhq2nNMKd36HOrv8MQ/DfB12xS3uPRzaOVZavgpM9raNAOUlNKJ4bk64PnQdKtbEbIF7H6ZqM+SS2gLOcX0z4Pa2OEKtJvhvzilSU0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794580448; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=D4QDAx78KWHUqPNjDA4H6eTXFRcl1oPkhjcemO9bHjY=; b=RaNkWM8i2U8ZKHK8Y3j/+7gtdS+JvC4v9q20QzJAyphMR0qAGTr8ObmzK55xesNiAXTFBOFDM/sxBzg63w0vafKDgWLm79aoyTGcXm1LAqjfJ2T51bgvgNEhRn0VrjObf/deA/GH/se8KrcPuebxYkgzAPtpwho/aQLT2xBCG1c= 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 1794580448826282.95107137420064; Fri, 13 Nov 2026 06:34:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRsLG-00028T-MZ; Fri, 13 Nov 2026 09:33:26 -0500 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 1xRsJo-0008Gs-F9 for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:32:04 -0500 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 1xRsJj-0007KF-VW for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:55 -0500 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-668-KS1oH9GONd-TmWUsRrnJrw-1; Fri, 13 Nov 2026 09:31:46 -0500 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 48FC2195606C; Fri, 13 Nov 2026 14:31:43 +0000 (UTC) Received: from eblake.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8C08C345; Fri, 13 Nov 2026 14:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794580311; 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=D4QDAx78KWHUqPNjDA4H6eTXFRcl1oPkhjcemO9bHjY=; b=UbiHUqfKLnzebfDGtddmnE1bP07v3y8SEGHpK2L6ecNId6EnmbBtHNkOjuv/KxOnNKr3TX IgdMt8dGeyykge907/S1iuqULSYIhWesmPd1hoVSq40tyngYnzLGUqjiCDrJcf6DNpfrmL d6V9dQF6XBwGYl/SMSgjPABTP6q8kiY= X-MC-Unique: KS1oH9GONd-TmWUsRrnJrw-1 X-Mimecast-MFC-AGG-ID: KS1oH9GONd-TmWUsRrnJrw_1794580303 From: Eric Blake To: qemu-devel@nongnu.org Cc: Feifan Qian , Haotian Jiang , qemu-stable@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stefan Hajnoczi , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org (open list:Network Block Dev...) Subject: [PULL v2 3/6] nbd/server: Reject rather than assert on non-compliant BLOCK_STATUS Date: Fri, 13 Nov 2026 08:30:31 -0600 Message-ID: <20261113143132.2414774-11-eblake@redhat.com> In-Reply-To: <20261113143132.2414774-8-eblake@redhat.com> References: <20261113143132.2414774-8-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=170.10.133.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: 1794580452768158500 The NBD spec is clear that a client must not send NBD_BLOCK_STATUS requests to a server if it did not negotiate any metacontexts with NBD_OPT_SET_META_CONTEXT for the current export. However, if the non-compliant client uses NBD_OPT_EXTENDED_HEADERS and then passes in the relatively new NBD_CMD_FLAG_PAYLOAD_LEN flag alongside an inappropriate block status request, this was enough to trigger an assertion in qemu. The assertion can also be tripped by initially requesting the context for one export, then using NBD_OPT_GO on a different export (nbd_check_meta_export() sets contexts.count to 0, but did not wipe contexts.exp). Forcing the client command to be rejected if contexts.count is 0 solves both triggers, and allows the assertion to still operate cleanly at a later location. If you do not use recommended practice to prevent unwanted clients from connecting to QEMU's NBD server, then any client can cause a denial of service with minimal effort. However, with TLS and x509 certs in place, an attacker must first chain in an attack to convince the client to send unwanted traffic, which is a factor in declaring this a lower-risk denial of service. Fixes: CVE-2026-124559 Fixes: 2dcbb11b ("nbd/server: Add FLAG_PAYLOAD support to CMD_BLOCK_STATUS"= , v8.2.0) Reported-by: Feifan Qian Reported-by: https://gitlab.com/qemu-project/qemu/-/work_items/3796 CC: Haotian Jiang CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-ID: <20261110155356.1520433-9-eblake@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Stefan Hajnoczi --- nbd/server.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index e6c47f8c2e3..8a01c27de07 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2584,17 +2584,18 @@ nbd_co_block_status_payload_read(NBDClient *client,= NBDRequest *request, return -EINVAL; } - assert(client->contexts.exp =3D=3D client->exp); nr_bitmaps =3D client->exp->nr_export_bitmaps; request->contexts =3D g_new0(NBDMetaContexts, 1); request->contexts->exp =3D client->exp; - if (payload_len % sizeof(uint32_t) || + if (!client->contexts.count || + payload_len % sizeof(uint32_t) || payload_len < sizeof(NBDBlockStatusPayload) || payload_len > (sizeof(NBDBlockStatusPayload) + sizeof(id) * client->contexts.count)) { goto skip; } + assert(client->contexts.exp =3D=3D client->exp); buf =3D g_malloc(payload_len); if (nbd_read(client->ioc, buf, payload_len, --=20 2.56.0 From nobody Mon Nov 23 04:34:28 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=1794580459; cv=none; d=zohomail.com; s=zohoarc; b=KiMaikGfhU9OYWxLX9+jLwShnZQ6bseJh8xHEe+RZdXjAsXvpwSv5RatFnu64HpVwhOqWtdnDxPXN/cr1MY42dSWAnrfWRY783DZa1KQBwWrK/iMW+0xQsbWu5W7jr0rX5OTWKA90YPbKGwKBmpqWWETacFtRa3O2SM080Tqwgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794580459; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vrUJBGn2vUH1UR3OPTAuN/Q+khfW6r7FRV+4klOWrSI=; b=VLVv6BxZGn6tA3kxAnkicpXZCxIEGl+hcxXfjwLvoxhGMaGP+pRbD34dTJuOPG6hlRiNo99LWqj5yprn2SI6YuGQz3OFUhZXDzBPfF8ZzEnaqp3egU3/oLV3upptt1Qu+ZOsHrrfQDlW8SSdwOoDSOuRgvXuEvrOlwdyXWVBXQk= 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 1794580459553266.4111813314747; Fri, 13 Nov 2026 06:34:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRsLF-0001uW-3B; Fri, 13 Nov 2026 09:33:25 -0500 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 1xRsJk-0008CD-8G for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:58 -0500 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 1xRsJh-0007Jd-UB for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:51 -0500 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-272-unVLsp4HMbum1UhllGDX8A-1; Fri, 13 Nov 2026 09:31:46 -0500 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 102DF1955F14; Fri, 13 Nov 2026 14:31:45 +0000 (UTC) Received: from eblake.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9F24844B; Fri, 13 Nov 2026 14:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794580309; 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=vrUJBGn2vUH1UR3OPTAuN/Q+khfW6r7FRV+4klOWrSI=; b=XVcf+IUd8/e9YcAFLZr0zMI92ctUlPR1vO6975l9L8N7/nfx7kARm2+YZ924N0W7Ddu/QJ W507wajatS8g7U5bex7isxzyTeTsczzYAVix0Tk8zW6zAWaX+QJyNnPRLh+toewEwg66VZ NvqVMDnAYbhooUhm88hAZAiMegWKlBQ= X-MC-Unique: unVLsp4HMbum1UhllGDX8A-1 X-Mimecast-MFC-AGG-ID: unVLsp4HMbum1UhllGDX8A_1794580305 From: Eric Blake To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Vladimir Sementsov-Ogievskiy , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org (open list:Network Block Dev...) Subject: [PULL v2 4/6] iotests: Add new nbd-robustness test Date: Fri, 13 Nov 2026 08:30:32 -0600 Message-ID: <20261113143132.2414774-12-eblake@redhat.com> In-Reply-To: <20261113143132.2414774-8-eblake@redhat.com> References: <20261113143132.2414774-8-eblake@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: pass client-ip=170.10.133.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: 1794580462695158500 Content-Type: text/plain; charset="utf-8" Convert the proof of concept test by Sunday Jiang into an iotest. I tried to get libnbd to trigger the situation, but forcing a block status command when no status has been initiated is not something that libnbd is willing to do. So this results in a hard-coded sequence of bytes sent over a raw socket. Swapping the order with the previous patch shows the assertion failure that was previously reachable. Based-on: https://gitlab.com/qemu-project/qemu/-/work_items/4091 Signed-off-by: Eric Blake Message-ID: <20261110155356.1520433-10-eblake@redhat.com> Reviewed-by: Stefan Hajnoczi --- tests/qemu-iotests/tests/nbd-robustness | 132 ++++++++++++++++++++ tests/qemu-iotests/tests/nbd-robustness.out | 5 + 2 files changed, 137 insertions(+) create mode 100755 tests/qemu-iotests/tests/nbd-robustness create mode 100644 tests/qemu-iotests/tests/nbd-robustness.out diff --git a/tests/qemu-iotests/tests/nbd-robustness b/tests/qemu-iotests/t= ests/nbd-robustness new file mode 100755 index 00000000000..fe61a839250 --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-robustness @@ -0,0 +1,132 @@ +#!/usr/bin/env python3 +# group: rw auto quick +# +# Test cases for NBD robustness against malicious clients +# +# Copyright (C) 2026 Red Hat, Inc. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +import socket +import struct + +import iotests +from iotests import qemu_img_create, qemu_io + +# Selected NBD Protocol Constants +NBD_MAGIC_INIT =3D 0x4e42444d41474943 # "NBDMAGIC" +NBD_MAGIC_OPTS =3D 0x49484156454f5054 # "IHAVEOPT" +NBD_MAGIC_REPLY =3D 0x0003e889045565a9 # Reply magic +NBD_MAGIC_EXT_REPLY =3D 0x6e8a278c # Structured reply magic +NBD_FLAG_C_FIXED_NEWSTYLE =3D 0x1 +NBD_OPT_GO =3D 7 +NBD_OPT_SET_META_CONTEXT =3D 10 +NBD_OPT_EXTENDED_HEADERS =3D 11 +NBD_REP_ACK =3D 1 +NBD_REP_INFO =3D 3 +NBD_CMD_BLOCK_STATUS =3D 7 + +disk =3D os.path.join(iotests.test_dir, 'disk') +size =3D '4M' +nbd_sock =3D os.path.join(iotests.sock_dir, 'nbd_sock') + + +class TestNbdRobustness(iotests.QMPTestCase): + def setUp(self): + qemu_img_create('-f', iotests.imgfmt, disk, size) + qemu_io('-c', 'w -P 1 0 2M', '-c', 'w -P 2 2M 2M', disk) + + self.vm =3D iotests.VM() + self.vm.launch() + self.vm.cmd('blockdev-add', { + 'driver': iotests.imgfmt, + 'node-name': 'n', + 'file': {'driver': 'file', 'filename': disk} + }) + + def tearDown(self): + self.vm.shutdown() + os.remove(disk) + try: + os.remove(nbd_sock) + except OSError: + pass + + def recv_exact(self, s: socket.socket, n: int) -> bytes: + buf =3D bytearray() + while len(buf) < n: + chunk =3D s.recv(n - len(buf)) + if not chunk: + raise EOFError(f"Unexpected EOF while reading {n} bytes " + f"(got {len(buf)})") + buf.extend(chunk) + return bytes(buf) + + def test_invalid_block_status(self): + with self.run_nbd_server(nbd_sock): + self.add_nbd_export('n', 'r') + + # Use raw socket traffic to intentionally violate NBD protocol + with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s: + s.connect(nbd_sock) + # Server sends NBDMAGIC(8) + IHAVEOPT(8) + flags(2) + data =3D self.recv_exact(s, 18) + magic, opt, flags =3D struct.unpack(">QQH", data) + self.assertEqual(magic, NBD_MAGIC_INIT) + self.assertEqual(opt, NBD_MAGIC_OPTS) + self.assertEqual(flags, 0x3) + + # Reply with flags(4) - just fixed newstyle flag + s.sendall(struct.pack(">I", NBD_FLAG_C_FIXED_NEWSTYLE)) + + # Request NBD_OPT_EXTENDED_HEADERS, no extra payload + s.sendall(struct.pack(">QII", NBD_MAGIC_OPTS, + NBD_OPT_EXTENDED_HEADERS, 0)) + + # Expect successful reply: + # magic(8) + option(4) + reply(4) + length(4) + data =3D self.recv_exact(s, 20) + magic, opt, reply, length =3D struct.unpack(">QIII", data) + self.assertEqual(magic, NBD_MAGIC_REPLY) + self.assertEqual(opt, NBD_OPT_EXTENDED_HEADERS) + self.assertEqual(reply, NBD_REP_ACK) + self.assertEqual(length, 0) + + # Request NBD_OPT_GO, name but no info as payload + payload =3D struct.pack(">I", 1) + b'r' + struct.pack(">H"= , 0) + s.sendall(struct.pack(">QII", NBD_MAGIC_OPTS, NBD_OPT_GO, + len(payload)) + payload) + + # Expect (and ignore) zero or more info packets before ack + while True: + data =3D self.recv_exact(s, 20) + magic, opt, reply, length =3D struct.unpack(">QIII", d= ata) + self.assertEqual(magic, NBD_MAGIC_REPLY) + self.assertEqual(opt, NBD_OPT_GO) + payload =3D self.recv_exact(s, length) + if reply !=3D NBD_REP_INFO: + break + self.assertEqual(reply, NBD_REP_ACK) + + # Send invalid NBD_CMD_BLOCK_STATUS with payload flag. This + # violates the NBD protocol (since no context was negotiat= ed), + # but should not crash the server. + payload =3D struct.pack(">QI", 0x1000, 0) + s.sendall(struct.pack(">IHHQQQ", 0x21e41c71, 0x20, + NBD_CMD_BLOCK_STATUS, 1, 0, + len(payload)) + payload) + + # Expect a rejection. + data =3D self.recv_exact(s, 32) + magic, flags, rtype, cookie, _, length =3D \ + struct.unpack(">IHHQQQ", data) + self.assertEqual(magic, NBD_MAGIC_EXT_REPLY) + self.assertEqual(rtype & 0x8000, 0x8000) + self.assertEqual(cookie, 1) + self.recv_exact(s, length) + + self.assertTrue(self.vm.is_running()) + +if __name__ =3D=3D '__main__': + iotests.main(supported_fmts=3D['qcow2']) diff --git a/tests/qemu-iotests/tests/nbd-robustness.out b/tests/qemu-iotes= ts/tests/nbd-robustness.out new file mode 100644 index 00000000000..ae1213e6f86 --- /dev/null +++ b/tests/qemu-iotests/tests/nbd-robustness.out @@ -0,0 +1,5 @@ +. +---------------------------------------------------------------------- +Ran 1 tests + +OK --=20 2.56.0 From nobody Mon Nov 23 04:34:28 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=1794580469; cv=none; d=zohomail.com; s=zohoarc; b=lJUC4HX1HabBfL1vIMy2+UI7hLOWa8QfMD9PQFN/SJU4gnzYMcmIWLSlxVtzu3pel6tFil4ciJnXHGpta2VewwEY4qlQ2aMkH/N7j+i3e51NlKdxP25AlWeULvWdswqeRH7JgQL33WZ5fjFtjQvO0UWchsx29crVJnLG9VUqpMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794580469; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wrZedr75GGg9WN9k+O0G0oSPPKkMM+sHh5y9JswdQsU=; b=Wo2U+8FUjS/Eas3lU+QOWFxZccYIcgNCCW3br+cpcqUDGsZ2IvRLjIPo/MOSinbkz6+9Zhn6QT93upUj/Vb7nhWZ6Fb6WoIQ5kPJ8+lNCI+Be6VMrjfOC4+86KXvw8jRUlzEhhiIKyNMYpoQ5gCBsU8R7eyHZfhO1U272BD87oI= 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 1794580469623546.5317342585395; Fri, 13 Nov 2026 06:34:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRsLx-0002pq-Mu; Fri, 13 Nov 2026 09:34:10 -0500 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 1xRsJq-0008HE-9M for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:32:06 -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 1xRsJm-0007Ke-Hh for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:57 -0500 Received: from mx-prod-mc-06.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-389-EvKyk0B-MCy1Gwmsy7G-qA-1; Fri, 13 Nov 2026 09:31:49 -0500 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9547418005BA; Fri, 13 Nov 2026 14:31:46 +0000 (UTC) Received: from eblake.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5F0B344B; Fri, 13 Nov 2026 14:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794580313; 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=wrZedr75GGg9WN9k+O0G0oSPPKkMM+sHh5y9JswdQsU=; b=HGljZjJhZzGS6aUjHYm4tbJTUYNQZ1K42zOfg8VUVHgMCShTiV/5GZPDt8F5ryT4zCNAS+ OG05XTN+Jhj5knZUjMVQAOPIAeRm2Nybq6TJp754iabKmXBVfbRtNULCCpWmYTOl0Qi8rs LJHtCQJr8DkYB0EC9NzdRa3p/fvAD0I= X-MC-Unique: EvKyk0B-MCy1Gwmsy7G-qA-1 X-Mimecast-MFC-AGG-ID: EvKyk0B-MCy1Gwmsy7G-qA_1794580306 From: Eric Blake To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stefan Hajnoczi , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org (open list:Network Block Dev...) Subject: [PULL v2 5/6] nbd/server: Reject rather than assert on non-compliant NBD_OPT_SET_META_CONTEXT Date: Fri, 13 Nov 2026 08:30:33 -0600 Message-ID: <20261113143132.2414774-13-eblake@redhat.com> In-Reply-To: <20261113143132.2414774-8-eblake@redhat.com> References: <20261113143132.2414774-8-eblake@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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: pass client-ip=170.10.129.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: 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: 1794580470757158500 The NBD protocol says that NBD_OPT_{LIST,SET}_META_CONTEXT sends several lengths that must be consistent: an overall option reply length, then a series of smaller lengths/data pairs representing the export name and zero or more context names. If the smaller lengths within the payload do not add up to the larger value, the client has sent garbage bytes that will trigger the server's parse of the client's next option to be out of sync. However, QEMU was dying with an assertion failure rather than diagnosing the issue, which a malicious client can then exploit to mount a denial-of-service attack against QEMU as the NBD server. As with several other recent NBD protocol violations, the likelihood of this attack can be reduced by using TLS and x509 certs to reject unwanted clients (a "trusted" client can still trigger the problem, but you first have to compromise the trusted client into sending arbitrary traffic). Fixes: CVE-2026-125683 Fixes: e7b1948d51 ("nbd: BLOCK_STATUS for standard get_block_status functio= n: server part", v2.12.0) Reported-by: TonySD via https://gitlab.com/qemu-project/qemu/-/work_items/4= 843 CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Message-ID: <20261110155356.1520433-11-eblake@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Stefan Hajnoczi --- nbd/server.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nbd/server.c b/nbd/server.c index 8a01c27de07..8c45f9fc43f 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1095,6 +1095,11 @@ nbd_negotiate_meta_queries(NBDClient *client, Error = **errp) } } } + if (client->optlen > 0) { + return nbd_opt_invalid(client, errp, + "Inconsistent lengths in option %s", + nbd_opt_lookup(client->opt)); + } if (meta->base_allocation) { ret =3D nbd_negotiate_send_meta_context(client, "base:allocation", --=20 2.56.0 From nobody Mon Nov 23 04:34:28 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=1794580460; cv=none; d=zohomail.com; s=zohoarc; b=DE0JZm6psM/FfmieLjbFHX1SanAQHkNc9Xm+SHHR9Xhwns48u2LWKrQ95aPwa3fHmj9wmPCq483TjFY/wUuAOohfkEFLM41Q9PxWzK3c+CilafHIbdQDKYSfe0tAUoSyso2p4hL6GOmepQK7oncuUH3/Jt+adr1yILcCJb0xq2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794580460; 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:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kQey4jsGrhUt0ZwEtQIa2PPXxdz1oC6d1Y293m8BGtI=; b=HIL6pxxopBkltqSK8Vr0dO+pHYaoQOqcKJ0BH/rYG1NX3l3eK4Sv8YVTZDXehDZaCUMLhTYEyVPl3sneeUCQ8m8Idz2B8JhzWCxjrqRuAk7ORaQyubGG+rnF+xVHjKRFd0jOHAoEkfS3SHrIIq3Lad7qgAGfzyjS0SGXVJHO6po= 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 1794580460273533.7136973128958; Fri, 13 Nov 2026 06:34:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xRsLa-0002M2-Gn; Fri, 13 Nov 2026 09:33:47 -0500 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 1xRsJm-0008GR-31 for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:32:02 -0500 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 1xRsJj-0007KB-VE for qemu-devel@nongnu.org; Fri, 13 Nov 2026 09:31:53 -0500 Received: from mx-prod-mc-05.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-38-WMTPeg-SNKq1anw0r-I0ng-1; Fri, 13 Nov 2026 09:31:49 -0500 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A9F3195606D; Fri, 13 Nov 2026 14:31:48 +0000 (UTC) Received: from eblake.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EA28A44B; Fri, 13 Nov 2026 14:31:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794580311; 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=kQey4jsGrhUt0ZwEtQIa2PPXxdz1oC6d1Y293m8BGtI=; b=Jk9yPfEQ6fGSoTd2/JebCF/nscG6OZUV8Avz0ph1W9wezssE4EbU43z0QQynOmBJeCNPDU IwNlEkEqlw3UnmzBCe58F18myQptRfUrcVkH7LlKpr1w0XgMSVsfa+l04OqPmhKXxMhJGD 58WVq/7/PkXRraZA+vYjSwtGJaFRsn0= X-MC-Unique: WMTPeg-SNKq1anw0r-I0ng-1 X-Mimecast-MFC-AGG-ID: WMTPeg-SNKq1anw0r-I0ng_1794580308 From: Eric Blake To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Vladimir Sementsov-Ogievskiy , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org (open list:Network Block Dev...) Subject: [PULL v2 6/6] iotests: Add another nbd-robustness test Date: Fri, 13 Nov 2026 08:30:34 -0600 Message-ID: <20261113143132.2414774-14-eblake@redhat.com> In-Reply-To: <20261113143132.2414774-8-eblake@redhat.com> References: <20261113143132.2414774-8-eblake@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: pass client-ip=170.10.133.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: 1794580462696158500 Content-Type: text/plain; charset="utf-8" Convert the proof of concept test by TonySD into another case of the iotest. This is yet another instance where a hard-coded exchange is easier than forcing libnbd into producing an exchange that violates the protocol. Swapping the order with the previous patch shows the assertion failure that was previously reachable. Based-on: https://gitlab.com/qemu-project/qemu/-/work_items/4843 Signed-off-by: Eric Blake Message-ID: <20261110155356.1520433-12-eblake@redhat.com> Reviewed-by: Stefan Hajnoczi --- tests/qemu-iotests/tests/nbd-robustness | 73 +++++++++++++++++++++ tests/qemu-iotests/tests/nbd-robustness.out | 4 +- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/tests/nbd-robustness b/tests/qemu-iotests/t= ests/nbd-robustness index fe61a839250..410dfca04e3 100755 --- a/tests/qemu-iotests/tests/nbd-robustness +++ b/tests/qemu-iotests/tests/nbd-robustness @@ -21,6 +21,7 @@ NBD_MAGIC_REPLY =3D 0x0003e889045565a9 # Reply ma= gic NBD_MAGIC_EXT_REPLY =3D 0x6e8a278c # Structured reply magic NBD_FLAG_C_FIXED_NEWSTYLE =3D 0x1 NBD_OPT_GO =3D 7 +NBD_OPT_STRUCTURED_REPLY =3D 8 NBD_OPT_SET_META_CONTEXT =3D 10 NBD_OPT_EXTENDED_HEADERS =3D 11 NBD_REP_ACK =3D 1 @@ -128,5 +129,77 @@ class TestNbdRobustness(iotests.QMPTestCase): self.assertTrue(self.vm.is_running()) + def test_invalid_set_meta_context(self): + with self.run_nbd_server(nbd_sock): + self.add_nbd_export('n', 'r') + + # Use raw socket traffic to intentionally violate NBD protocol + with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s: + s.connect(nbd_sock) + # Server sends NBDMAGIC(8) + IHAVEOPT(8) + flags(2) + data =3D self.recv_exact(s, 18) + magic, opt, flags =3D struct.unpack(">QQH", data) + self.assertEqual(magic, NBD_MAGIC_INIT) + self.assertEqual(opt, NBD_MAGIC_OPTS) + self.assertEqual(flags, 0x3) + + # Reply with flags(4) - just fixed newstyle flag + s.sendall(struct.pack(">I", NBD_FLAG_C_FIXED_NEWSTYLE)) + + # Request NBD_OPT_STRUCTURED_REPLY, no extra payload + s.sendall(struct.pack(">QII", NBD_MAGIC_OPTS, + NBD_OPT_STRUCTURED_REPLY, 0)) + + # Expect successful reply: + # magic(8) + option(4) + reply(4) + length(4) + data =3D self.recv_exact(s, 20) + magic, opt, reply, length =3D struct.unpack(">QIII", data) + self.assertEqual(magic, NBD_MAGIC_REPLY) + self.assertEqual(opt, NBD_OPT_STRUCTURED_REPLY) + self.assertEqual(reply, NBD_REP_ACK) + self.assertEqual(length, 0) + + # Request NBD_OPT_SET_META_CONTEXT with invalid length + # namelen(4) + str + queries(4) + {querylen(4) + str) + payload =3D struct.pack(">I", 1) + b'r' + payload +=3D struct.pack(">II", 1, 1) + b'X' + s.sendall(struct.pack(">QII", NBD_MAGIC_OPTS, + NBD_OPT_SET_META_CONTEXT, + len(payload) + 1) + payload) + + # Request NBD_OPT_GO, name but no info as payload + # (request is early, but does not hurt here) + payload =3D struct.pack(">I", 1) + b'r' + struct.pack(">H"= , 0) + s.sendall(struct.pack(">QII", NBD_MAGIC_OPTS, NBD_OPT_GO, + len(payload)) + payload) + + # Expect error reply to SET_META_CONTEXT: + # magic(8) + option(4) + reply(4) + length(4) + data =3D self.recv_exact(s, 20) + magic, opt, reply, length =3D struct.unpack(">QIII", data) + self.assertEqual(magic, NBD_MAGIC_REPLY) + self.assertEqual(opt, NBD_OPT_SET_META_CONTEXT) + self.assertEqual(reply & 0x80000000, 0x80000000) + self.recv_exact(s, length) + + # Expect early disconnect for unaligned GO. Could show up = as + # either b'' or ConnectionResetError + try: + data =3D s.recv(1) + self.assertEqual(data, b'') + except ConnectionResetError: + pass + + # Further writes must trigger an error (EPIPE / ECONNRESET) + with self.assertRaises((BrokenPipeError, ConnectionResetEr= ror, + OSError)): + s.sendall(b'X') + + # QEMU should still be up + self.assertIsNone(self.vm.exitcode()) + self.assertTrue(self.vm.is_running()) + res =3D self.vm.cmd('query-status') + self.assertEqual(res['status'], 'running') + if __name__ =3D=3D '__main__': iotests.main(supported_fmts=3D['qcow2']) diff --git a/tests/qemu-iotests/tests/nbd-robustness.out b/tests/qemu-iotes= ts/tests/nbd-robustness.out index ae1213e6f86..fbc63e62f88 100644 --- a/tests/qemu-iotests/tests/nbd-robustness.out +++ b/tests/qemu-iotests/tests/nbd-robustness.out @@ -1,5 +1,5 @@ -. +.. ---------------------------------------------------------------------- -Ran 1 tests +Ran 2 tests OK --=20 2.56.0