From nobody Sat May 18 07:31:15 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=1673430339; cv=none; d=zohomail.com; s=zohoarc; b=O0eV69MYjJE9YE49X42zo9+UaiVF9wTFGo1eA9CMiKt7Sm/znWq9vOYe481OI15tI8Kf4vYCHKLmZxqR0ZuyfUKkl2rBznjHuDtHzZImCF8pa+dEuiMiIaxm1YY3ViKdP4Yk/nWv8yX50zsQTfVnDA7kYk4gE34aCZgNHacGLnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673430339; 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=F0Y7uav6Dwmcq3FR9ULiG629Cio42Lt8ZNMdMMN8Kek=; b=ETcQr3JOErPOQMS67GMtgJcLtBbPbe89DMnFZMk9rexdkp20NbwB18e5x6b8RVfG+bvCPSHty8vu2iyURyB/ojSbc7BKf6H7nLzRPRoZDjn87H/v1sUstiP3gZ2as/XD+bO6/pQ/yNa3k4Aa8FtEsLVYOLQLniClnGmQWBJecf8= 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 1673430339177353.03493896307566; Wed, 11 Jan 2023 01:45:39 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-QVmoUYChNa-FiAcPy9J2WQ-1; Wed, 11 Jan 2023 04:45:33 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F18D785A588; Wed, 11 Jan 2023 09:45:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A29F7401530E; Wed, 11 Jan 2023 09:45:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6852C194658F; Wed, 11 Jan 2023 09:45:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DB05C1946587 for ; Wed, 11 Jan 2023 09:45:13 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B50FDC16031; Wed, 11 Jan 2023 09:45:03 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77332C15BA0 for ; Wed, 11 Jan 2023 09:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673430338; 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=F0Y7uav6Dwmcq3FR9ULiG629Cio42Lt8ZNMdMMN8Kek=; b=YQ5yAxDPx2nYGI0T7l2HyVvMjqpBeZwClQDbiZtpVmHJZEJ/w9bJTrSwOr6KmiyI2YEInL gAgriVJb85TPT2mikcV7Uq0dr+efUK944WSx7wh4DOfU3Ydj0zyqTBgEYbD7cVoBPAJRy4 UeekBLmMQvBDnpaTx7d4hV4q6Wp5DkI= X-MC-Unique: QVmoUYChNa-FiAcPy9J2WQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] qemu: Don't check pidfile in qemuPasstStart Date: Wed, 11 Jan 2023 10:44:58 +0100 Message-Id: <09cc85504c59e46f8dd51a10e8ea983bb32cbad7.1673430232.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1673430340683100001 Content-Type: text/plain; charset="utf-8" The pidfile is guaranteed to be non-NULL (thanks to glib allocation functions) and it's dereferenced two lines above anyway. Reported by coverity: /src/qemu/qemu_passt.c: 278 in qemuPasstStart() 272 return 0; 273 274 error: 275 ignore_value(virPidFileReadPathIfLocked(pidfile, &pid)); 276 if (pid !=3D -1) 277 virProcessKillPainfully(pid, true); >>> CID 404360: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "pidfile" suggests that it may be null, but it >>> has already been dereferenced on all paths leading to the check. 278 if (pidfile) 279 unlink(pidfile); 280 281 return -1; Signed-off-by: Jiri Denemark Reviewed-by: Erik Skultety --- src/qemu/qemu_passt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index 3355f7b2fa..5493eee494 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -275,8 +275,7 @@ qemuPasstStart(virDomainObj *vm, ignore_value(virPidFileReadPathIfLocked(pidfile, &pid)); if (pid !=3D -1) virProcessKillPainfully(pid, true); - if (pidfile) - unlink(pidfile); + unlink(pidfile); =20 return -1; } --=20 2.39.0 From nobody Sat May 18 07:31:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1673430369; cv=none; d=zohomail.com; s=zohoarc; b=I60P2MnxCP0IwQX2uTRzYIZikf9xs+V9/ncWDWftovh+mq0bp5tmWymSl7gU+ALvVtQIW/lkQsmfrojZoR5rOGY7GsA3wnVZyCBzjbaOJxGtdAx5rT66KHkDIU1lKZuWf0gkQb2bzW9iBbuM7kYwa8eE/8/xR/vab47zJDmL8BI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673430369; 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=BrFLiyddrvRkUFFwtT/zTp8pnG4dSVvQD3fTgvRtjbM=; b=kw8VHtWGpAA6ouIe2jJZgPB/l27PJrL4qf61TA2l1IOtc/z5/7Ex2U8vHHrUZ4D8jUQmDNv8jY3y8M2A2SirL3MqP68py5vIL2DErMJN30+GtKgC75CV4iRKNzF1NugOqSeshRus9ZwRwkarXuVhb8EOnkKKvNTWiNlp9kHa4+U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1673430369201951.4095448498089; Wed, 11 Jan 2023 01:46:09 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-A0zC4IKqMjyLJMrHss7AeA-1; Wed, 11 Jan 2023 04:45:27 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 515543C10EE4; Wed, 11 Jan 2023 09:45:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38883140EBF4; Wed, 11 Jan 2023 09:45:25 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1FD891946A75; Wed, 11 Jan 2023 09:45:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id B38431946A71 for ; Wed, 11 Jan 2023 09:45:04 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A92142026D2A; Wed, 11 Jan 2023 09:45:04 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C03C2026D76 for ; Wed, 11 Jan 2023 09:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673430368; 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=BrFLiyddrvRkUFFwtT/zTp8pnG4dSVvQD3fTgvRtjbM=; b=PXBWVd4XWRsOz0vpChwL02x3a+t554HjP89FkMDH2GEolLbBQIbQ3AIFoFQmrqidoqDq/C A1vCCXLptQNFNKPc+3rvq4a0qlD2GGZgkUFanlQxBu/W5BK1ZalNQRZFyBbHFyTB7i/cYl H/lIUhSFnvGpTbi7iZUjlCUBOShB1HY= X-MC-Unique: A0zC4IKqMjyLJMrHss7AeA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Jiri Denemark To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] qemu: Change some gotos in qemuPasstStart to direct return Date: Wed, 11 Jan 2023 10:44:59 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1673430370839100001 Content-Type: text/plain; charset="utf-8" Jumping to the error label and reading the pidfile does not make sense until we reached qemuSecurityCommandRun which creates the pidfile. Signed-off-by: Jiri Denemark Reviewed-by: Erik Skultety --- src/qemu/qemu_passt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index 5493eee494..a7ee841af7 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -209,14 +209,14 @@ qemuPasstStart(virDomainObj *vm, /* validation guarantees this will never happen */ virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid portForward proto value %u"), pf->pr= oto); - goto error; + return -1; } =20 if (VIR_SOCKET_ADDR_VALID(&pf->address)) { g_autofree char *addr =3D NULL; =20 if (!(addr =3D virSocketAddrFormat(&pf->address))) - goto error; + return -1; =20 virBufferAddStr(&buf, addr); =20 @@ -258,7 +258,7 @@ qemuPasstStart(virDomainObj *vm, =20 =20 if (qemuExtDeviceLogCommand(driver, vm, cmd, "passt") < 0) - goto error; + return -1; =20 if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus, &cmdr= et) < 0) goto error; --=20 2.39.0