Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1347659

Summary: [Hyper-v][RHEL7.3] Selinux AVC: avc: denied { read write } for pid=2668 comm="ip" path="/dev/vmbus/hv_kvp" in audit log.
Product: Red Hat Enterprise Linux 7 Reporter: xuli <xuli>
Component: hyperv-daemonsAssignee: Vitaly Kuznetsov <vkuznets>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.3CC: ailan, boyang, hhei, jingli, ldu, leiwang, lvrabec, mgrepl, mmalik, plautrba, pvrabec, ssekidde, v-chvale, vkuznets, xiaofwan, xuli, yacao
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: hyperv-daemons-0-0.28.20160216git.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 03:51:32 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:
Embargoed:

Description xuli 2016-06-17 11:03:35 UTC
Description of problem:

Power off VM and disable "Data Exchange", then power on VM and enable "Data Exchange", there is avc: denied log comm="ip" path="/dev/vmbus/hv_kvp" in the audit log. Sometimes also do kvp-ip-injection related operation can trigger error log.

Version-Release number of selected component (if applicable):
Kernel: 3.10.0-435.e17.x86_64
Host: Windows 2012R2

How reproducible: 30%

Steps to Reproduce:
        
1. Update the selinux, hyperv-daemons, kernel as below version.

a. selinux-policy-3.13.1-80.el7
b. hyperv-daemons-0-0.27.20160216git.el7.x86_64
c. kernel version 3.10.0-438.e17.x86_64

2. Power off VM, go to Hyper-V manager -> Integration Services -> Disable "Data Exchange".
3. Start VM, and check selinux mode is Enforcing.
4. Check the log by # ausearch -m avc
<no matches>, no any  avc:  denied information, which is expected result.
5. Go to Hyper-V manager -> Integration Services -> Enable "Data Exchange", make sure hypervkvpd are running.
6. check the log # ausearch -m avc.
7. run kvp-ip-injection
8. check the log # ausearch -m avc.

Actual results:
Observe that selinux "AVC msg=audit(1466147600.222:426): avc:  denied  { read write } for  pid=2668 comm="ip" path="/dev/vmbus/hv_kvp" shows.
Expected results:
No avc: denied log for "/dev/vmbus/hv_kvp".


Log information

type=SYSCALL msg=audit(1466147600.222:426): arch=c000003e syscall=59 success=yes exit=0 a0=72f010 a1=72f6a0 a2=72dc20 a3=7ffc46950260 items=0 ppid=2667 pid=2668 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="ip" exe="/usr/sbin/ip" subj=system_u:system_r:ifconfig_t:s0 key=(null)
type=AVC msg=audit(1466147600.222:426): avc:  denied  { read write } for  pid=2668 comm="ip" path="/dev/vmbus/hv_kvp" dev="devtmpfs" ino=17561 scontext=system_u:system_r:ifconfig_t:s0 tcontext=system_u:object_r:hypervkvp_device_t:s0 tclass=chr_file

Comment 2 Miroslav Grepl 2016-06-22 08:53:02 UTC
Does hypervkvp close FDs on EXEC?

Comment 3 Vitaly Kuznetsov 2016-06-22 09:38:17 UTC
Nice guess, it does not. Thanks!

I'll send a patch to fix the issue.

Comment 6 Vitaly Kuznetsov 2016-06-23 09:16:10 UTC
(In reply to xuli from comment #5)
> Hi Vitaly,
> 
> Have tested the above brew build with
> hyperv-daemons-0-0.28.20160216git.el7.x86_64, test steps are same with bug
> described, the error log changes to  new eror: 
> avc:  denied  { getattr } for  pid=2627 comm="restorecon" name="/"
> dev="sysfs", could you please check it?
> 
> 
> Detailed Log:
> 
> time->Thu Jun 23 11:46:54 2016
> type=SYSCALL msg=audit(1466653614.813:356): arch=c000003e syscall=137
> success=no exit=-13 a0=7fc1dcc03296 a1=7ffd08f031a0 a2=7fc1dcc03296
> a3=75736f6e2c6c6562 items=0 ppid=2522 pid=2627 auid=4294967295 uid=0 gid=0
> euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295
> comm="restorecon" exe="/usr/sbin/setfiles"
> subj=system_u:system_r:hypervkvp_t:s0 key=(null)
> type=AVC msg=audit(1466653614.813:356): avc:  denied  { getattr } for 
> pid=2627 comm="restorecon" name="/" dev="sysfs" ino=1
> scontext=system_u:system_r:hypervkvp_t:s0
> tcontext=system_u:object_r:sysfs_t:s0 tclass=filesystem
> ----

....

I'm able to reproduce that but it is a different issue. 

hypervkvpd runs /sbin/ifup ethX and through /etc/sysconfig/network-scripts/network-functions it end up calling 

/sbin/restorecon /etc/resolv.conf >/dev/null 2>&1

for some (unknown to me) reason restorecon tries to get attributes for all members of '/' and fails. It should probably be allowed to or it should not do that. Please open a new bug against selinux-policy, guys may reassign it to policycoreutils if they feel like restorecon (setfiles) should be fixed instead.

Comment 7 xuli 2016-06-23 10:09:19 UTC
Thank you Vitaly, have filed new bug https://bugzilla.redhat.com/show_bug.cgi?id=1349356

Comment 9 xuli 2016-07-15 07:22:14 UTC
Verify Pass on latest build.
Host: Windows server 2016 TP5
Guest:RHEL7.3 Gen1 (3.10.0-469.el7.x86_64) 
hyperv-daemons-0-0.28.20160216git.el7.x86_64

Verify steps are same with bug described, and do not have log "comm="ip" path="/dev/vmbus/hv_kvp", for different ausearch log after ip-injection, which is tracked by https://bugzilla.redhat.com/show_bug.cgi?id=1349356, so close this bug.

Comment 11 errata-xmlrpc 2016-11-04 03:51:32 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-2016-2330.html