Skip to content

libct: fix shared pidns detection#3865

Closed
kolyshkin wants to merge 1 commit intoopencontainers:mainfrom
kolyshkin:fix-shared-kill
Closed

libct: fix shared pidns detection#3865
kolyshkin wants to merge 1 commit intoopencontainers:mainfrom
kolyshkin:fix-shared-kill

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin commented May 12, 2023

Found while working on #3825.

When someone is using libcontainer to start and kill containers from a long lived process (i.e. the same process creates and removes the container), initProcess.wait method is used, which has a kludge to work around killing containers that do not have their own PID namespace.

The code that checks for own PID namespace is not entirely correct. To be exact, it does not set sharePidns flag when the host/caller PID namespace is implicitly used. As a result, the above mentioned kludge does not work.

Fix this, and provide a test case. The test is checked to fail before the fix:

=== RUN   TestHostPidnsInitKill
    exec_test.go:1413: expected process to have been killed: <nil>
--- FAIL: TestHostPidnsInitKill (0.24s)

When someone is using libcontainer to start and kill containers from a
long lived process (i.e. the same process creates and removes the
container), initProcess.wait method is used, which has a kludge to work
around killing containers that do not have their own PID namespace.

The code that checks for own PID namespace is not entirely correct.
To be exact, it does not set sharePidns flag when the host/caller PID
namespace is implicitly used. As a result, the above mentioned kludge
does not work.

Fix this, and provide a test case (which is checked to fail before the
fix).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Copy Markdown
Contributor Author

I'm going to convert this to an issue, and merge the fix to #3825.

@kolyshkin
Copy link
Copy Markdown
Contributor Author

Filed #3866

@kolyshkin kolyshkin closed this May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant