From 55a01cab83b608bae6345b7e0e2fbecc142c1b2f Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Mon, 22 May 2023 20:47:37 +0900 Subject: [PATCH 1/2] crypto: Always initialize splitkeylen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When _FORTIFY_SOURCE=2, glibc version is 2.35, and GCC version is 12.1.0, the compiler complains as follows: In file included from /usr/include/string.h:535, from /home/alarm/q/var/qemu/include/qemu/osdep.h:99, from ../crypto/block-luks.c:21: In function 'memset', inlined from 'qcrypto_block_luks_store_key' at ../crypto/block-luks.c:843:9: /usr/include/bits/string_fortified.h:59:10: error: 'splitkeylen' may be used uninitialized [-Werror=maybe-uninitialized] 59 | return __builtin___memset_chk (__dest, __ch, __len, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 | __glibc_objsize0 (__dest)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ ../crypto/block-luks.c: In function 'qcrypto_block_luks_store_key': ../crypto/block-luks.c:699:12: note: 'splitkeylen' was declared here 699 | size_t splitkeylen; | ^~~~~~~~~~~ It seems the compiler cannot see that splitkeylen will not be used when splitkey is NULL. Suppress the warning by initializing splitkeylen even when splitkey stays NULL. Signed-off-by: Akihiko Odaki Signed-off-by: Daniel P. Berrangé --- crypto/block-luks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 5688783ab1..2f59c3a625 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -706,14 +706,14 @@ qcrypto_block_luks_store_key(QCryptoBlock *block, assert(slot_idx < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS); slot = &luks->header.key_slots[slot_idx]; + splitkeylen = luks->header.master_key_len * slot->stripes; + if (qcrypto_random_bytes(slot->salt, QCRYPTO_BLOCK_LUKS_SALT_LEN, errp) < 0) { goto cleanup; } - splitkeylen = luks->header.master_key_len * slot->stripes; - /* * Determine how many iterations are required to * hash the user password while consuming 1 second of compute From 0e6b20b9656174e815751cf8b21f5e326148bb99 Mon Sep 17 00:00:00 2001 From: "Hongren (Zenithal) Zheng" Date: Sun, 30 Apr 2023 21:58:19 +0800 Subject: [PATCH 2/2] hw/usb/canokey: change license to GPLv2+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apache license is considered by some to be not compatible with GPLv2+. Since QEMU as combined work is GPLv2-only, these two files should be made compatible. Reported-by: "Daniel P. Berrangé" Link: https://lore.kernel.org/qemu-devel/ZEpKXncC%2Fe6FKRe9@redhat.com/ Reviewed-by: Philippe Mathieu-Daudé Acked-By: canokeys.org (http://canokeys.org) Acked-by: YuanYang Meng Signed-off-by: Hongren (Zenithal) Zheng Signed-off-by: Daniel P. Berrangé --- hw/usb/canokey.c | 2 +- hw/usb/canokey.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb/canokey.c b/hw/usb/canokey.c index bbc5da07b5..b306eeb20e 100644 --- a/hw/usb/canokey.c +++ b/hw/usb/canokey.c @@ -4,7 +4,7 @@ * Copyright (c) 2021-2022 Canokeys.org * Written by Hongren (Zenithal) Zheng * - * This code is licensed under the Apache-2.0. + * This code is licensed under the GPL v2 or later. */ #include "qemu/osdep.h" diff --git a/hw/usb/canokey.h b/hw/usb/canokey.h index 24cf304203..e528889d33 100644 --- a/hw/usb/canokey.h +++ b/hw/usb/canokey.h @@ -4,7 +4,7 @@ * Copyright (c) 2021-2022 Canokeys.org * Written by Hongren (Zenithal) Zheng * - * This code is licensed under the Apache-2.0. + * This code is licensed under the GPL v2 or later. */ #ifndef CANOKEY_H