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 1622284

Summary: policy blocks smartd access to nvme device
Product: Red Hat Enterprise Linux 7 Reporter: Patrick C. F. Ernzer <pcfe>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED WONTFIX QA Contact: Milos Malik <mmalik>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.5CC: lvrabec, mgrepl, mmalik, orion, peljasz, plautrba, rmetrich, ssekidde, vmojzis, zpytela
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-03-14 10:25:16 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: 1653106    

Description Patrick C. F. Ernzer 2018-08-25 11:41:40 UTC
Description of problem:
when using smartd against an NVMe device, there's
avc denied

Version-Release number of selected component (if applicable):
selinux-policy-targeted-3.13.1-192.el7_5.6.noarch

How reproducible:
always

Steps to Reproduce:
1. configure smartd to use /dev/nvme0n1
2. start smartd

Actual results:
Aug 25 10:42:42 epyc.internal.pcfe.net smartd[126969]: smartd 6.5 2016-05-07 r4318 [x86_64-linux-3.10.0-862.11.6.el7.x86_64] (local build)
Aug 25 10:42:42 epyc.internal.pcfe.net smartd[126969]: Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
Aug 25 10:42:42 epyc.internal.pcfe.net smartd[126969]: Opened configuration file /etc/smartmontools/smartd.conf
Aug 25 10:42:42 epyc.internal.pcfe.net smartd[126969]: Configuration file /etc/smartmontools/smartd.conf parsed.
Aug 25 10:42:42 epyc.internal.pcfe.net smartd[126969]: Device: /dev/nvme0, open() failed: Permission denied


Expected results:
smartd is allowed nvme_device_t

Additional info:
Currently testing if the following works.
I'l know in a couple days, when smartd attempted to run both a short and a long test

# cat smartd-nvme-access.te 

module smartd-nvme-access 1.2;

require {
        type fsdaemon_t;
        type nvme_device_t;
        class blk_file { getattr read open ioctl };
}

#============= fsdaemon_t ==============
allow fsdaemon_t nvme_device_t:blk_file { getattr read open ioctl };

Comment 2 Patrick C. F. Ernzer 2018-08-25 11:43:52 UTC
/dev/nvme0 has been adjusted to /dev/nvme0n1
sorry for posting an old log extract, here's a more recent oneAug 25 13:24:19 epyc.internal.pcfe.net smartd[38099]: smartd 6.5 2016-05-07 r4318 [x86_64-linux-3.10.0-862.11.6.el7.x86_64] (local build)
Aug 25 13:24:19 epyc.internal.pcfe.net smartd[38099]: Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
Aug 25 13:24:19 epyc.internal.pcfe.net smartd[38099]: Opened configuration file /etc/smartmontools/smartd.conf
Aug 25 13:24:19 epyc.internal.pcfe.net smartd[38099]: Configuration file /etc/smartmontools/smartd.conf parsed.
Aug 25 13:24:19 epyc.internal.pcfe.net smartd[38099]: Device: /dev/nvme0n1, open() failed: Permission denied

Comment 3 Zdenek Pytela 2019-03-14 10:25:16 UTC
This issue was not selected to be included in Red Hat Enterprise Linux 7.7 because it is seen either as low or moderate impact to a small number of use-cases. The next release will be in Maintenance Support 1 Phase, which means that qualified Critical and Important Security errata advisories (RHSAs) and Urgent Priority Bug Fix errata advisories (RHBAs) may be released as they become available.

We will now close this issue, but if you believe that it qualifies for the Maintenance Support 1 Phase, please re-open; otherwise, we recommend moving the request to Red Hat Enterprise Linux 8 if applicable.

Comment 4 lejeczek 2019-10-03 08:23:42 UTC
An absolute bol... well, really??? More & more boxes get NVMes every day. I really have no doubts that lots of users would love that to be in booleans. And before everybody jumped the rhel8 ship, well, it's going to be a while.
Regards, L.

