Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1945585 - selinux-policy is blocking plymouth from starting /usr/libexec/plymouth/plymouthd-drm-escrow
Summary: selinux-policy is blocking plymouth from starting /usr/libexec/plymouth/plymo...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 34
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-04-01 10:49 UTC by Hans de Goede
Modified: 2021-04-05 00:17 UTC (History)
8 users (show)

Fixed In Version: selinux-policy-34-1.fc34
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-04-05 00:17:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Hans de Goede 2021-04-01 10:49:54 UTC
Recently the shutdown/reboot support in plymouth has been reworked and currently a  plymouth update is pending with these changes:

https://bodhi.fedoraproject.org/updates/FEDORA-2021-cbe477064d

On shutdown plymouthd will now chroot back into the initramfs (when applicable) and when it gets the SIGTERM send near the end of shutdown it will fork + execute a new  /usr/libexec/plymouth/plymouthd-drm-escrow helper binary (from the initrams if the initramfs is used during shutdown) which does nothing except keeping open the fds for /dev/dri/card? which it has inherited from its parent.

Things are done this way to keep the boot-splash up until the end (instead of falling back to the text console), while at the same time not keeping any files busy on the rootfs so that it can be cleanly remounted to ro or be completely unmounted and disassembled in some cases.

This all works as it should, leading to a nice clean shutdown with the boot-splash showing all the way until the end, when selinux is in permissive mode.

However plymouthd fails to start the /usr/libexec/plymouth/plymouthd-drm-escrow helper binary when selinux is in enforcing mode.

Unfortunately at this point during shutdown audit messages are no longer being logged, so I don't have any audit / AVC messages about this for you. But I guess that plymouthd is simply forbidden from execing anything by its current selinux policy and that this is the problem.

Not being able to start the plymouthd-drm-escrow helper leads to the monitor showing the text console with the last couple of shutdown log-messages before the system power-offs or reboots. It would be nice if we can get this fixed before Fedora 34 final.

Comment 1 Zdenek Pytela 2021-04-01 13:38:06 UTC
Hans,

Without the denials it will be quite hard to troubleshoot. I understand auditd is not running, but is journal still accessible? With persistent journal files, the AVC denials should be visible after reboot.

We can try small steps with inserting local policy modules.
Can you explain the new functionality?
- how the plymouthd-drm-escrow is executed, is is a service?
- which files are accessed and which resources are used by plymouthd or a child processes during shutdown that were not used before?

> But I guess that plymouthd is simply forbidden from execing anything by its current selinux policy and that this is the problem.
The same policy applies as during the system lifetime.

> It would be nice if we can get this fixed before Fedora 34 final.
I am afraid this is hardly possible given the deadline next Tuesday.

