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 1162707 - qemu-guest-agent in guest is denied by selinux-policy when do s3/s4
Summary: qemu-guest-agent in guest is denied by selinux-policy when do s3/s4
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.1
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Miroslav Grepl
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-11 14:06 UTC by Luyao Huang
Modified: 2015-03-05 10:46 UTC (History)
10 users (show)

Fixed In Version: selinux-policy-3.13.1-17.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 10:46:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
audit.log (16.66 KB, text/plain)
2014-12-04 08:37 UTC, Luyao Huang
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0458 0 normal SHIPPED_LIVE selinux-policy bug fix and enhancement update 2015-03-05 15:17:00 UTC

Description Luyao Huang 2014-11-11 14:06:03 UTC
Description of problem:
qemu-guest-agent in guest is denied by selinux-policy when do s3/s4 

Version-Release number of selected component (if applicable):

IN guest:
selinux-policy-targeted-3.13.1-9.el7.noarch
selinux-policy-3.13.1-9.el7.noarch
qemu-guest-agent-2.1.0-4.el7.x86_64
systemd-208-19.el7.x86_64

How reproducible:


Steps to Reproduce:
1.prepare a happy guest have agent
    <channel type='unix'>
      <source mode='bind' path='/var/lib/libvirt/qemu/r7.agent'/>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='9'/>
    </channel>

2.start it and after guest os start do s3/s4 via libvirt command:
# virsh dompmsuspend r7 mem
error: Domain r7 could not be suspended
error: internal error: unable to execute QEMU agent command 'guest-suspend-ram': child process has failed to suspend


3.get avc error IN guest, something like:

type=AVC msg=audit(1415714424.618:414): avc:  denied  { read } for  pid=3050 comm="pm-is-supported" name="passwd" dev="dm-0" ino=10756798 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:object_r:passwd_file_t:s0 tclass=file
type=SYSCALL msg=audit(1415714424.618:414): arch=c000003e syscall=2 success=no exit=-13 a0=7f20b8508d8a a1=80000 a2=1b6 a3=0 items=0 ppid=684 pid=3050 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="pm-is-supported" exe="/usr/bin/bash" subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null)
type=AVC msg=audit(1415714424.623:415): avc:  denied  { getattr } for  pid=3050 comm="pm-is-supported" path="/dev/snapshot" dev="devtmpfs" ino=6516 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:object_r:apm_bios_t:s0 tclass=chr_file
type=SYSCALL msg=audit(1415714424.623:415): arch=c000003e syscall=4 success=no exit=-13 a0=1a7a100 a1=7fffdf7de070 a2=7fffdf7de070 a3=8 items=0 ppid=684 pid=3050 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="pm-is-supported" exe="/usr/bin/bash" subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null)
unconfined_u:object_r:devicekit_var_log_t:s0 tclass=file
type=SYSCALL msg=audit(1415714424.667:420): arch=c000003e syscall=280 success=no exit=-13 a0=ffffffffffffff9c a1=7fff729ecb55 a2=0 a3=0 items=0 ppid=3062 pid=3084 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="touch" exe="/usr/bin/touch" subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null)
type=AVC msg=audit(1415714424.668:421): avc:  denied  { open } for  pid=3062 comm="pm-suspend" path="/var/log/pm-suspend.log" dev="dm-0" ino=19406745 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=unconfined_u:object_r:devicekit_var_log_t:s0 tclass=file
type=SYSCALL msg=audit(1415714424.668:421): arch=c000003e syscall=2 success=no exit=-13 a0=1058370 a1=441 a2=1b6 a3=0 items=0 ppid=684 pid=3062 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="pm-suspend" exe="/usr/bin/bash" subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null)
type=AVC msg=audit(1415714424.668:422): avc:  denied  { open } for  pid=3062 comm="pm-suspend" path="/var/log/pm-suspend.log" dev="dm-0" ino=19406745 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=unconfined_u:object_r:devicekit_var_log_t:s0 tclass=file
type=SYSCALL msg=audit(1415714424.668:422): arch=c000003e syscall=2 success=no exit=-13 a0=1058370 a1=401 a2=1b6 a3=0 items=0 ppid=684 pid=3062 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="pm-suspend" exe="/usr/bin/bash" subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null)


Actual results:
cannot do s3/s4 via qemu-guest-agent

Expected results:
no avc and do s3/s4 success

Additional info:

IN guest :

check qemu-guest-agent serice labels:
# ps -efZ|grep qemu-ga

system_u:system_r:virt_qemu_ga_t:s0 root   684     1  0 21:53 ?        00:00:00 /usr/bin/qemu-ga --method=virtio-serial --path=/dev/virtio-ports/org.qemu.guest_agent.0 --blacklist=guest-file-open guest-file-close guest-file-read guest-file-write guest-file-seek guest-file-flush -F/etc/qemu-ga/fsfreeze-hook

And do not find this issue with old selinux

Comment 1 Milos Malik 2014-11-11 14:14:12 UTC
Based on "success=no" I guess that AVCs were caught in enforcing mode. Could you re-test your scenario in permissive mode and collect AVCs too?

# ausearch -m avc -m user_avc -m selinux_err -i -ts today

Thanks you.

Comment 2 Luyao Huang 2014-11-11 14:21:37 UTC
# getenforce 
Permissive

# ausearch -m avc -m user_avc -m selinux_err -i -ts today

