Bug 1810356
| Summary: | [cgroup2] When detach a device from vm, the device entry not removed from vm's bpf map | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux Advanced Virtualization | Reporter: | yisun |
| Component: | libvirt | Assignee: | Pavel Hrdina <phrdina> |
| Status: | CLOSED ERRATA | QA Contact: | yisun |
| Severity: | low | Docs Contact: | |
| Priority: | low | ||
| Version: | 8.2 | CC: | jdenemar, jsuchane, lmen, virt-maint, xuzhang, yisun |
| Target Milestone: | rc | Keywords: | Triaged |
| Target Release: | 8.0 | Flags: | pm-rhel:
mirror+
|
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-7.0.0-1.el8 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2021-05-25 06:41:21 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | 7.0.0 |
| Embargoed: | |||
|
Description
yisun
2020-03-05 04:06:00 UTC
Upstream commit:
commit 0cbcd21b1f981dcca7879130a6653725db87d33a
Author: Pavel Hrdina <phrdina>
Date: Wed Nov 25 17:21:49 2020 +0100
vircgroupv2: fix virCgroupV2DenyDevice
Tested with libvirt-7.0.0-1.module+el8.4.0+9464+3e71831a.x86_64
result is : PASS
1. Set selinux to permissive to make sure bpftool can get ebpf info
[root@dell-per740-39 ~]# setenforce 0
2. Get the bpf map info for running vm (vm1)
[root@dell-per740-39 ~]# bpftool cgroup list /sys/fs/cgroup/machine.slice/machine-qemu\\x2d1\\x2dvm1.scope/
ID AttachType AttachFlags Name
149 device
<== vm's eBPF program id is 149
[root@dell-per740-39 ~]# bpftool prog show id 149
149: cgroup_device tag b95e404d31962705 gpl
loaded_at 2021-01-17T03:13:31-0500 uid 0
xlated 616B jited 347B memlock 4096B map_ids 149
<== vm's eBPF map id is 149
[root@dell-per740-39 ~]# bpftool map dump id 149
key: 03 00 00 00 01 00 00 00 value: 02 00 06 00
key: 05 00 00 00 01 00 00 00 value: 02 00 06 00
key: 07 00 00 00 01 00 00 00 value: 02 00 06 00
key: 09 00 00 00 01 00 00 00 value: 02 00 06 00
key: ff ff ff ff 88 00 00 00 value: 02 00 06 00
key: 02 00 00 00 05 00 00 00 value: 02 00 06 00
key: e8 00 00 00 0a 00 00 00 value: 02 00 06 00
key: 08 00 00 00 01 00 00 00 value: 02 00 06 00
Found 8 elements
<== Here is 8 elements now, means vm has access right to 8 devices
3. prepare a block device on host, here we use targetcli to prepare a iscsi device (/dev/sdb)
[root@dell-per740-39 ~]# lsscsi
[0:2:0:0] disk DELL PERC H730P Adp 4.30 /dev/sda
[15:0:0:0] disk LIO-ORG device.logical- 4.0 /dev/sdb
4. Attach the deivce to vm
[root@dell-per740-39 ~]# cat disk.xml
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/sdb'/>
<target dev='vdbd' bus='virtio'/>
</disk>
[root@dell-per740-39 ~]# virsh attach-device vm1 disk.xml
Device attached successfully
5. Check the bpf map
[root@dell-per740-39 ~]# bpftool map dump id 149
key: 03 00 00 00 01 00 00 00 value: 02 00 06 00
key: 10 00 00 00 08 00 00 00 value: 01 00 06 00 <==== newly attached device
key: 05 00 00 00 01 00 00 00 value: 02 00 06 00
key: 07 00 00 00 01 00 00 00 value: 02 00 06 00
key: 09 00 00 00 01 00 00 00 value: 02 00 06 00
key: ff ff ff ff 88 00 00 00 value: 02 00 06 00
key: 02 00 00 00 05 00 00 00 value: 02 00 06 00
key: e8 00 00 00 0a 00 00 00 value: 02 00 06 00
key: 08 00 00 00 01 00 00 00 value: 02 00 06 00
Found 9 elements
<== now we found 9 elements, and the newly added one is 'key: 10 00 00 00 08 00 00 00 value: 01 00 06 00'
6. Detach the device from vm
[root@dell-per740-39 ~]# virsh detach-device vm1 disk.xml
Device detached successfully
7. Check the bpf map
[root@dell-per740-39 ~]# bpftool map dump id 149
key: 03 00 00 00 01 00 00 00 value: 02 00 06 00
key: 05 00 00 00 01 00 00 00 value: 02 00 06 00
key: 07 00 00 00 01 00 00 00 value: 02 00 06 00
key: 09 00 00 00 01 00 00 00 value: 02 00 06 00
key: ff ff ff ff 88 00 00 00 value: 02 00 06 00
key: 02 00 00 00 05 00 00 00 value: 02 00 06 00
key: e8 00 00 00 0a 00 00 00 value: 02 00 06 00
key: 08 00 00 00 01 00 00 00 value: 02 00 06 00
Found 8 elements
<==== As expected, the entry 'key: 10 00 00 00 08 00 00 00 value: 01 00 06 00' removed from the bpf map
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 (virt:av 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/RHBA-2021:2098 |