Comment 2 Hans de Goede 2021-04-01 14:32:35 UTC
(In reply to Zdenek Pytela from comment #1)
> Hans,
> 
> Without the denials it will be quite hard to troubleshoot. I understand
> auditd is not running, but is journal still accessible? With persistent
> journal files, the AVC denials should be visible after reboot.

Yes the journal is still visible, but I could not find anything
in there. I do see these:

Apr 01 11:53:34 x1.localdomain audit[3638]: AVC avc:  denied  { read } for  pid=3638 comm="plymouthd" name="cmdline" dev="proc" ino=43089 scontext=system_u:system_r:plymouthd_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1
Apr 01 11:53:34 x1.localdomain audit[3638]: AVC avc:  denied  { open } for  pid=3638 comm="plymouthd" path="/proc/3640/cmdline" dev="proc" ino=43089 scontext=system_u:system_r:plymouthd_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1
Apr 01 11:53:34 x1.localdomain audit[3638]: AVC avc:  denied  { getattr } for  pid=3638 comm="plymouthd" path="/proc/3640/stat" dev="proc" ino=43090 scontext=system_u:system_r:plymouthd_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1

In the journal which happen shortly before the troublesome exec. Notice that these are still logged by the audit daemon, I think that the audit team turns of direct logging of AVC-s by the kernel when it starts; and maybe it does not re-enable this when it quits?

BTW these are harmless, they are plymouthd reading the cmdline from a request coming from the "plymouth" client which controls it to log some debug info. Things work fine without these. Regardless this is a different issue. I guess I should also file a separate bug for this, because in the end we don't want to have any denials in the journal / audit logs.

> We can try small steps with inserting local policy modules.

That sounds like a good idea, thank you for your help with this.

> Can you explain the new functionality?
> - how the plymouthd-drm-escrow is executed, is is a service?
> - which files are accessed and which resources are used by plymouthd or a
> child processes during shutdown that were not used before?

The new functionality is this:

pid = fork ();
if (pid == 0) {
  const char *argv[] = { "/usr/libexec/plymouthd-drm-escrow", NULL };
  execve (argv[0], (char * const *) argv, NULL);
}

Where /usr/libexec/plymouthd-drm-escrow is:

int
main(int argc, char **argv)
{
        signal (SIGTERM, SIG_IGN);

        /* Make the first byte in argv be '@' so that we can survive systemd's killing
         * spree until the power is killed at shutdown.
         * http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
         */
        argv[0][0] = '@';

        while (pause());

        return 0;
}

plymouthd does already use fork, so AFAICT the only new permission which it needs is executing "/usr/libexec/plymouthd-drm-escrow" and "/usr/libexec/plymouthd-drm-escrow" can stay in the same process-context and it does not need any special rights.

> > It would be nice if we can get this fixed before Fedora 34 final.
> I am afraid this is hardly possible given the deadline next Tuesday.

Sorry I was not clear, what I meant was that it would be nice if we can get this fixed with a 0-day update. I understand that we are way too close to the freeze to get a fix included in final.

Comment 3 Zdenek Pytela 2021-04-01 14:53:04 UTC
(In reply to Hans de Goede from comment #2)
> (In reply to Zdenek Pytela from comment #1)
> > Hans,
> > 
> > Without the denials it will be quite hard to troubleshoot. I understand
> > auditd is not running, but is journal still accessible? With persistent
> > journal files, the AVC denials should be visible after reboot.
> 
> Yes the journal is still visible, but I could not find anything
> in there. I do see these:
> 
> Apr 01 11:53:34 x1.localdomain audit[3638]: AVC avc:  denied  { read } for 
> pid=3638 comm="plymouthd" name="cmdline" dev="proc" ino=43089
> scontext=system_u:system_r:plymouthd_t:s0
> tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1
> Apr 01 11:53:34 x1.localdomain audit[3638]: AVC avc:  denied  { open } for 
> pid=3638 comm="plymouthd" path="/proc/3640/cmdline" dev="proc" ino=43089
> scontext=system_u:system_r:plymouthd_t:s0
> tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1
> Apr 01 11:53:34 x1.localdomain audit[3638]: AVC avc:  denied  { getattr }
> for  pid=3638 comm="plymouthd" path="/proc/3640/stat" dev="proc" ino=43090
> scontext=system_u:system_r:plymouthd_t:s0
> tcontext=system_u:system_r:init_t:s0 tclass=file permissive=1
> 
> In the journal which happen shortly before the troublesome exec. Notice that
> these are still logged by the audit daemon, I think that the audit team
> turns of direct logging of AVC-s by the kernel when it starts; and maybe it
> does not re-enable this when it quits?
> 
> BTW these are harmless, they are plymouthd reading the cmdline from a
> request coming from the "plymouth" client which controls it to log some
> debug info. Things work fine without these. Regardless this is a different
> issue. I guess I should also file a separate bug for this, because in the
> end we don't want to have any denials in the journal / audit logs.
You can see those in permissive mode as the access to the directory is dontaudited:

vm-f34# sesearch --dontaudit -s plymouthd_t -t init_t -c dir
dontaudit daemon init_t:dir { getattr open search };

> 
> > We can try small steps with inserting local policy modules.
> 
> That sounds like a good idea, thank you for your help with this.
> 
Let's start with:

vm-f34# cat local_plymouthd.cil
(allow plymouthd_t bin_t (file (getattr ioctl lock open read execute execute_no_trans map)))
vm-f34# semodule -i local_plymouthd.cil

Note you need to have the system in selinux enforcing mode to see the difference. I suppose the process is plymouthd started from one of the plymouth services.

> > Can you explain the new functionality?
> > - how the plymouthd-drm-escrow is executed, is is a service?
> > - which files are accessed and which resources are used by plymouthd or a
> > child processes during shutdown that were not used before?
> 
> The new functionality is this:
> 
> pid = fork ();
> if (pid == 0) {
>   const char *argv[] = { "/usr/libexec/plymouthd-drm-escrow", NULL };
>   execve (argv[0], (char * const *) argv, NULL);
> }
> 
> Where /usr/libexec/plymouthd-drm-escrow is:
> 
> int
> main(int argc, char **argv)
> {
>         signal (SIGTERM, SIG_IGN);
> 
>         /* Make the first byte in argv be '@' so that we can survive
> systemd's killing
>          * spree until the power is killed at shutdown.
>          *
> http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons
>          */
>         argv[0][0] = '@';
> 
>         while (pause());
> 
>         return 0;
> }
> 
> plymouthd does already use fork, so AFAICT the only new permission which it
> needs is executing "/usr/libexec/plymouthd-drm-escrow" and
> "/usr/libexec/plymouthd-drm-escrow" can stay in the same process-context and
> it does not need any special rights.
These files have the generic bin_t label. Also note other plymouth executables are in /usr/libexec/plymouth/.

> 
> > > It would be nice if we can get this fixed before Fedora 34 final.
> > I am afraid this is hardly possible given the deadline next Tuesday.
> 
> Sorry I was not clear, what I meant was that it would be nice if we can get
> this fixed with a 0-day update. I understand that we are way too close to
> the freeze to get a fix included in final.
Yep.

Comment 4 Hans de Goede 2021-04-01 15:58:26 UTC
> Let's start with:
>
> vm-f34# cat local_plymouthd.cil
> (allow plymouthd_t bin_t (file (getattr ioctl lock open read execute execute_no_trans map)))
> vm-f34# semodule -i local_plymouthd.cil

Thank you, that works. I've run a bunch of tests to figure out the minimal permission set and this also works:

(allow plymouthd_t bin_t (file (execute execute_no_trans map)))

> > plymouthd does already use fork, so AFAICT the only new permission which it
> > needs is executing "/usr/libexec/plymouthd-drm-escrow" and
> > "/usr/libexec/plymouthd-drm-escrow" can stay in the same process-context and
> > it does not need any special rights.
> These files have the generic bin_t label. Also note other plymouth executables are in /usr/libexec/plymouth/.

Oops, my bad, the plymouthd-drm-escrow binary actually also sits under /usr/libexec/plymouth/, so its *correct* full path is: 

/usr/libexec/plymouth/plymouthd-drm-escrow

Note that the other files there are shell-scripts which are used as helpers for initrd generation, they are not executed by plymouthd.

Also during upstream review there were some comments on the plymouthd-drm-escrow name, so it will likely be renamed to plymouthd-fds-escrow . As long as bin_t is used that is fine, but if you plan to add a special plymouth_bin_t to make the new permissions more narrow, please make sure that the labelling will be done on both these paths:

/usr/libexec/plymouth/plymouthd-drm-escrow
/usr/libexec/plymouth/plymouthd-fds-escrow

To make things future proof for the next plymouth version.

Comment 5 Zdenek Pytela 2021-04-01 16:15:27 UTC
(In reply to Hans de Goede from comment #4)
> > Let's start with:
> >
> > vm-f34# cat local_plymouthd.cil
> > (allow plymouthd_t bin_t (file (getattr ioctl lock open read execute execute_no_trans map)))
> > vm-f34# semodule -i local_plymouthd.cil
> 
> Thank you, that works. I've run a bunch of tests to figure out the minimal
> permission set and this also works:
> 
> (allow plymouthd_t bin_t (file (execute execute_no_trans map)))
Does this mean this policy is sufficient to make it working as expected in SELinux enforcing? If yes, it can make it to the last pre-ga build.

> 
> > > plymouthd does already use fork, so AFAICT the only new permission which it
> > > needs is executing "/usr/libexec/plymouthd-drm-escrow" and
> > > "/usr/libexec/plymouthd-drm-escrow" can stay in the same process-context and
> > > it does not need any special rights.
> > These files have the generic bin_t label. Also note other plymouth executables are in /usr/libexec/plymouth/.
> 
> Oops, my bad, the plymouthd-drm-escrow binary actually also sits under
> /usr/libexec/plymouth/, so its *correct* full path is: 
> 
> /usr/libexec/plymouth/plymouthd-drm-escrow
> 
> Note that the other files there are shell-scripts which are used as helpers
> for initrd generation, they are not executed by plymouthd.
> 
> Also during upstream review there were some comments on the
> plymouthd-drm-escrow name, so it will likely be renamed to
> plymouthd-fds-escrow . As long as bin_t is used that is fine, but if you
> plan to add a special plymouth_bin_t to make the new permissions more
> narrow, please make sure that the labelling will be done on both these paths:
> 
> /usr/libexec/plymouth/plymouthd-drm-escrow
> /usr/libexec/plymouth/plymouthd-fds-escrow
> 
> To make things future proof for the next plymouth version.
Discussion for this will continue in bz#1945685, correct?

Comment 6 Hans de Goede 2021-04-01 17:34:49 UTC
> > Thank you, that works. I've run a bunch of tests to figure out the minimal
> > permission set and this also works:
> > 
> > (allow plymouthd_t bin_t (file (execute execute_no_trans map)))
> Does this mean this policy is sufficient to make it working as expected in
> SELinux enforcing? If yes, it can make it to the last pre-ga build.

Yes this is sufficient to make thing work with SELinux enforcing.

If this can make the last pre-ga build, then that would be great.

> Discussion for this will continue in bz#1945685, correct?

Yes lets discuss further improvements to plymouth's selinux policy there.

Comment 7 Zdenek Pytela 2021-04-01 17:51:01 UTC
I've submitted a Fedora PR to address the issue:
https://github.com/fedora-selinux/selinux-policy/pull/673

Comment 8 Hans de Goede 2021-04-01 19:25:14 UTC
(In reply to Zdenek Pytela from comment #7)
> I've submitted a Fedora PR to address the issue:
> https://github.com/fedora-selinux/selinux-policy/pull/673

Great, thank you.

Comment 9 Fedora Update System 2021-04-02 14:44:48 UTC
FEDORA-2021-e221a38cfe has been submitted as an update to Fedora 34. https://bodhi.fedoraproject.org/updates/FEDORA-2021-e221a38cfe

Comment 10 Fedora Update System 2021-04-03 01:09:18 UTC
FEDORA-2021-e221a38cfe has been pushed to the Fedora 34 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-e221a38cfe`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-e221a38cfe

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 11 Fedora Update System 2021-04-05 00:17:53 UTC
FEDORA-2021-e221a38cfe has been pushed to the Fedora 34 stable repository.
If problem still persists, please make note of it in this bug report.


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