type=SYSCALL msg=audit(11/11/2014 22:19:01.854:521) : arch=x86_64 syscall=access success=yes exit=0 a0=0x17ee630 a1=X_OK a2=0x7fffc2bac690 a3=0x7fffc2bac520 items=0 ppid=3846 pid=3874 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=00logging exe=/usr/bin/bash subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null) 
type=AVC msg=audit(11/11/2014 22:19:01.854:521) : avc:  denied  { execute } for  pid=3874 comm=00logging name=kmod dev="dm-0" ino=9092337 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:object_r:insmod_exec_t:s0 tclass=file 
----
type=SYSCALL msg=audit(11/11/2014 22:19:01.854:522) : arch=x86_64 syscall=access success=yes exit=0 a0=0x17ee630 a1=R_OK a2=0x7fffc2bac690 a3=0x7fffc2bac520 items=0 ppid=3846 pid=3874 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=00logging exe=/usr/bin/bash subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null) 
type=AVC msg=audit(11/11/2014 22:19:01.854:522) : avc:  denied  { read } for  pid=3874 comm=00logging name=kmod dev="dm-0" ino=9092337 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:object_r:insmod_exec_t:s0 tclass=file 
----
type=SYSCALL msg=audit(11/11/2014 22:19:01.855:523) : arch=x86_64 syscall=execve success=yes exit=0 a0=0x17ee630 a1=0x17ec450 a2=0x17ee690 a3=0x7fffc2bac640 items=0 ppid=3874 pid=3876 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=lsmod exe=/usr/bin/kmod subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null) 
type=AVC msg=audit(11/11/2014 22:19:01.855:523) : avc:  denied  { execute_no_trans } for  pid=3876 comm=00logging path=/usr/bin/kmod dev="dm-0" ino=9092337 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:object_r:insmod_exec_t:s0 tclass=file 
type=AVC msg=audit(11/11/2014 22:19:01.855:523) : avc:  denied  { open } for  pid=3876 comm=00logging path=/usr/bin/kmod dev="dm-0" ino=9092337 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:object_r:insmod_exec_t:s0 tclass=file 
----
type=SYSCALL msg=audit(11/11/2014 22:19:02.012:537) : arch=x86_64 syscall=open success=yes exit=4 a0=0x1aa8140 a1=O_WRONLY|O_CREAT|O_TRUNC a2=0666 a3=0x7fffe1b97f60 items=0 ppid=3975 pid=3976 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=sysctl exe=/usr/sbin/sysctl subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null) 
type=AVC msg=audit(11/11/2014 22:19:02.012:537) : avc:  denied  { write } for  pid=3976 comm=sysctl name=acpi_video_flags dev="proc" ino=42006 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:object_r:sysctl_kernel_t:s0 tclass=file 
----
type=USER_AVC msg=audit(11/11/2014 22:19:19.228:552) : pid=728 uid=dbus auid=unset ses=unset subj=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 msg='avc:  denied  { send_msg } for msgtype=method_call interface=org.freedesktop.PackageKit member=StateHasChanged dest=org.freedesktop.PackageKit spid=4065 tpid=3571 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:system_r:rpm_t:s0-s0:c0.c1023 tclass=dbus  exe=/usr/bin/dbus-daemon sauid=dbus hostname=? addr=? terminal=?' 
----
type=SYSCALL msg=audit(11/11/2014 22:19:19.293:553) : arch=x86_64 syscall=stat success=yes exit=0 a0=0x223e3e0 a1=0x7fff1db4dec0 a2=0x7fff1db4dec0 a3=0x8 items=0 ppid=4079 pid=4080 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=pm-powersave exe=/usr/bin/bash subj=system_u:system_r:virt_qemu_ga_t:s0 key=(null) 
type=AVC msg=audit(11/11/2014 22:19:19.293:553) : avc:  denied  { getattr } for  pid=4080 comm=pm-powersave path=/dev/snapshot dev="devtmpfs" ino=6516 scontext=system_u:system_r:virt_qemu_ga_t:s0 tcontext=system_u:object_r:apm_bios_t:s0 tclass=chr_file 


(some of them)

Comment 3 Miroslav Grepl 2014-12-02 12:12:52 UTC
Do you have all AVCs from permissive mode?

Comment 4 Luyao Huang 2014-12-04 08:37:36 UTC
Created attachment 964478 [details]
audit.log

Comment 5 Luyao Huang 2014-12-04 08:38:37 UTC
I have give the audit log in permissive mode.

Comment 6 Miroslav Grepl 2014-12-12 15:11:57 UTC
commit 5bea5d85e0e8efd89fbc64b3d235c7f5e834e18a
Author: Miroslav Grepl <mgrepl>
Date:   Fri Dec 12 16:09:56 2014 +0100

    Allow virt_qemu_ga_t to execute kmod.

Comment 9 Miroslav Grepl 2015-01-20 18:41:38 UTC
commit 08f6adcb6558180867d40422b5c7a9739f1a59de
Author: Miroslav Grepl <mgrepl>
Date:   Tue Jan 20 19:40:03 2015 +0100

    Allow pm-suspend running as virt_qemu_ga to read /var/log/pm-suspend.log.

commit b08e0e36ba694dc7e3fd7d027542f9fdddca444e
Author: Miroslav Grepl <mgrepl>
Date:   Tue Jan 20 19:39:20 2015 +0100

    Add devicekit_read_log_files().

commit 8c6ea34309db51e45bfe9da3854fb05c1e9e82d5
Author: Miroslav Grepl <mgrepl>
Date:   Tue Jan 20 19:35:37 2015 +0100

    Allow  virt_qemu_ga to dbus chat with rpm.

Comment 13 errata-xmlrpc 2015-03-05 10:46:56 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, 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://rhn.redhat.com/errata/RHBA-2015-0458.html


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