From nobody Sun May 19 12:00:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644396009; cv=none; d=zohomail.com; s=zohoarc; b=eAsAzY4W24HXso+XgVg3j+JQoMLBmjLiN8gUYHoE2M3A7didsFG8PxhV0yFGqIBrlFJO0NOkHun2FjBE8g9e/H9gCikRAetJTjR6PN25CRUjCUtWvv/2sCFwe6QqBb37qqED6e8gJhkV0BGZIw7oASi0girckiGP/2CA9X3o4Wg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644396009; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0Rb/OTlU8jpfLg9iSdP9i9kMeqgsIDM8/xV3QEjKL78=; b=Gw9M4PVKg7VtGbGlvggmJTO5ZYx8T05FFDxHA5xs3hJdd4QmIqQfmluytXqEy6VWxA93O7FCIJ9Ymb4yRzCp1UD3BMRVSkklM2WXfv/ATSOijx2kW2nLek07pbWct/7Zz1DXJWTfObZyfA9PMwQmj9GPmFxzQiflj8NIXbziFFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1644396009490506.70658492304005; Wed, 9 Feb 2022 00:40:09 -0800 (PST) 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-639-0J-YUzn_OoW1T6xG6LwzHA-1; Wed, 09 Feb 2022 03:40:05 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 322BD1091DA1; Wed, 9 Feb 2022 08:40:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E701227CC5; Wed, 9 Feb 2022 08:39:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A59014BB7C; Wed, 9 Feb 2022 08:39:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2198dr7N019082 for ; Wed, 9 Feb 2022 03:39:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 889017AB45; Wed, 9 Feb 2022 08:39:53 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 135BA7AB5F for ; Wed, 9 Feb 2022 08:39:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644396008; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0Rb/OTlU8jpfLg9iSdP9i9kMeqgsIDM8/xV3QEjKL78=; b=XUobjGiNWnoDG7LThgIDrOD4zkhgeWDVOuhQ/EndIrwG4D8jO458J6ZcSRW/qZnXVrzL1M tJba0AphRvq3O9/5WgRMiLPNUtP/1v9XXpf3K2lO8ipsEdW1TsADjfDsHs/TK1Q+itExwH XckmKN1ixZ1+L0s65OjQedFdGnPeL7A= X-MC-Unique: 0J-YUzn_OoW1T6xG6LwzHA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/2] qemu_process.c: Fix VIR_QEMU_PROCESS_START_RESET_NVRAM value Date: Wed, 9 Feb 2022 09:39:49 +0100 Message-Id: <1b636593c76f443169ef7bdb3644fd670379d04e.1644395944.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1644396009815100001 Content-Type: text/plain; charset="utf-8" In one of recent commits qemuProcessStartFlags enum gained new value: VIR_QEMU_PROCESS_START_RESET_NVRAM but due to a typo it has the same value as another member of the enum. Fix that. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_process.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index f6c0d63d11..f6dd3f5104 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -79,7 +79,7 @@ typedef enum { VIR_QEMU_PROCESS_START_PRETEND =3D 1 << 3, VIR_QEMU_PROCESS_START_NEW =3D 1 << 4, /* internal, new VM is= starting */ VIR_QEMU_PROCESS_START_GEN_VMID =3D 1 << 5, /* Generate a new VMID= */ - VIR_QEMU_PROCESS_START_RESET_NVRAM =3D 1 << 5, /* Re-initialize NVRAM= from template */ + VIR_QEMU_PROCESS_START_RESET_NVRAM =3D 1 << 6, /* Re-initialize NVRAM= from template */ } qemuProcessStartFlags; =20 int qemuProcessStart(virConnectPtr conn, --=20 2.34.1 From nobody Sun May 19 12:00:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1644396009; cv=none; d=zohomail.com; s=zohoarc; b=X0ep5ZwAQTYwi/RZ1HoqGGhUvABSuv1OTrX4Wbd0j39WzTxoC1Ih6M+7CzcoPgNYYgIRGIxB20K36nDNJb0oBEaJrnBmzW3NFqAqRHz1m94Z9LCcm1g6Pxem4rnae8n8ppo2FRaYroYNVZVmkOnh7yJ/ZNGsw6QbubP4VfQ/NoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644396009; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uzD6nVRCo+YTlbXCA7r6vW+3pHi4ZCoYefOkwvHAVbY=; b=VuyfRh0PMSqzlGluREOatg8qyrvmGQP2ujjh15d6jtF+ML340LePv0FNDGPRyxgfDysTLlWSDVcPEvxJJPt/en4cFbhJYvgTF+BomgYVc7l1XWYLrSVR4a83eB6vLGU5HdYgHsiuA0D7KS8rkkmTztE6pH2EPknwjrDRyE8QZ1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1644396009516799.6102566661657; Wed, 9 Feb 2022 00:40:09 -0800 (PST) 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-589-lhVA_C4BNMaTIynvyn0DCQ-1; Wed, 09 Feb 2022 03:40:05 -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 327BB84DA41; Wed, 9 Feb 2022 08:40:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED4F87AB5F; Wed, 9 Feb 2022 08:39:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B96524A7C8; Wed, 9 Feb 2022 08:39:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 2198dspb019087 for ; Wed, 9 Feb 2022 03:39:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 563207AB48; Wed, 9 Feb 2022 08:39:54 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4E907AB45 for ; Wed, 9 Feb 2022 08:39:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644396008; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uzD6nVRCo+YTlbXCA7r6vW+3pHi4ZCoYefOkwvHAVbY=; b=H4JpUh+L/PrI4NDpN+QgGfqhMVOhyctYjBWO5KWsDS+giJeFDdrm8880tUZLBBgoZrcDgQ k5tmWRpT98PaIbDAVq1qJfApSoyUNaaSk2GvKl+zYJKldV1xLuC1r4x0sLWiL05DgdaroB rSr1fS4uU+LLF4WMSI+9DhiQ/geT7ww= X-MC-Unique: lhVA_C4BNMaTIynvyn0DCQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/2] qemu_process: Fix theoretical overflow in uint to bool typecast Date: Wed, 9 Feb 2022 09:39:50 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1644396009833100002 Content-Type: text/plain; charset="utf-8" The qemuPrepareNVRAM() function accepts three arguments and the last one being a boolean type. However, when the function is called from qemuProcessPrepareHost() the argument passed is a result of logical and of @flags (unsigned int) and VIR_QEMU_PROCESS_START_RESET_NVRAM value. In theory this is unsafe to do because if the value of the flag is ever changed then this expression might overflow. Do what we do elsewhere: double negation. Signed-off-by: Michal Privoznik --- src/qemu/qemu_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 7066696f31..24873f6fb7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6983,7 +6983,7 @@ qemuProcessPrepareHost(virQEMUDriver *driver, qemuProcessMakeDir(driver, vm, priv->channelTargetDir) < 0) return -1; =20 - if (qemuPrepareNVRAM(driver, vm, flags & VIR_QEMU_PROCESS_START_RESET_= NVRAM) < 0) + if (qemuPrepareNVRAM(driver, vm, !!(flags & VIR_QEMU_PROCESS_START_RES= ET_NVRAM)) < 0) return -1; =20 if (vm->def->vsock) { --=20 2.34.1