Bug 2330722

Summary: SELinux is preventing /usr/lib/systemd/system-generators/systemd-cryptsetup-generator from 'getattr' accesses on the nsfs_t file.
Product: [Fedora] Fedora Reporter: Steve <y9t7sypezp>
Component: selinux-policyAssignee: Zdenek Pytela <zpytela>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dwalsh, lvrabec, mmalik, omosnacek, pkoncity, ppisar, vmojzis, y9t7sypezp, zpytela
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: abrt_hash:739f5ce3b2f5d8680ed1a72f1296895fc52af270e67544ef145b1d6c833953a3;VARIANT_ID=workstation;
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-12-11 08:38:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
File: description
none
File: os_info
none
$ sudo ausearch -i -ts boot -m avc
none
$ sudo ausearch -i -m avc # collect all the AVCs none

Description Steve 2024-12-06 05:53:08 UTC
Description of problem:
Numerous AVCs after a fresh install of F42 Workstation in a VM with Fedora-Everything-netinst-x86_64-Rawhide-20241205.n.1.iso.

--
SELinux is preventing /usr/lib/systemd/system-generators/systemd-cryptsetup-generator from 'getattr' accesses on the file file.

*****  Plugin catchall (100. confidence) suggests   **************************

If you believe that systemd-cryptsetup-generator should be allowed getattr access on the file file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'systemd-cryptse' --raw | audit2allow -M my-systemdcryptse
# semodule -X 300 -i my-systemdcryptse.pp

Additional Information:
Source Context                system_u:system_r:systemd_cryptsetup_generator_t:s
                              0
Target Context                system_u:object_r:nsfs_t:s0
Target Objects                file [ file ]
Source                        systemd-cryptse
Source Path                   /usr/lib/systemd/system-generators/systemd-
                              cryptsetup-generator
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           systemd-udev-257~rc3-1.fc42.x86_64
Target RPM Packages           
SELinux Policy RPM            selinux-policy-targeted-41.26-2.fc42.noarch
Local Policy RPM              selinux-policy-targeted-41.26-2.fc42.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 6.13.0-
                              0.rc1.20241204gitfeffde684ac2.17.fc42.x86_64 #1
                              SMP PREEMPT_DYNAMIC Wed Dec 4 20:26:04 UTC 2024
                              x86_64
Alert Count                   2
First Seen                    2024-12-06 05:08:16 GMT
Last Seen                     2024-12-06 05:08:16 GMT
Local ID                      2626ada8-5b9d-4fba-bd08-85321630b997

Raw Audit Messages
type=AVC msg=audit(1733461696.759:606): avc:  denied  { getattr } for  pid=6107 comm="systemd-cryptse" path="pid:[4026531836]" dev="nsfs" ino=4026531836 scontext=system_u:system_r:systemd_cryptsetup_generator_t:s0 tcontext=system_u:object_r:nsfs_t:s0 tclass=file permissive=0


type=SYSCALL msg=audit(1733461696.759:606): arch=x86_64 syscall=newfstatat success=no exit=EACCES a0=ffffff9c a1=7ffe6f007210 a2=7ffe6f007230 a3=0 items=0 ppid=6091 pid=6107 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm=systemd-cryptse exe=/usr/lib/systemd/system-generators/systemd-cryptsetup-generator subj=system_u:system_r:systemd_cryptsetup_generator_t:s0 key=(null)

Hash: systemd-cryptse,systemd_cryptsetup_generator_t,nsfs_t,file,getattr

Version-Release number of selected component:
selinux-policy-targeted-41.26-2.fc42.noarch

Additional info:
reporter:       libreport-2.17.15
reason:         SELinux is preventing /usr/lib/systemd/system-generators/systemd-cryptsetup-generator from 'getattr' accesses on the file file.
package:        selinux-policy-targeted-41.26-2.fc42.noarch
component:      selinux-policy
hashmarkername: setroubleshoot
type:           libreport
kernel:         6.13.0-0.rc1.20241204gitfeffde684ac2.17.fc42.x86_64
component:      selinux-policy

Comment 1 Steve 2024-12-06 05:53:10 UTC
Created attachment 2061428 [details]
File: description

Comment 2 Steve 2024-12-06 05:53:11 UTC
Created attachment 2061429 [details]
File: os_info

Comment 3 Steve 2024-12-06 06:02:32 UTC
Created attachment 2061430 [details]
$ sudo ausearch -i -ts boot -m avc

Comment 4 Steve 2024-12-06 10:05:01 UTC
$ audit2allow -i avcs-2024-12-05.txt 


#============= systemd_homed_t ==============
allow systemd_homed_t nsfs_t:file getattr;

#============= systemd_hostnamed_t ==============
allow systemd_hostnamed_t nsfs_t:file getattr;

#============= systemd_localed_t ==============
allow systemd_localed_t nsfs_t:file getattr;

#============= systemd_logind_t ==============
allow systemd_logind_t nsfs_t:file getattr;

#============= systemd_timedated_t ==============
allow systemd_timedated_t nsfs_t:file getattr;

Comment 5 Steve 2024-12-06 10:21:24 UTC
Created attachment 2061462 [details]
$ sudo ausearch -i -m avc # collect all the AVCs

Comment 6 Steve 2024-12-06 10:26:04 UTC
$ audit2allow -i avcs-2024-12-06.txt | fgrep allow
allow init_t locate_exec_t:file execute_no_trans;
allow init_t locate_t:process2 nnp_transition;
allow systemd_bless_boot_generator_t nsfs_t:file getattr;
allow systemd_cryptsetup_generator_t nsfs_t:file getattr;
allow systemd_debug_generator_t nsfs_t:file getattr;
allow systemd_fstab_generator_t nsfs_t:file getattr;
allow systemd_generic_generator_t nsfs_t:file getattr;
allow systemd_getty_generator_t nsfs_t:file getattr;
allow systemd_gpt_generator_t nsfs_t:file getattr;
allow systemd_homed_t nsfs_t:file getattr;
allow systemd_hostnamed_t nsfs_t:file getattr;
allow systemd_localed_t nsfs_t:file getattr;
allow systemd_logind_t nsfs_t:file getattr;
allow systemd_rc_local_generator_t nsfs_t:file getattr;
allow systemd_resolved_t nsfs_t:file getattr;
allow systemd_ssh_generator_t nsfs_t:file getattr;
allow systemd_sysv_generator_t nsfs_t:file getattr;
allow systemd_timedated_t nsfs_t:file getattr;
allow systemd_tpm2_generator_t nsfs_t:file getattr;
allow systemd_zram_generator_t nsfs_t:file getattr;

Comment 7 Petr Pisar 2024-12-10 09:36:56 UTC
I found that nsfs is some kind of pseudofilesystem used for managing name spaces (containers). Is it what nsfs_t stands for?

"rpm --reinstall audit-4.0.2-1.fc41.x86_64.rpm" reproduces the problem.

Comment 8 Steve 2024-12-11 01:55:10 UTC
(In reply to Petr Pisar from comment #7)
> I found that nsfs is some kind of pseudofilesystem used for managing name spaces (containers). Is it what nsfs_t stands for?
> 
> "rpm --reinstall audit-4.0.2-1.fc41.x86_64.rpm" reproduces the problem.

Thanks for suggesting the reproducer.

I am not an selinux maintainer, so I had to do some research, starting with asking an AI chat bot*:

--
Prompt: In selinux, what is the "nsfs_t" type used for?

Response: In SELinux, the "nsfs_t" type is used for the namespace file system. The namespace file system is a virtual file system that provides a way to manage and isolate system resources, such as process IDs, network namespaces, and mount namespaces. 

The "nsfs_t" type is used to label the namespace file system, which is typically mounted at /proc/<pid>/ns or /proc/<pid>/ns/<namespace_type>. This type is used to define the security context for the namespace file system, controlling access to the namespace resources.

In SELinux, the "nsfs_t" type is typically used to restrict access to the namespace resources, such as preventing a process from accessing or modifying the namespace resources of another process.
--

And here are two related man pages:

$ whatis namespaces ioctl_nsfs
namespaces (7)       - overview of Linux namespaces
ioctl_nsfs (2)       - ioctl() operations for Linux namespaces

* In this case, Llama 3.1 70B, seemed to give the best response:
https://duckduckgo.com/?q=DuckDuckGo+AI+Chat&ia=chat&duckai=1

Comment 9 Zdenek Pytela 2024-12-11 08:38:20 UTC

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