Bug 1142454

Summary: sanlock not allowed to send SIGTERM or SIGKILL signals
Product: Red Hat Enterprise Linux 7 Reporter: David Teigland <teigland>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: high Docs Contact:
Priority: high    
Version: 7.0CC: amureini, bmcclain, danken, mgrepl, mmalik, nsoffer, rmm, scohen, snagar, teigland, tlavigne
Target Milestone: rcKeywords: ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-5.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1152594 1172147 (view as bug list) Environment:
Last Closed: 2015-03-05 10:40:52 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:
Bug Depends On:    
Bug Blocks: 1141658, 1151835, 1152594, 1172147    
Attachments:
Description Flags
audit.log
none
audit log from another machine
none
audit log from fedora 19
none
audit log from fedora 19
none
audit log from fedora 20
none
Output of ps -efZ on all ovirt/rhev supported platforms
none
Output of ps -efZ on all ovirt/rhev supported platforms none

Description David Teigland 2014-09-16 19:35:55 UTC
Created attachment 938211 [details]
audit.log

Description of problem:

While investigating bug 1141658, we discovered a lot of complaining about sanlock in audit.log.  The problem in that bug is that SIGTERM sent from sanlock to vdsm is not being seen by vdsm.

Full audit.log attached, but a sample:

type=AVC msg=audit(1410877425.387:3337): avc:  denied  { read } for  pid=1504 comm="sanlock" name="253:18" dev="sysfs" ino=19700 scontext=system_u:system_r:sanlock_t:s0-s0:c0.c1023 tcontext=system_u:object_r:sysfs_t:s0 tclass=lnk_file
type=SYSCALL msg=audit(1410877425.387:3337): arch=c000003e syscall=2 success=no exit=-13 a0=7f3a9c814940 a1=80000 a2=16 a3=0 items=0 ppid=1 pid=1504 auid=4294967295 uid=179 gid=179 euid=179 suid=179 fsuid=179 egid=179 sgid=179 fsgid=179 tty=(none) ses=4294967295 comm="sanlock" exe="/usr/sbin/sanlock" subj=system_u:system_r:sanlock_t:s0-s0:c0.c1023 key=(null)


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Nir Soffer 2014-09-16 21:11:00 UTC
Created attachment 938243 [details]
audit log from another machine

From the log it looks like sanlock-helper is not allowed to send SIGTERM and SIGKILL to vdsm.

The number of the attempts match sanlock logic and what I could see in sanlock.log while reproducing this issue.

Comment 3 Nir Soffer 2014-09-17 22:40:00 UTC
I reproduce the same issue on Fedora 19.

1. 40 retries to send SIGTERM:

type=AVC msg=audit(1410992928.276:1447): avc:  denied  { signal } for  pid=3878 comm="sanlock-helper" scontext=system_u:system_r:sanlock_t:s0-s0:c0.c1023 tcontext=system_u:system_r:initrc_t:s0 tclass=process
type=SYSCALL msg=audit(1410992928.276:1447): arch=c000003e syscall=62 success=no exit=-13 a0=f7e a1=f a2=200 a3=4 items=0 ppid=3877 pid=3878 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="sanlock-helper" exe="/usr/sbin/sanlock" subj=system_u:system_r:sanlock_t:s0-s0:c0.c1023 key=(null)

2. Couple of retries to send SIGKILL

type=AVC msg=audit(1410992976.124:1495): avc:  denied  { sigkill } for  pid=3878 comm="sanlock-helper" scontext=system_u:system_r:sanlock_t:s0-s0:c0.c1023 tcontext=system_u:system_r:initrc_t:s0 tclass=process
type=SYSCALL msg=audit(1410992976.124:1495): arch=c000003e syscall=62 success=no exit=-13 a0=f7e a1=9 a2=200 a3=4 items=0 ppid=3877 pid=3878 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="sanlock-helper" exe="/usr/sbin/sanlock" subj=system_u:system_r:sanlock_t:s0-s0:c0.c1023 key=(null)

On Fedora 20, we the behavior is little better:

1. 40 retries to send SIGTERM

type=AVC msg=audit(1410991380.283:100996): avc:  denied  { signal } for  pid=678 comm="sanlock-helper" scontext=system_u:system_r:sanlock_t:s0-s0:c0.c1023 tcontext=system_u:system_r:virtd_t:s0-s0:c0.c1023 tclass=process permissive=0
type=SYSCALL msg=audit(1410991380.283:100996): arch=c000003e syscall=62 success=no exit=-13 a0=79a a1=f a2=200 a3=6 items=0 ppid=677 pid=678 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="sanlock-helper" exe="/usr/sbin/sanlock" subj=system_u:system_r:sanlock_t:s0-s0:c0.c1023 key=(null)

2. The first attempt to send SIGKILL succeeds, and the host
   is not rebooted.

Comment 4 Nir Soffer 2014-09-17 22:45:30 UTC
Created attachment 938662 [details]
audit log from fedora 19

Comment 5 Nir Soffer 2014-09-17 22:47:43 UTC
Created attachment 938663 [details]
audit log from fedora 19

Comment 6 Nir Soffer 2014-09-17 22:48:17 UTC
Created attachment 938670 [details]
audit log from fedora 20

Comment 8 Miroslav Grepl 2014-09-29 12:46:27 UTC
What does

# ps -efZ |grep initrc_t

Comment 9 David Teigland 2014-09-29 21:10:13 UTC
I suspect that would need that to be run on a RHEV host.  Nir?

Comment 10 Nir Soffer 2014-10-05 21:43:07 UTC
Created attachment 944107 [details]
Output of ps -efZ on all ovirt/rhev supported platforms

Comment 11 Nir Soffer 2014-10-05 21:44:07 UTC
(In reply to Miroslav Grepl from comment #8)
> What does
> # ps -efZ |grep initrc_t
See attachment 944107 [details]

Comment 12 Nir Soffer 2014-10-05 21:47:08 UTC
Created attachment 944108 [details]
Output of ps -efZ on all ovirt/rhev supported platforms

This version fix wrong rhel6.5 data that sneaked into the rehl7 data.

Comment 13 Miroslav Grepl 2014-10-10 08:57:18 UTC
# rpm -q selinux-policy

I believe we have fixes in the latest policy builds.

Comment 15 Miroslav Grepl 2014-10-10 09:44:37 UTC
commit 2c027d0b63c43d328a75ea7cdb5d711f45b1280d
Author: Miroslav Grepl <mgrepl>
Date:   Fri Oct 10 11:43:42 2014 +0200

    ALlow sanlock to send a signal to virtd_t.

Comment 16 Nir Soffer 2014-10-12 14:03:59 UTC
(In reply to Miroslav Grepl from comment #15)
> commit 2c027d0b63c43d328a75ea7cdb5d711f45b1280d
> Author: Miroslav Grepl <mgrepl>
> Date:   Fri Oct 10 11:43:42 2014 +0200
> 
>     ALlow sanlock to send a signal to virtd_t.

Miroslav, according to attachment 944107 [details] vdsm does not run as 
virtd_t on rhel7.

RHEL 6.5:
# ps -efZ | grep vdsm
system_u:system_r:virtd_t:s0-s0:c0.c1023 vdsm 3007 3005  4 Oct05 ?     00:05:02 /usr/bin/python /usr/share/vdsm/vdsm --pidfile /var/run/vdsm/vdsmd.pid

RHEL 7:
# ps -efZ | grep vdsm
system_u:system_r:init_t:s0     vdsm      7790     1  4 Oct05 ?        00:03:25 /usr/bin/python /usr/share/vdsm/vdsm

Fedora 19:
# ps -efZ | grep vdsm
system_u:system_r:initrc_t:s0   vdsm      1732     1  3 Sep30 ?        04:48:56 /usr/bin/python /usr/share/vdsm/vdsm

Fedora 20:
# ps -efZ | grep vdsm
system_u:system_r:virtd_t:s0-s0:c0.c1023 vdsm 1851 1  3 00:31 ?        00:00:17 /usr/bin/python /usr/share/vdsm/vdsm

So it seems that the issue is not only sanlock issue but also
different selinux policy for vdsm on different platforms.

Do you know why vdsm is running as "virtd_t", "init_t", and "initrc_t"?
Shouldn't it be the same label under all platforms?

Comment 17 Nir Soffer 2014-10-12 14:06:42 UTC
Correction: I meant attachment 944108 [details] (replaced attachment 944107 [details]).

Comment 18 Milos Malik 2014-10-13 07:43:35 UTC
(In reply to Nir Soffer from comment #16)
> 
> Do you know why vdsm is running as "virtd_t", "init_t", and "initrc_t"?
> Shouldn't it be the same label under all platforms?

The vdsm and supervdsmServer processes in RHEL-6.6 are already confined:
 * see BZ#1064270 - vdsm and supervdsmServer run as initrc_t.

The vdsm and supervdsmServer processes in RHEL-7.1 will be confined soon:
 * see BZ#1064277 - vdsm and supervdsmServer run as init_t.

I'm not sure if the new policies for vdsm and supervdsmServer will be ported to Fedora 19 and Fedora 20.

AFAIK all processes that are not confined run as initrc_t on RHEL-6 because they were started by a process running as initrc_t (upstart). All processes that are not confined run as init_t on RHEL-7 because they were started by a process running as init_t (systemd).

Comment 19 Miroslav Grepl 2014-10-13 07:52:40 UTC
We have unconfined_services_t pro rawhide/F21/RHEL7.1. 

Also vdsm and supervdsmServer processes in RHEL-7.1 are already confined. PLease just use the latest RHEL7.1 builds.

Nir,
any chance to re-test it?

Comment 20 Nir Soffer 2014-10-13 08:07:55 UTC
(In reply to Miroslav Grepl from comment #19)
> We have unconfined_services_t pro rawhide/F21/RHEL7.1.

I don't follow - can you explain?
 
> Also vdsm and supervdsmServer processes in RHEL-7.1 are already confined.
> PLease just use the latest RHEL7.1 builds.
> any chance to re-test it?

Can you point us to the build that works with this RHEL 7.0.z?

Comment 21 Nir Soffer 2014-10-13 13:06:05 UTC
What would be the best way to ensure that we get this fix also on Fedora? Should we clone this bug to Fedora?

Comment 22 Miroslav Grepl 2014-10-13 14:30:24 UTC
I added all fixes to Fedora.

Comment 29 errata-xmlrpc 2015-03-05 10:40:52 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

Comment 30 Red Hat Bugzilla 2023-09-14 02:47:40 UTC
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days