Skip to content

runc-dmz does not play well with selinux #4057

Closed
@kolyshkin

Description

@kolyshkin

Description

When .process.selinuxLabel is set, runc uses it to set the executable context (calls selinux.SetExecLabel) before we execute the container binary.

With the dmz feature (introduced in #3987), we now execute runc-dmz (which, in turn, executes the container binary), and we do it with the exec context of the container (selinux.SetExecLabel call). Alas, the container context does not give us enough permissions to use runc-dmz (see e.g. containers/container-selinux#274).

Steps to reproduce the issue

The issue is reproduced on CentOS and Fedora (which has SELinux enabled and in enforcing mode by default) using test cases added in #4053.

Describe the results you received and expected

The issue is reproduced with tests added in #4053. Here's the result:

For CentOS 7:

ok 162 runc run (no selinux label)
not ok 163 runc run (custom selinux label)
# (in test file tests/integration/selinux.bats, line 35)
#   `[ "$status" -eq 0 ]' failed
# runc spec (status=0):
#
# runc run tst (status=139):
#
# type=AVC msg=audit(1696402028.469:690): avc:  denied  { read execute } for  pid=501 comm="6" path=2F6D656D66643A72756E635F636C6F6E65643A72756E632D646D7A202864656C6574656429 dev="tmpfs" ino=146799 scontext=system_u:system_r:container_t:s0:c4,c5 tcontext=unconfined_u:object_r:container_runtime_tmpfs_t:s0 tclass=file permissive=0
ok 164 runc run (custom selinux label, RUNC_DMZ=legacy)

For CentOS 8/9 and Fedora:

ok 162 runc run (no selinux label)
not ok 163 runc run (custom selinux label)
# (in test file tests/integration/selinux.bats, line 35)
#   `[ "$status" -eq 0 ]' failed
# runc spec (status=0):
#
# runc run tst (status=1):
# writing sync procError: write sync: file already closed
# execveat: permission denied
# type=AVC msg=audit(1696403137.078:10848): avc:  denied  { entrypoint } for  pid=105267 comm="runc:[2:INIT]" path=2F6D656D66643A72756E635F636C6F6E65643A72756E632D646D7A202864656C6574656429 dev="tmpfs" ino=276 scontext=system_u:system_r:container_t:s0:c4,c5 tcontext=unconfined_u:object_r:container_runtime_tmpfs_t:s0 tclass=file permissive=0
ok 164 runc run (custom selinux label, RUNC_DMZ=legacy)

What version of runc are you using?

v1.1.0-785-gd8d576ca

Host OS information

Any recent Fedora or CentOS with SELinux enabled and in enforced mode.

Host kernel information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions