Bug 1937664 - avc: denied { ioctl } for pid=4033 comm="smbd" path="/proc/1/environ" dev="proc"
Summary: avc: denied { ioctl } for pid=4033 comm="smbd" path="/proc/1/environ" dev=...
Keywords:
Status: CLOSED DUPLICATE of bug 1932689
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: rawhide
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Zdenek Pytela
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-03-11 09:48 UTC by Bruno Goncalves
Modified: 2021-06-23 08:39 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2021-04-07 07:45:20 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1932689 1 medium CLOSED SELinux is preventing avahi-daemon from 'open' accesses on the file /proc/<pid>/environ. 2022-04-13 20:59:37 UTC

Description Bruno Goncalves 2021-03-11 09:48:28 UTC
Description of problem:
During CIFS Connectathon test on CKI this avc denial happens

----
time->Wed Mar 10 02:20:39 2021
type=PROCTITLE msg=audit(1615360839.723:257): proctitle=2F7573722F7362696E2F736D6264002D2D666F726567726F756E64002D2D6E6F2D70726F636573732D67726F7570
type=SYSCALL msg=audit(1615360839.723:257): arch=c000003e syscall=16 success=no exit=-25 a0=19 a1=5401 a2=7ffcb7b21a70 a3=1000 items=0 ppid=1 pid=4033 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="smbd" exe="/usr/sbin/smbd" subj=system_u:system_r:smbd_t:s0 key=(null)
type=AVC msg=audit(1615360839.723:257): avc:  denied  { ioctl } for  pid=4033 comm="smbd" path="/proc/1/environ" dev="proc" ino=14267 ioctlcmd=0x5401 scontext=system_u:system_r:smbd_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1
----
time->Wed Mar 10 02:21:01 2021
type=PROCTITLE msg=audit(1615360861.439:267): proctitle=2F7573722F7362696E2F736D6264002D2D666F726567726F756E64002D2D6E6F2D70726F636573732D67726F7570
type=SYSCALL msg=audit(1615360861.439:267): arch=c000003e syscall=16 success=no exit=-25 a0=19 a1=5401 a2=7ffdfae331b0 a3=1000 items=0 ppid=1 pid=4208 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="smbd" exe="/usr/sbin/smbd" subj=system_u:system_r:smbd_t:s0 key=(null)
type=AVC msg=audit(1615360861.439:267): avc:  denied  { ioctl } for  pid=4208 comm="smbd" path="/proc/1/environ" dev="proc" ino=14267 ioctlcmd=0x5401 scontext=system_u:system_r:smbd_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1


Version-Release number of selected component (if applicable):
selinux-policy-3.14.8-4.fc35.noarch

How reproducible:
not sure yet

Steps to Reproduce:
1.Clone the test repo
git clone https://gitlab.com/cki-project/kernel-tests.git

2.go the the test directory
cd kernel-tests/filesystems/cifs/connectathon

3. install test dependencies
dnf install -y wget git samba time patch cups samba-client cifs-utils gcc bzip2 nfs-utils net-tools libnsl2 libtirpc-devel python3-lxml rusers

4. Run the test
bash runtest.sh

Additional info:
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      33
selinux-policy-3.14.8-4.fc35.noarch

Comment 1 Bruno Goncalves 2021-03-11 13:25:42 UTC
I was able to reproduce running the test using restraint

1. make sure restraintd service is running in the machine

2. install restraint-client and beakerlib

3. run the test

3.1 test job:

# cat job.xml 
<?xml version="1.0" encoding="utf-8"?>
<job>
  <recipeSet>
    <recipe id="1">
      <task name="CIFS Connectathon" role="STANDALONE">
        <fetch url="https://gitlab.com/cki-project/kernel-tests/-/archive/main/kernel-tests-main.zip#filesystems/cifs/connectathon"/>
      </task>
   </recipe>
 </recipeSet>
</job>

3.2 restraint -j job.xml -t localhost

4. check avc.log
avc.log will be under job.01 directory
find job.01 -iname avc.log

Comment 2 Zdenek Pytela 2021-03-11 15:43:55 UTC
Bruno,

Apart from the denial, is there also some service failing or otherwise negatively affected?
Given the permissive=1 in the auditd, do I suppose correctly there are no more denials?

Comment 3 Bruno Goncalves 2021-03-11 16:05:25 UTC
The test do pass, the failure is only found when searching for avc errors.

here is an example of different test execution https://beaker.engineering.redhat.com/recipes/9695133#task123170056

Comment 4 Zdenek Pytela 2021-03-11 18:22:17 UTC
Bruno,

I gave it a second thought and I think it is rather related to the test or test environment.

Here is the audited event disclosed:

----
type=PROCTITLE msg=audit(03/10/21 08:21:01.439:267) : proctitle=/usr/sbin/smbd --foreground --no-process-group
type=AVC msg=audit(03/10/21 08:21:01.439:267) : avc:  denied  { ioctl } for  pid=4208 comm=smbd path=/proc/1/environ dev="proc" ino=14267 ioctlcmd=TCGETS scontext=system_u:system_r:smbd_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1
type=SYSCALL msg=audit(03/10/21 08:21:01.439:267) : arch=x86_64 syscall=ioctl success=no exit=ENOTTY(Inappropriate ioctl for device) a0=0x19 a1=TCGETS a2=0x7ffdfae331b0 a3=0x1000 items=0 ppid=1 pid=4208 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=smbd exe=/usr/sbin/smbd subj=system_u:system_r:smbd_t:s0 key=(null)

smbd is run in the foreground which I think is not an usual scenario for a daemon.

Comment 5 Bruno Goncalves 2021-03-11 19:21:11 UTC
Isn't this because this is how the service is configured to run?

samba-4.14.0-1.fc35.x86_64


# cat /usr/lib/systemd/system/smb.service
[Unit]
Description=Samba SMB Daemon
Documentation=man:smbd(8) man:samba(7) man:smb.conf(5)
Wants=network-online.target
After=network.target network-online.target nmb.service winbind.service

[Service]
Type=notify
PIDFile=/run/smbd.pid
LimitNOFILE=16384
EnvironmentFile=-/etc/sysconfig/samba
ExecStart=/usr/sbin/smbd --foreground --no-process-group $SMBDOPTIONS
ExecReload=/bin/kill -HUP $MAINPID
LimitCORE=infinity
Environment=KRB5CCNAME=FILE:/run/samba/krb5cc_samba

[Install]
WantedBy=multi-user.target

Comment 10 Zdenek Pytela 2021-04-07 07:45:20 UTC

*** This bug has been marked as a duplicate of bug 1932689 ***


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