From nobody Fri Apr 19 23:28:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637683283817511.37230989093086; Tue, 23 Nov 2021 08:01:23 -0800 (PST) Received: from localhost ([::1]:35690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpYET-0006Wy-69 for importer@patchew.org; Tue, 23 Nov 2021 11:01:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53844) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpYCa-0004JH-3v for qemu-devel@nongnu.org; Tue, 23 Nov 2021 10:59:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpYCY-0007g9-Hp for qemu-devel@nongnu.org; Tue, 23 Nov 2021 10:59:23 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-418-0utgXHEYNBaPnwP_wXYGWw-1; Tue, 23 Nov 2021 10:59:18 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8433AA40CB; Tue, 23 Nov 2021 15:59:17 +0000 (UTC) Received: from localhost (unknown [10.39.194.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2BB879454; Tue, 23 Nov 2021 15:59:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637683161; 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=u0cpCi9JMgKY3XtvC3AUbvyyeW3xdqtWpXVJ2QeSanE=; b=cPH4JMQfvf2E7jMhWobitgBNERLMS+JohejDwf9jYLLh8tBiJB+fsyctugffs7PmbsRrAW tp1oc72h/dy6WXPUjsAZ+1gFvUcECr5YeFlH8Uar8ed91V2+qmtKHOS4m8GPT/sUcObAO7 SpyuC1Ih/0SA6n1aOyjxSrSgaHL02Rg= X-MC-Unique: 0utgXHEYNBaPnwP_wXYGWw-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 1/3] block/vvfat.c fix leak when failure occurs Date: Tue, 23 Nov 2021 16:59:07 +0100 Message-Id: <20211123155909.717547-2-hreitz@redhat.com> In-Reply-To: <20211123155909.717547-1-hreitz@redhat.com> References: <20211123155909.717547-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637683290558100001 Content-Type: text/plain; charset="utf-8" From: Daniella Lee Function vvfat_open called function enable_write_target and init_directorie= s, and these functions malloc new memory for BDRVVVFATState::qcow_filename, BDRVVVFATState::used_clusters, and BDRVVVFATState::cluster_buff. When the specified folder does not exist ,it may contains memory leak. After init_directories function is executed, the vvfat_open return -EIO, and bdrv_open_driver goto label open_failed, the program use g_free(bs->opaque) to release BDRVVVFATState struct without members mentioned. command line: qemu-system-x86_64 -hdb -usb -device usb-storage,drive= =3Dfat16 -drive file=3Dfat:rw:fat-type=3D16:"", id=3Dfat16,format=3Draw,if=3Dnone enable_write_target called: (gdb) bt at ../block/vvfat.c:3114 flags=3D155650, errp=3D0x7fffffffd780) at ../block/vvfat.c:1236 node_name=3D0x0, options=3D0x555556fa45d0, open_flags=3D155650, errp=3D0x7fffffffd890) at ../block.c:1558 errp=3D0x7fffffffd890) at ../block.c:1852 reference=3D0x0, options=3D0x555556fa45d0, flags=3D40962, parent=3D0x55= 5556f98cd0, child_class=3D0x555556b1d6a0 , child_role=3D19, errp=3D0x7fffffffda90) at ../block.c:3779 options=3D0x555556f9cfc0, bdref_key=3D0x555556239bb8 "file", parent=3D0x555556f98cd0, child_class=3D0x555556b1d6a0 , child_role=3D19, allow_none=3Dtrue, errp=3D0x7fffffffda90) at ../block.= c:3419 reference=3D0x0, options=3D0x555556f9cfc0, flags=3D8194, parent=3D0x0, child_class=3D0x0, child_role=3D0, errp=3D0x555556c98c40 ) at ../block.c:3726 options=3D0x555556f757b0, flags=3D0, errp=3D0x555556c98c40 ) at ../block.c:3872 options=3D0x555556f757b0, flags=3D0, errp=3D0x555556c98c40 ) at ../block/block-backend.c:436 bs_opts=3D0x555556f757b0, errp=3D0x555556c98c40 ) at ../blockdev.c:608 errp=3D0x555556c98c40 ) at ../blockdev.c:992 ...... Signed-off-by: Daniella Lee Message-Id: <20211119112553.352222-1-daniellalee111@gmail.com> [hreitz: Took commit message from v1] Signed-off-by: Hanna Reitz --- block/vvfat.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 05e78e3c27..5dacc6cfac 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1279,8 +1279,18 @@ static int vvfat_open(BlockDriverState *bs, QDict *o= ptions, int flags, =20 qemu_co_mutex_init(&s->lock); =20 - ret =3D 0; + qemu_opts_del(opts); + + return 0; + fail: + g_free(s->qcow_filename); + s->qcow_filename =3D NULL; + g_free(s->cluster_buffer); + s->cluster_buffer =3D NULL; + g_free(s->used_clusters); + s->used_clusters =3D NULL; + qemu_opts_del(opts); return ret; } @@ -3118,7 +3128,7 @@ static int enable_write_target(BlockDriverState *bs, = Error **errp) int size =3D sector2cluster(s, s->sector_count); QDict *options; =20 - s->used_clusters =3D calloc(size, 1); + s->used_clusters =3D g_malloc0(size); =20 array_init(&(s->commits), sizeof(commit_t)); =20 @@ -3166,8 +3176,6 @@ static int enable_write_target(BlockDriverState *bs, = Error **errp) return 0; =20 err: - g_free(s->qcow_filename); - s->qcow_filename =3D NULL; return ret; } =20 --=20 2.33.1 From nobody Fri Apr 19 23:28:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637683423288528.3180098610694; Tue, 23 Nov 2021 08:03:43 -0800 (PST) Received: from localhost ([::1]:41888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpYGj-0002MV-54 for importer@patchew.org; Tue, 23 Nov 2021 11:03:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpYCd-0004WW-VL for qemu-devel@nongnu.org; Tue, 23 Nov 2021 10:59:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45111) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpYCc-0007gu-Az for qemu-devel@nongnu.org; Tue, 23 Nov 2021 10:59:27 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-alESFW-mPvuJuKMEFcesOA-1; Tue, 23 Nov 2021 10:59:21 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D17FF100C61C; Tue, 23 Nov 2021 15:59:20 +0000 (UTC) Received: from localhost (unknown [10.39.194.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39E0A5D6CF; Tue, 23 Nov 2021 15:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637683165; 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=kpfgdX372kuJC19fIhHQJvofnBmUEOAhXayxTc7AI8w=; b=cuvMVL0fZqzrlL/ZH78ngYXbCJ/bVXsLKSXDbapqcv/9tiqViq9tjarjdPhpsgfIh/WPui nocSujENbTf5D0Z+Yx6eWbR2S15uCUXBBKecb8H3FBvIPvjARIf8yqDf3t4ZI83Ayp4LJN oU2/ekUR1e/wI0je0qYvMnMtAjGapzo= X-MC-Unique: alESFW-mPvuJuKMEFcesOA-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 2/3] iotests: Use aes-128-cbc Date: Tue, 23 Nov 2021 16:59:08 +0100 Message-Id: <20211123155909.717547-3-hreitz@redhat.com> In-Reply-To: <20211123155909.717547-1-hreitz@redhat.com> References: <20211123155909.717547-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637683424828100001 Our gnutls crypto backend (which is the default as of 8bd0931f6) supports neither twofish-128 nor the CTR mode. CBC and aes-128 are supported by all of our backends (as far as I can tell), so use aes-128-cbc in our iotests. (We could also use e.g. aes-256-cbc, but the different key sizes would lead to different key slot offsets and so change the reference output more, which is why I went with aes-128.) Signed-off-by: Hanna Reitz Message-Id: <20211117151707.52549-2-hreitz@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Tested-by: Thomas Huth --- tests/qemu-iotests/206 | 4 ++-- tests/qemu-iotests/206.out | 6 +++--- tests/qemu-iotests/210 | 4 ++-- tests/qemu-iotests/210.out | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206 index c3cdad4ce4..10eff343f7 100755 --- a/tests/qemu-iotests/206 +++ b/tests/qemu-iotests/206 @@ -162,8 +162,8 @@ with iotests.FilePath('t.qcow2') as disk_path, \ 'encrypt': { 'format': 'luks', 'key-secret': 'keysec0', - 'cipher-alg': 'twofish-128', - 'cipher-mode': 'ctr', + 'cipher-alg': 'aes-128', + 'cipher-mode': 'cbc', 'ivgen-alg': 'plain64', 'ivgen-hash-alg': 'md5', 'hash-alg': 'sha1', diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out index 3593e8e9c2..80cd274223 100644 --- a/tests/qemu-iotests/206.out +++ b/tests/qemu-iotests/206.out @@ -97,7 +97,7 @@ Format specific information: =20 =3D=3D=3D Successful image creation (encrypted) =3D=3D=3D =20 -{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "qcow2", "encrypt": {"cipher-alg": "twofish-128", "cipher-mode":= "ctr", "format": "luks", "hash-alg": "sha1", "iter-time": 10, "ivgen-alg":= "plain64", "ivgen-hash-alg": "md5", "key-secret": "keysec0"}, "file": {"dr= iver": "file", "filename": "TEST_DIR/PID-t.qcow2"}, "size": 33554432}}} +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "qcow2", "encrypt": {"cipher-alg": "aes-128", "cipher-mode": "cb= c", "format": "luks", "hash-alg": "sha1", "iter-time": 10, "ivgen-alg": "pl= ain64", "ivgen-hash-alg": "md5", "key-secret": "keysec0"}, "file": {"driver= ": "file", "filename": "TEST_DIR/PID-t.qcow2"}, "size": 33554432}}} {"return": {}} {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} @@ -115,10 +115,10 @@ Format specific information: encrypt: ivgen alg: plain64 hash alg: sha1 - cipher alg: twofish-128 + cipher alg: aes-128 uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX format: luks - cipher mode: ctr + cipher mode: cbc slots: [0]: active: true diff --git a/tests/qemu-iotests/210 b/tests/qemu-iotests/210 index 5a62ed4dd1..a4dcc5fe59 100755 --- a/tests/qemu-iotests/210 +++ b/tests/qemu-iotests/210 @@ -83,8 +83,8 @@ with iotests.FilePath('t.luks') as disk_path, \ }, 'size': size, 'key-secret': 'keysec0', - 'cipher-alg': 'twofish-128', - 'cipher-mode': 'ctr', + 'cipher-alg': 'aes-128', + 'cipher-mode': 'cbc', 'ivgen-alg': 'plain64', 'ivgen-hash-alg': 'md5', 'hash-alg': 'sha1', diff --git a/tests/qemu-iotests/210.out b/tests/qemu-iotests/210.out index 55c0844370..96d9f749dd 100644 --- a/tests/qemu-iotests/210.out +++ b/tests/qemu-iotests/210.out @@ -59,7 +59,7 @@ Format specific information: {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} =20 -{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"cipher-alg": "twofish-128", "cipher-mode": "ctr", "driver": "luks", "file= ": {"driver": "file", "filename": "TEST_DIR/PID-t.luks"}, "hash-alg": "sha1= ", "iter-time": 10, "ivgen-alg": "plain64", "ivgen-hash-alg": "md5", "key-s= ecret": "keysec0", "size": 67108864}}} +{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"cipher-alg": "aes-128", "cipher-mode": "cbc", "driver": "luks", "file": {= "driver": "file", "filename": "TEST_DIR/PID-t.luks"}, "hash-alg": "sha1", "= iter-time": 10, "ivgen-alg": "plain64", "ivgen-hash-alg": "md5", "key-secre= t": "keysec0", "size": 67108864}}} {"return": {}} {"execute": "job-dismiss", "arguments": {"id": "job0"}} {"return": {}} @@ -71,9 +71,9 @@ encrypted: yes Format specific information: ivgen alg: plain64 hash alg: sha1 - cipher alg: twofish-128 + cipher alg: aes-128 uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX - cipher mode: ctr + cipher mode: cbc slots: [0]: active: true --=20 2.33.1 From nobody Fri Apr 19 23:28:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637683318468948.8429190377357; Tue, 23 Nov 2021 08:01:58 -0800 (PST) Received: from localhost ([::1]:36728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mpYF1-0007F4-Hk for importer@patchew.org; Tue, 23 Nov 2021 11:01:55 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpYCg-0004hQ-Lf for qemu-devel@nongnu.org; Tue, 23 Nov 2021 10:59:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mpYCe-0007hT-Qs for qemu-devel@nongnu.org; Tue, 23 Nov 2021 10:59:30 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-19-knFjioljPB-VBP9esIcIiA-1; Tue, 23 Nov 2021 10:59:25 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D50D58735C5; Tue, 23 Nov 2021 15:59:23 +0000 (UTC) Received: from localhost (unknown [10.39.194.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A3375D6CF; Tue, 23 Nov 2021 15:59:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637683168; 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=E3JhAz0bZW7d4NsiaQzqDdc2dJyRrQ1S/q5xH/SXDP4=; b=UiKK0J6+pCUEZnWShuoOXLIwR055q+ZnBiFQ4mP59rQrv8UW29Kmwtpqt2mQycEqTarhrL IzlOpu/i4+USkyFvYfFiiNA2/hWpRkSw0x3FpwgQ73i9zb/a4R8DdVH9iCO4Sqp8bGtfJc 5pN2uBfbLXddPcD6FBjwDPCVghxa18I= X-MC-Unique: knFjioljPB-VBP9esIcIiA-1 From: Hanna Reitz To: qemu-block@nongnu.org Subject: [PULL 3/3] iotests/149: Skip on unsupported ciphers Date: Tue, 23 Nov 2021 16:59:09 +0100 Message-Id: <20211123155909.717547-4-hreitz@redhat.com> In-Reply-To: <20211123155909.717547-1-hreitz@redhat.com> References: <20211123155909.717547-1-hreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hreitz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=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: , Cc: Kevin Wolf , Peter Maydell , Hanna Reitz , Richard Henderson , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1637683328994100001 Whenever qemu-img or qemu-io report that some cipher is unsupported, skip the whole test, because that is probably because qemu has been configured with the gnutls crypto backend. We could taylor the algorithm list to what gnutls supports, but this is a test that is run rather rarely anyway (because it requires password-less sudo), and so it seems better and easier to skip it. When this test is intentionally run to check LUKS compatibility, it seems better not to limit the algorithms but keep the list extensive. Signed-off-by: Hanna Reitz Message-Id: <20211117151707.52549-3-hreitz@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/qemu-iotests/149 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149 index 328fd05a4c..d49646ca60 100755 --- a/tests/qemu-iotests/149 +++ b/tests/qemu-iotests/149 @@ -230,6 +230,18 @@ def create_image(config, size_mb): fn.truncate(size_mb * 1024 * 1024) =20 =20 +def check_cipher_support(config, output): + """Check the output of qemu-img or qemu-io for mention of the respecti= ve + cipher algorithm being unsupported, and if so, skip this test. + (Returns `output` for convenience.)""" + + if 'Unsupported cipher algorithm' in output: + iotests.notrun('Unsupported cipher algorithm ' + f'{config.cipher}-{config.keylen}-{config.mode}; ' + 'consider configuring qemu with a different crypto ' + 'backend') + return output + def qemu_img_create(config, size_mb): """Create and format a disk image with LUKS using qemu-img""" =20 @@ -253,7 +265,8 @@ def qemu_img_create(config, size_mb): "%dM" % size_mb] =20 iotests.log("qemu-img " + " ".join(args), filters=3D[iotests.filter_te= st_dir]) - iotests.log(iotests.qemu_img_pipe(*args), filters=3D[iotests.filter_te= st_dir]) + iotests.log(check_cipher_support(config, iotests.qemu_img_pipe(*args)), + filters=3D[iotests.filter_test_dir]) =20 def qemu_io_image_args(config, dev=3DFalse): """Get the args for access an image or device with qemu-io""" @@ -279,8 +292,8 @@ def qemu_io_write_pattern(config, pattern, offset_mb, s= ize_mb, dev=3DFalse): args =3D ["-c", "write -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb= )] args.extend(qemu_io_image_args(config, dev)) iotests.log("qemu-io " + " ".join(args), filters=3D[iotests.filter_tes= t_dir]) - iotests.log(iotests.qemu_io(*args), filters=3D[iotests.filter_test_dir, - iotests.filter_qemu_io]) + iotests.log(check_cipher_support(config, iotests.qemu_io(*args)), + filters=3D[iotests.filter_test_dir, iotests.filter_qemu_io= ]) =20 =20 def qemu_io_read_pattern(config, pattern, offset_mb, size_mb, dev=3DFalse): @@ -291,8 +304,8 @@ def qemu_io_read_pattern(config, pattern, offset_mb, si= ze_mb, dev=3DFalse): args =3D ["-c", "read -P 0x%x %dM %dM" % (pattern, offset_mb, size_mb)] args.extend(qemu_io_image_args(config, dev)) iotests.log("qemu-io " + " ".join(args), filters=3D[iotests.filter_tes= t_dir]) - iotests.log(iotests.qemu_io(*args), filters=3D[iotests.filter_test_dir, - iotests.filter_qemu_io]) + iotests.log(check_cipher_support(config, iotests.qemu_io(*args)), + filters=3D[iotests.filter_test_dir, iotests.filter_qemu_io= ]) =20 =20 def test_once(config, qemu_img=3DFalse): --=20 2.33.1