Bug 2144541

Summary: [container-tools:rhel8/toolbox] 'init-container' fails when /var/lib/flatpak, /var/lib/systemd/coredump or /var/log/journal on the host are mounted with nodev, noexec or nosuid
Product: Red Hat Enterprise Linux 8 Reporter: Christophe GRENIER <grenier>
Component: toolboxAssignee: Debarshi Ray <debarshir>
Status: CLOSED ERRATA QA Contact: Petr Schindler <pschindl>
Severity: high Docs Contact:
Priority: medium    
Version: 8.7CC: debarshir, desktop-qa-list, grenier, sbarcomb, tpelka, tpopela, vraghave
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: vraghave: needinfo-
vraghave: needinfo-
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: toolbox-0.0.99.4-5.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-14 15:27:28 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:

Description Christophe GRENIER 2022-11-21 15:37:56 UTC
Description of problem:
Failed to bind /var/lib/systemd/coredump to /run/host/var/lib/systemd/coredump


Version-Release number of selected component (if applicable):
toolbox-0.0.99.3-0.6.module_el8.6.0+3070+1510fbd1.x86_64

How reproducible:
Always

Steps to Reproduce:
1. toolbox create --image quay.io/toolbx-images/almalinux-toolbox:8
2. toolbox enter almalinux-toolbox-8

Actual results:
Error: invalid entry point PID of container almalinux-toolbox-8

podman start --attach  almalinux-toolbox-8
...
level=debug msg="Binding /var/lib/systemd/coredump to /run/host/var/lib/systemd/coredump"
mount: /var/lib/systemd/coredump: filesystem was mounted, but any subsequent operation failed: Unknown error 5005.
Error: failed to bind /var/lib/systemd/coredump to /run/host/var/lib/systemd/coredump


Expected results:
Being able to use the container

Comment 3 Debarshi Ray 2023-06-29 15:21:24 UTC
I apologize for the late response.  This one fell through the cracks.  Sorry about that.

> podman start --attach  almalinux-toolbox-8
> ...
> level=debug msg="Binding /var/lib/systemd/coredump to
>     /run/host/var/lib/systemd/coredump"
> mount: /var/lib/systemd/coredump: filesystem was mounted,
>     but any subsequent operation failed: Unknown error 5005.
> Error: failed to bind /var/lib/systemd/coredump to /run/host/var/lib/systemd/coredump

Thanks a lot for the `podman start` logs!  This is the all important line:
  mount: /var/lib/systemd/coredump: filesystem was mounted,
      but any subsequent operation failed: Unknown error 5005.

It's coming from the container's entry point attempting this inside it's mount and user namespace:

  # mount --rbind -o ro /run/host/var/lib/systemd/coredump
      /var/lib/systemd/coredump
  mount: /var/lib/systemd/coredump: filesystem was mounted,
      but any subsequent operation failed: Unknown error 5005.

Looking at the util-linux code [1] it becomes clear that 5005 is MNT_ERR_APPLYFLAGS.

I suspect that on the host /var/lib/systemd/coredump is mounted with some restricted flags beyond 'ro' (like 'nodev', 'nosuid', 'noexec', etc.), and the kernel is unhappy that they are not being used inside the container's mount and user namespace.  This wouldn't have failed if it was attempted inside the host's namespace.

[1] https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/

Comment 4 Debarshi Ray 2023-06-29 15:27:19 UTC
Christophe, could you please show me the results from:

  $ df --output=target /var/lib/systemd/coredump
  Mounted on
  <mount-point>

  $ findmnt --output OPTIONS,PROPAGATION <mount-point>
  OPTIONS       PROPAGATION
  ...           ...

Comment 5 Christophe GRENIER 2023-06-29 17:02:25 UTC
Yes, /var is using nosuid

Please find the requested information

$ rpm -q toolbox
toolbox-0.0.99.3-7.module_el8.8.0+3470+252b1910.x86_64
$ df --output=target /var/lib/systemd/coredump
Mounted on
/var
$ findmnt --output OPTIONS,PROPAGATION /var
OPTIONS                    PROPAGATION
rw,nosuid,noatime,seclabel shared

Comment 6 Debarshi Ray 2023-07-13 10:50:30 UTC
For what it's worth, I sent a pull request to get mount(8) to show a better error message:
https://github.com/util-linux/util-linux/pull/2376

Comment 7 Debarshi Ray 2023-07-13 13:10:27 UTC
Toolbx pull request: https://github.com/containers/toolbox/pull/1340

Comment 9 Debarshi Ray 2023-07-13 17:50:04 UTC
(In reply to Debarshi Ray from comment #7)
> Toolbx pull request: https://github.com/containers/toolbox/pull/1340

Christophe, would it be possible for you to test this pull request?  Thanks for your patience and persistence.

Comment 13 Christophe GRENIER 2023-07-15 17:08:26 UTC
Where can I found the RPM for this pull request for RHEL/CentOS 8 ?

Comment 15 Tomas Popela 2023-07-17 07:33:23 UTC
(In reply to Christophe GRENIER from comment #13)
> Where can I found the RPM for this pull request for RHEL/CentOS 8 ?

You should be able to get them in https://kojihub.stream.centos.org/koji/taskinfo?taskID=2488636 (please keep in mind that these are only test builds)

Comment 16 Christophe GRENIER 2023-07-17 09:20:23 UTC
Thanks. With the new rpm, "toolbox enter almalinux-toolbox-8" now works correctly.
I have also tested successfully
  toolbox create --image quay.io/toolbx-images/almalinux-toolbox:9
  toolbox enter almalinux-toolbox-9

Comment 18 Debarshi Ray 2023-08-11 16:20:36 UTC
Let's use this bug for the 'rolling' stream of the container-tools module in RHELL 8.  I filed bug 2231464 as the 4.0 stream counterpart.

Comment 25 errata-xmlrpc 2023-11-14 15:27:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: container-tools:rhel8 security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6939