From nobody Tue Oct 22 22:29:04 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=1694699849; cv=none; d=zohomail.com; s=zohoarc; b=bh3tlbgONcXfeKQ2+eLhl2qgxxJLIMQtfLS/nVsZiz0JucxU9pK05ZVSQmzjwLgRJvc3ktWWJk3oAwP/cDHlFM6/OQmKZXJyljuCkOUKs/w/FvAgYml608BnSptCbDzC++JhCI/y2BJpLA/MVnZKtZmfUpukrP1lQbmZexmUuhQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694699849; 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=qLzYpchZnDixM+vsdmYYQURpw1ymxTqaCD9gMmUQiWI=; b=I/Ao3ma1NqWynuIl+ZIAi4Dkf8hyed3qZStbGhNfwXInE/DpTdXMRveb+I9dyfTIYD708evPun1WQSSL9mzaEZLdfO5CeG28Z9Ccq30DRozTFLTOyL8DWtY8Og2dBYtsWyyb5WoidERTHd1p2+8xW+YAUePXoCIq7sLK3pMJiJ4= 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 1694699849550169.27861678924376; Thu, 14 Sep 2023 06:57:29 -0700 (PDT) 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-638-N4FFIK1wPe-homiUyxmsFg-1; Thu, 14 Sep 2023 09:57:23 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A82F5800045; Thu, 14 Sep 2023 13:57:20 +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 9392C40C6EC1; Thu, 14 Sep 2023 13:57:20 +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 ED81A1946A43; Thu, 14 Sep 2023 13:56:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6871A19465BB for ; Thu, 14 Sep 2023 13:56:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 53ECE40C6EC1; Thu, 14 Sep 2023 13:56:26 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.2.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id F042440C6EBF for ; Thu, 14 Sep 2023 13:56:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694699848; 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=qLzYpchZnDixM+vsdmYYQURpw1ymxTqaCD9gMmUQiWI=; b=Q5OrlyxAvYY8DvhLozCqEXaP+Di9OJG7Y8oMCxBUFqXrIl92cMDvxKjPe/2SZYRC38snd2 BxzDGS6w3r2i7XCVeEx1bGNGR8lB5Km3xjP1QQoiFvb8zDgVazmmqYKRbz/el8MoCxtZVO 45EAl0f50JOI3Rk1BU1HNoi3x399Ehc= X-MC-Unique: N4FFIK1wPe-homiUyxmsFg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/20] src: Access hostdev->source.subsys iff VIR_DOMAIN_HOSTDEV_MODE_SUBSYS Date: Thu, 14 Sep 2023 15:56:03 +0200 Message-ID: <860ccc4428c1d7d10e71fbedbb0cbc0ecca78e43.1694699681.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: 1694699850569100001 Content-Type: text/plain; charset="utf-8"; x-default="true" There are few places where a virDomainHostdevDef->source.subsys is accessed without ->mode being checked. Mind you, virDomainHostdevDef can be also in VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES mode. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 3 ++- src/conf/domain_validate.c | 3 ++- src/security/virt-aa-helper.c | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1f14ef6f23..9d819c3dab 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5099,7 +5099,8 @@ virDomainDriveAddressIsUsedByHostdev(const virDomainD= ef *def, for (i =3D 0; i < def->nhostdevs; i++) { hostdev =3D def->hostdevs[i]; =20 - if (hostdev->source.subsys.type !=3D type || + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || + hostdev->source.subsys.type !=3D type || hostdev->info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) continue; =20 diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b050f21edb..53d920b2b3 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1283,7 +1283,8 @@ virDomainDefHostdevValidate(const virDomainDef *def) } } =20 - if (dev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= MDEV && + if (dev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && + dev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= MDEV && dev->source.subsys.u.mdev.ramfb =3D=3D VIR_TRISTATE_SWITCH_ON)= { if (ramfbEnabled) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index c50629d096..4638451183 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1049,6 +1049,10 @@ get_files(vahControl * ctl) if (ctl->def->hostdevs[i]) { virDomainHostdevDef *dev =3D ctl->def->hostdevs[i]; virDomainHostdevSubsysUSB *usbsrc =3D &dev->source.subsys.u.us= b; + + if (dev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) + continue; + switch (dev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: { virUSBDevice *usb =3D --=20 2.41.0