Comment 5 Milos Malik 2019-10-03 11:50:21 UTC
Enforcing mode:
----
type=PROCTITLE msg=audit(10/03/2019 07:42:22.547:154) : proctitle=/usr/sbin/smartd -n -q never 
type=SYSCALL msg=audit(10/03/2019 07:42:22.547:154) : arch=x86_64 syscall=lstat success=no exit=EACCES(Permission denied) a0=0x55ef652d7348 a1=0x7fffd6722cb0 a2=0x7fffd6722cb0 a3=0x7fffd6723990 items=0 ppid=1 pid=15418 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=smartd exe=/usr/sbin/smartd subj=system_u:system_r:fsdaemon_t:s0 key=(null) 
type=AVC msg=audit(10/03/2019 07:42:22.547:154) : avc:  denied  { getattr } for  pid=15418 comm=smartd path=/dev/nvme0 dev="devtmpfs" ino=22684 scontext=system_u:system_r:fsdaemon_t:s0 tcontext=system_u:object_r:nvme_device_t:s0 tclass=chr_file permissive=0 
----
type=PROCTITLE msg=audit(10/03/2019 07:42:22.547:155) : proctitle=/usr/sbin/smartd -n -q never 
type=SYSCALL msg=audit(10/03/2019 07:42:22.547:155) : arch=x86_64 syscall=open success=no exit=EACCES(Permission denied) a0=0x55ef652c8e28 a1=O_RDONLY|O_NONBLOCK a2=0x0 a3=0x55ef6479cdf0 items=0 ppid=1 pid=15418 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=smartd exe=/usr/sbin/smartd subj=system_u:system_r:fsdaemon_t:s0 key=(null) 
type=AVC msg=audit(10/03/2019 07:42:22.547:155) : avc:  denied  { read } for  pid=15418 comm=smartd name=nvme0 dev="devtmpfs" ino=22684 scontext=system_u:system_r:fsdaemon_t:s0 tcontext=system_u:object_r:nvme_device_t:s0 tclass=chr_file permissive=0 
----

Permissive mode:
----
type=PROCTITLE msg=audit(10/03/2019 07:43:55.415:160) : proctitle=/usr/sbin/smartd -n -q never 
type=SYSCALL msg=audit(10/03/2019 07:43:55.415:160) : arch=x86_64 syscall=lstat success=yes exit=0 a0=0x55ad5c12a348 a1=0x7ffc12b75b50 a2=0x7ffc12b75b50 a3=0x7ffc12b76830 items=0 ppid=1 pid=15521 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=smartd exe=/usr/sbin/smartd subj=system_u:system_r:fsdaemon_t:s0 key=(null) 
type=AVC msg=audit(10/03/2019 07:43:55.415:160) : avc:  denied  { getattr } for  pid=15521 comm=smartd path=/dev/nvme0 dev="devtmpfs" ino=22684 scontext=system_u:system_r:fsdaemon_t:s0 tcontext=system_u:object_r:nvme_device_t:s0 tclass=chr_file permissive=1 
----
type=PROCTITLE msg=audit(10/03/2019 07:43:55.415:161) : proctitle=/usr/sbin/smartd -n -q never 
type=SYSCALL msg=audit(10/03/2019 07:43:55.415:161) : arch=x86_64 syscall=open success=yes exit=3 a0=0x55ad5c11be28 a1=O_RDONLY|O_NONBLOCK a2=0x0 a3=0x55ad5bb87df0 items=0 ppid=1 pid=15521 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=smartd exe=/usr/sbin/smartd subj=system_u:system_r:fsdaemon_t:s0 key=(null) 
type=AVC msg=audit(10/03/2019 07:43:55.415:161) : avc:  denied  { open } for  pid=15521 comm=smartd path=/dev/nvme0 dev="devtmpfs" ino=22684 scontext=system_u:system_r:fsdaemon_t:s0 tcontext=system_u:object_r:nvme_device_t:s0 tclass=chr_file permissive=1 
type=AVC msg=audit(10/03/2019 07:43:55.415:161) : avc:  denied  { read } for  pid=15521 comm=smartd name=nvme0 dev="devtmpfs" ino=22684 scontext=system_u:system_r:fsdaemon_t:s0 tcontext=system_u:object_r:nvme_device_t:s0 tclass=chr_file permissive=1 
----
type=PROCTITLE msg=audit(10/03/2019 07:43:55.415:162) : proctitle=/usr/sbin/smartd -n -q never 
type=SYSCALL msg=audit(10/03/2019 07:43:55.415:162) : arch=x86_64 syscall=ioctl success=no exit=ENOTTY(Inappropriate ioctl for device) a0=0x3 a1=0x4e40 a2=0x0 a3=0x55ad5bb87df0 items=0 ppid=1 pid=15521 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=smartd exe=/usr/sbin/smartd subj=system_u:system_r:fsdaemon_t:s0 key=(null) 
type=AVC msg=audit(10/03/2019 07:43:55.415:162) : avc:  denied  { ioctl } for  pid=15521 comm=smartd path=/dev/nvme0 dev="devtmpfs" ino=22684 ioctlcmd=0x4e40 scontext=system_u:system_r:fsdaemon_t:s0 tcontext=system_u:object_r:nvme_device_t:s0 tclass=chr_file permissive=1 
----

Comment 6 Orion Poplawski 2020-06-24 23:10:38 UTC
# cat smartd_nvme.te

module smartd_nvme 1.0;

require {
        type fsdaemon_t;
        type nvme_device_t;
        class blk_file read;
        class chr_file { ioctl open read };
}

#============= fsdaemon_t ==============
allow fsdaemon_t nvme_device_t:blk_file read;
allow fsdaemon_t nvme_device_t:chr_file { ioctl open read };