Skip to content

nspawn --selinux-context call to setexeccon fails because tid is cached and not invalidated #475

@richardmaw-codethink

Description

@richardmaw-codethink

I've been trying to use the advanced nspawn features and came across a snag.
setexeccon() is failing with ENOENT.
After digging in with strace, it appears to be attempting to write to the exec context of the wrong thread.

I believe the reason for this is that libselinux caches this path, and invalidates it with an atfork() handler.
However, because glibc doesn't expose a low-level clone() interface, systemd does its own raw clone, hence the atfork() handlers are not called, so setexeccon() attempts to change the context of a process that does not exist.

I think our options are to either forego use of libselinux and write the context directly (I've tried this locally and it appears to work) or rework the uses of raw_clone to use the thread-centric clone provided by glibc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions