Skip to content

procfs: add ioctl to get the pidns associated with the procfs #216

@cyphar

Description

@cyphar

This would be very useful for us, as it would allow us to work around the kinds of issues we had with /proc/thread-self when joining PID namespaces -- if you have a PID value you want to operate on but /proc is from a different pidns, at the moment you will get nonsense results (either an error or -- even worse -- operate on the the wrong process's /proc/$pid).

The idea would be to be able to get a pidns handle from the /proc root, which then could be used with NS_GET_PID_IN_PIDNS to convert the PID from task_active_pid_ns(current) to the pidns of /proc. This could then be automatically translated when you use ProcfsBase::Pid. For fsopen(2) users, this would be a no-op, but this could be incredibly useful for container runtimes or other systems that mess around with namespaces.

In theory you could do this today with pidfds (since /proc/self/fdinfo/$fd will convert the PID to the PID of the pidns, but it would be nice to avoid the need for that).

Metadata

Metadata

Assignees

No one assigned

    Labels

    api/procfsRelated to the procfs API.upstream/linuxDependent on upstream kernel work.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions