From nobody Wed Nov 25 22:10:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1790637379; cv=none; d=zohomail.com; s=zohoarc; b=HK4qvY7wXOOWo89QgIlppXXAaTTRPQnPpBAMWrpwe/nhI3/dfvekf+dyN73Z0L01EwX5KKzZCrsdBBpx/kM1ShDDc3Ox0NkfNs7VRL5vmADLEFBA9Q1j7CYTm+YA5QrnxmTnwNdu1l6GI3U3ulBYJtAHMaHLjujxdSwCzMbUoJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790637379; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=k89VqZoxg4fXtGUeZYwjh05KMrMryTADqFem9g24wdQ=; b=UzLopOpg7+G0MPPWnj5YJLGkdZviTEc4jc/R88ypeWWNyeLndp91SdVxgVGVgn0Sh1Yv/tA7jZ2D6Fwy85j/t7KjXSI9qVTTxEoQU21a33x8+9gSTMDUMo7/BUrmrY81onenA7pkPTViKqQ244kZ6+fc0tbV624JOlnARZ29c8c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1790637379029140.1805251413101; Mon, 28 Sep 2026 16:16:19 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 824A53F31F; Mon, 28 Sep 2026 19:16:17 -0400 (EDT) Received: from [172.19.199.16] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 1E960419A7; Mon, 28 Sep 2026 19:15:12 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 00A003F292; Mon, 28 Sep 2026 19:15:03 -0400 (EDT) Received: from smtp-relay-canonical-1.canonical.com (smtp-relay-canonical-1.canonical.com [185.125.188.121]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id AAAB23F313 for ; Mon, 28 Sep 2026 19:15:02 -0400 (EDT) Received: from localhost.localdomain (2.general.hector.uk.vpn [10.172.192.135]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id B3F16414F0; Mon, 28 Sep 2026 23:07:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 X-Greylist: delayed 439 seconds by postgrey-1.37 at lists.libvirt.org; Mon, 28 Sep 2026 19:15:02 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20251003; t=1790636860; bh=k89VqZoxg4fXtGUeZYwjh05KMrMryTADqFem9g24wdQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MRthy1Y6H7sByy7pz+e++tBPtBeU2HMsq9c3UHG5fhV5z2c+BUSLEqE9dG4aCJiBl /7NKqK6fNZEqFfJz9/Xqzygz9wc2n0ii7FbW/8iCM4+2LszW/i1tcs+Mk9FKCSEj1R DTAsQwCI6/9w5Do7y6JUIOHYftsA6VsYtRaCfQUz8Ab8IO40anu0VJ5h9RD8abqcyP 9P6we/cxuLdYIGxV2uzamma0OZoSWM9Ebalw6jjVCL1gCxzHtVhs7nJ15Jat5SZs7c 78icTi6NEyv2bhQtjVD25AxAupSLSl9PrEOTml5qoUFrwJ1kHMEmC6lnU4QMTiIphC HoxY+ARKJX1WE5l+NJUXYI/wHd6uLRxy4bQxWQLbrIhnYCn1v9EtGXDrc39h+if10d Z2BIcF3o5n1rpCuGK6zHjvigu7rScwjpj+nXC6icaY+jiYWt4+4H1X1AN+oO05elq0 1Oi9+/Xd8pH2JmQmoa/iV7gvnlJZQaVEHrmBeoft3TEsALBBqTuU794Fw9G3cPttHA e4VkA6BSOGBc3qbXo2L66/ymoL+7VB1rEqqFax9RORgTa+WCKyDhZLLNB3wg19jJ+Y VCYqFxQkqOsmiI/9z8wV7bLOp19EY+p3HdnRBGHd7gDLQzhOrze8fIyL5vhu0uOa07 KOD6a4PdtyBCpXZig/u09PNk= To: devel@lists.libvirt.org Subject: [PATCH] apparmor: Allow reading device uevent files for USB hostdev Date: Tue, 29 Sep 2026 01:07:35 +0200 Message-ID: <20260928230735.993363-1-hector.cao@canonical.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: STRKGEF4HSYTDAZHBEUQADPM3S4IIGHN X-Message-ID-Hash: STRKGEF4HSYTDAZHBEUQADPM3S4IIGHN X-MailFrom: hector.cao@canonical.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Hector Cao X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Hector Cao via Devel Reply-To: Hector Cao X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1790637383488158500 Content-Type: text/plain; charset="utf-8" From: Hector Cao Attaching a USB device as a fails under the libvirt-qemu AppArmor profile because QEMU (via libusb) walks up the sysfs topology of the passed-through device and reads the uevent file of the parent USB host controller, which is a PCI (or platform) device that lives one level above the usb[0-9]* directory: /sys/devices/pci0000:00/0000:00:01.2/uevent The existing rule only grants read access to everything *under* a usb[0-9]* directory: /sys/devices/**/usb[0-9]*/** r, so the controller's uevent, which sits above usb[0-9]*, is not covered and the access is denied: apparmor=3D"DENIED" operation=3D"open" class=3D"file" profile=3D"libvirt-" name=3D"/sys/devices/pci0000:00/0000:00:01.2/uevent" comm=3D"qemu-system-x86" requested_mask=3D"r" denied_mask=3D"r" uevent files only expose non-sensitive device metadata (driver name, modalias, PCI IDs, DEVTYPE, etc.), so grant read access to uevent files across the device tree might be acceptable. This is enough to let USB hostdev attach and hotplug succeed without broadening access to any other sysfs attribute. Signed-off-by: Hector Cao Reviewed-by: Michal Privoznik --- src/security/apparmor/libvirt-qemu | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/security/apparmor/libvirt-qemu b/src/security/apparmor/lib= virt-qemu index 428f9a9731..9bf572692b 100644 --- a/src/security/apparmor/libvirt-qemu +++ b/src/security/apparmor/libvirt-qemu @@ -45,6 +45,12 @@ /sys/bus/usb/devices/ r, /sys/bus/usb/devices/* r, /sys/devices/**/usb[0-9]*/** r, + # For USB hostdev access, QEMU (via libusb) walks up the sysfs topology + # of the passed-through device and reads the uevent of the parent USB + # host controller, which sits one level above the usb[0-9]* directory + # (e.g. /sys/devices/pci0000:00/0000:00:01.2/uevent). uevent files only + # expose non-sensitive device metadata. + /sys/devices/**/uevent r, # libusb needs udev data about usb devices (~equal to content of lsusb -= v) /run/udev/data/+usb* r, /run/udev/data/c16[6,7]* r, --=20 2.43.0