RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1717394 - RFE: add cgroups v2 BPF devices support
Summary: RFE: add cgroups v2 BPF devices support
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: libvirt
Version: 8.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 8.0
Assignee: Pavel Hrdina
QA Contact: yisun
URL:
Whiteboard:
Depends On: 1656432 1689297
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-06-05 12:07 UTC by Pavel Hrdina
Modified: 2020-11-04 02:54 UTC (History)
20 users (show)

Fixed In Version: libvirt-6.0.0-17.el8
Doc Type: Enhancement
Doc Text:
Clone Of: 1689297
: 1717396 (view as bug list)
Environment:
Last Closed: 2020-11-04 02:53:02 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2020:4676 0 None None None 2020-11-04 02:53:55 UTC

Description Pavel Hrdina 2019-06-05 12:07:56 UTC
Description of problem:

In cgroups v2 the devices controller was dropped in favor of eBPF programs.
We need to implement support for eBPF cgroups programs in order to be able
filter access to devices.

This is not critical features as we already create a namespaces for QEMU
process to isolate it from the host.

https://www.kernel.org/doc/Documentation/cgroup-v2.txt
https://www.kernel.org/doc/Documentation/networking/filter.txt
https://cilium.readthedocs.io/en/v1.3/bpf/

Comment 7 yisun 2020-06-05 10:31:44 UTC
Verified
[root@lenovo-sr630-13 ~]# rpm -qa | grep ^libvirt-6
libvirt-6.4.0-1.module+el8.3.0+6881+88468c00.x86_64

[root@lenovo-sr630-13 ~]# setenforce 0

1. Check the default libvirt setting
[root@lenovo-sr630-13 ~]# cat /etc/libvirt/qemu.conf | grep cgroup_device_acl -A10
#cgroup_device_acl = [
#    "/dev/null", "/dev/full", "/dev/zero",
#    "/dev/random", "/dev/urandom",
#    "/dev/ptmx", "/dev/kvm"
#]

[root@lenovo-sr630-13 ~]# python get_bpf_map.py /sys/fs/cgroup/machine.slice/machine-qemu\\x2d3\\x2davocado\\x2dvt\\x2dvm1.scope/
c 136:* rw
c 1:9 rw		urandom
c 1:8 rw		random
c 5:2 rw		ptmx
c 1:7 rw		full
c 10:232 rw		kvm
c 1:3 rw		null
c 1:5 rw		zero
<===== all devices existing in bpf map


2. Remove /dev/zero form the qemu.conf
[root@lenovo-sr630-13 ~]# cat /etc/libvirt/qemu.conf | grep cgroup_device_acl -A10
cgroup_device_acl = [
    "/dev/null", "/dev/full",
    "/dev/random", "/dev/urandom",
    "/dev/ptmx", "/dev/kvm"
]

[root@lenovo-sr630-13 ~]# virsh destroy avocado-vt-vm1
vDomain avocado-vt-vm1 destroyed

[root@lenovo-sr630-13 ~]# virsh start avocado-vt-vm1
Domain avocado-vt-vm1 started

[root@lenovo-sr630-13 ~]# python get_bpf_map.py /sys/fs/cgroup/machine.slice/machine-qemu\\x2d4\\x2davocado\\x2dvt\\x2dvm1.scope/
c 1:9 rw		urandom
c 1:8 rw		random
c 5:2 rw		ptmx
c 1:7 rw		full
c 10:232 rw		kvm
c 136:* rw
c 1:3 rw		null
<==== zero gone as expected

3. Test hot plug and unplug a new device to vm
Using a local block device
[root@lenovo-sr630-13 ~]# ll /dev/sdb
brw-rw----. 1 root disk 8, 16 Jun  5 06:26 /dev/sdb

[root@lenovo-sr630-13 ~]# python get_bpf_map.py /sys/fs/cgroup/machine.slice/machine-qemu\\x2d4\\x2davocado\\x2dvt\\x2dvm1.scope/
c 1:9 rw		urandom
c 1:8 rw		random
c 5:2 rw		ptmx
c 1:7 rw		full
c 10:232 rw		kvm
c 136:* rw
c 1:3 rw		null

[root@lenovo-sr630-13 ~]# virsh attach-disk avocado-vt-vm1 /dev/sdb vdb
Disk attached successfully

[root@lenovo-sr630-13 ~]# python get_bpf_map.py /sys/fs/cgroup/machine.slice/machine-qemu\\x2d4\\x2davocado\\x2dvt\\x2dvm1.scope/
c 1:9 rw		urandom
c 1:8 rw		random
c 5:2 rw		ptmx
c 1:7 rw		full
c 10:232 rw		kvm
c 136:* rw
b 8:16 rw		sdb
<======= added as expected
c 1:3 rw		null

[root@lenovo-sr630-13 ~]# virsh detach-disk avocado-vt-vm1 vdb
Disk detached successfully

[root@lenovo-sr630-13 ~]# python get_bpf_map.py /sys/fs/cgroup/machine.slice/machine-qemu\\x2d4\\x2davocado\\x2dvt\\x2dvm1.scope/
c 1:9 rw		urandom
c 1:8 rw		random
c 5:2 rw		ptmx
c 1:7 rw		full
c 10:232 rw		kvm
c 136:* rw
None 8:16
<======= still hit bz1810356
c 1:3 rw		null

Comment 10 errata-xmlrpc 2020-11-04 02:53:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: virt:rhel and virt-devel:rhel security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:4676


Note You need to log in before you can comment on or make changes to this bug.