Proposal: bindmount init's procfs

Open
#1,224 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
go

Research direction

Start by tracing runc's handling of the initProcessTime check and the /run/runc/[ctr]/init path, then investigate how bind-mounted /proc/[pid] entries behave across PID namespaces. The issue does not name implementation files or tests; done would require choosing and validating a concrete approach for managing containers and detecting the init process without the existing magic.

Written by the indexing model from the issue text.

Description

So, I was playing around with different tricks you can do with persistent namespaces and I noticed that you can bindmount /proc/[pid] directories:

% mount --bind /proc/1 /tmp/init
% cat /tmp/init/stat
1 (systemd) S 0 1 1 0 -1 4210944 91669 332185088 31 11021 346 382 571372 98303 20 0 1 0 2 127012864 1248 18446744073709551615 1 1 0 0 0 0 671173123 4096 1260 0 0 0 17 0 0 0 581 0 0 0 0 0 0 0 0 0 0
% mount --bind /proc/self /tmp/self
% ls /tmp/self
ls: cannot open directory '/tmp/self': No such process

This means there are two things that we can solve with this:

  1. We can manage containers from a different PID namespace, because the /proc/self/stat pseudo-file will generate the correct PID for us. I'm not sure what happens if you try to access it from a different namespace though (probably ESRCH).

  2. We can remove the initProcessTime magic with a simple check to see if /run/runc/[ctr]/init gives us ESRCH. This is a fool-proof method because we're pinning the kernel struct task's procfs entry.

There's also some other cool stuff we could do.

Dominant language
Go
Stars
13.5k
Forks
2.3k
Avg merge
2d 8h
Merged PRs (30d)
30

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from opencontainers/runc

All issues in opencontainers/runc

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.