Bug 1474775 - SELinux is preventing snapd from 'getattr' accesses on the lnk_file /var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2.
Summary: SELinux is preventing snapd from 'getattr' accesses on the lnk_file /var/lib/...
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 26
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: abrt_hash:367a00c57b1a51e84e07b9ea19b...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-25 11:41 UTC by Joshua Rich
Modified: 2023-12-07 17:20 UTC (History)
11 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2018-05-29 11:40:40 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Joshua Rich 2017-07-25 11:41:44 UTC
Description of problem:
Noticed this SELinux Alert in retrospect.  Had installed snapd to be able to install a snap.
SELinux is preventing snapd from 'getattr' accesses on the lnk_file /var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2.

*****  Plugin restorecon (99.5 confidence) suggests   ************************

If you want to fix the label. 
/var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2 default label should be snappy_var_lib_t.
Then you can run restorecon. The access attempt may have been stopped due to insufficient permissions to access a parent directory in which case try to change the following command accordingly.
Do
# /sbin/restorecon -v /var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2

*****  Plugin catchall (1.49 confidence) suggests   **************************

If you believe that snapd should be allowed getattr access on the ld-linux-x86-64.so.2 lnk_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 'snapd' --raw | audit2allow -M my-snapd
# semodule -X 300 -i my-snapd.pp

Additional Information:
Source Context                system_u:system_r:snappy_t:s0
Target Context                system_u:object_r:unlabeled_t:s0
Target Objects                /var/lib/snapd/snap/core/2381/lib64/ld-
                              linux-x86-64.so.2 [ lnk_file ]
Source                        snapd
Source Path                   snapd
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-260.1.fc26.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 4.11.11-300.fc26.x86_64 #1 SMP Mon
                              Jul 17 16:32:11 UTC 2017 x86_64 x86_64
Alert Count                   2
First Seen                    2017-07-25 09:27:41 AEST
Last Seen                     2017-07-25 19:27:33 AEST
Local ID                      f4e82629-d93c-4f70-9d23-edcff05b4bb9

Raw Audit Messages
type=AVC msg=audit(1500974853.93:1120): avc:  denied  { getattr } for  pid=23528 comm="snapd" path="/var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2" dev="loop0" ino=2569 scontext=system_u:system_r:snappy_t:s0 tcontext=system_u:object_r:unlabeled_t:s0 tclass=lnk_file permissive=1


Hash: snapd,snappy_t,unlabeled_t,lnk_file,getattr

Version-Release number of selected component:
selinux-policy-3.13.1-260.1.fc26.noarch

Additional info:
component:      selinux-policy
reporter:       libreport-2.9.1
hashmarkername: setroubleshoot
kernel:         4.11.11-300.fc26.x86_64
type:           libreport

Comment 1 Daniel Walsh 2017-07-25 12:56:12 UTC
Alert tells you what to do.


*****  Plugin restorecon (99.5 confidence) suggests   ************************

If you want to fix the label. 
/var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2 default label should be snappy_var_lib_t.
Then you can run restorecon. The access attempt may have been stopped due to insufficient permissions to access a parent directory in which case try to change the following command accordingly.
Do
# /sbin/restorecon -v /var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2





restorecon -R -v /var/lib

is probably not a bad idea.

Comment 2 Joshua Rich 2017-07-25 13:45:47 UTC
The alerts' suggestion doesn't seem to work here because that file is actually in a squashfs volume.  Should the warning be changed or should a different suggestion be presented? 

$ sudo /sbin/restorecon -v /var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2                                                                                   /sbin/restorecon: Could not set context for /var/lib/snapd/snap/core/2381/lib64/ld-linux-x86-64.so.2:  Read-only file system


$ mount | grep snapd                                                                                                                                                               /var/lib/snapd/snaps/core_2381.snap on /var/lib/snapd/snap/core/2381 type squashfs (ro,nodev,relatime,seclabel)
tmpfs on /run/snapd/ns type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
nsfs on /run/snapd/ns/core.mnt type nsfs (rw,seclabel)
/var/lib/snapd/snaps/micro_1.snap on /var/lib/snapd/snap/micro/1 type squashfs (ro,nodev,relatime,seclabel)
nsfs on /run/snapd/ns/micro.mnt type nsfs (rw,seclabel)

Comment 3 Daniel Walsh 2017-07-25 14:23:20 UTC
This file system does not have labels on it. if you could mount the file system with a context omunt we could probably fix the AVC.

Something like

-o context="system_u:object_r:usr_t:s0"  

ALthough if this is a standard diretory for snappy to install then it should have a label on it like snapd_var_lib_t.  Which is a bug in SELinux policy.

Comment 4 Joshua Rich 2017-07-26 07:49:54 UTC
I assume this is a standard directory. I installed snapd with:

sudo dnf install snapd

Then attempted to install the following snap with:

sudo snap install micro --beta

I then tried another snap:

sudo snap install vlc

This gets me a different alert:

SELinux is preventing systemctl from create access on the lnk_file var-lib-snapd-snap-vlc-4.mount.

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

If you believe that systemctl should be allowed create access on the var-lib-snapd-snap-vlc-4.mount lnk_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 'systemctl' --raw | audit2allow -M my-systemctl
# semodule -X 300 -i my-systemctl.pp

Additional Information:
Source Context                system_u:system_r:snappy_t:s0
Target Context                system_u:object_r:systemd_unit_file_t:s0
Target Objects                var-lib-snapd-snap-vlc-4.mount [ lnk_file ]
Source                        systemctl
Source Path                   systemctl
Port                          <Unknown>
Host                          agalloch
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-260.1.fc26.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     agalloch
Platform                      Linux agalloch 4.11.11-300.fc26.x86_64 #1 SMP Mon
                              Jul 17 16:32:11 UTC 2017 x86_64 x86_64
Alert Count                   1
First Seen                    2017-07-26 17:46:41 AEST
Last Seen                     2017-07-26 17:46:41 AEST
Local ID                      57b937c7-7942-44c4-9f53-2f60b72151ed

Raw Audit Messages
type=AVC msg=audit(1501055201.930:1312): avc:  denied  { create } for  pid=20001 comm="systemctl" name="var-lib-snapd-snap-vlc-4.mount" scontext=system_u:system_r:snappy_t:s0 tcontext=system_u:object_r:systemd_unit_file_t:s0 tclass=lnk_file permissive=1


Hash: systemctl,snappy_t,systemd_unit_file_t,lnk_file,create

Comment 5 Fedora End Of Life 2018-05-03 07:54:15 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 6 Fedora End Of Life 2018-05-29 11:40:40 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 7 Jakub T. Jankiewicz 2023-12-07 17:20:31 UTC
I have the same error in Fedora 39. This never got fixed.


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