-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
youki exec
did not join the correct pid namespace
#185
Comments
Looks like we didn't set the |
youki exec
did not join the correct pid namespace
@utam0k @Furisto @tsturzl The root cause of this is that the I am not sure what is the right approach to resolve this yet. Perhaps we need to revert the change and clone/fork two processes after all. |
I will take a look and see if I have any ideas, otherwise perhaps the double fork is the right solution for now. I'm not entirely sure what runc and crun are doing, and I'd like to look deeper at what they're doing. I think doing what runc is doing is a pretty reliable baseline for us to work off of, because at worst we are only as efficient as what's currently the standard. |
Thanks. I have a feeling that we may have to revert to creating two processes but want to take a bit of time to think it over. As far as I know, |
I'm a bit naive here so forgive any silly questions. Can we not know the pid namespace for the fork until the fork has already happened? It seems like the namespace is derived from the Spec which I assume is known upfront since it seems like the initial process is just passing the loaded spec as is. So those namespaces presumably should be known before the |
Consider there are two operations for namespaces. Either create or join.
Create will create a new namespace, where the namespace is not known. In
the spec, this is indicated as join a namespace but path to the namespace
is null. Namespaces are identified through /proc/pid/ns path. In the case
of join, we have the namespace path on the /proc, which we use to join that
namespace.
The pid namespace however works a bit differently and is the reason for all
these mess. The pid namespace will not change the namespace of the existing
process, only for the children forked after. This is true when both
creating or joining.
However, for rootless container, we have to enter into the user namespace
first. This is because pid namespace requires cap_admin or similar
capabilities. That’s why for rootless containers, the double fork needs to
be done.
I haven’t get a chance to try yet, but another way to work around this
would be to make Youki main process join the user namespace and pid
namespace first, fork the init process, then handle the rest like we do
today. Since the youki main process will return and the process will go
away, theoretically it should be OK.
…On Mon, Aug 9, 2021 at 9:45 PM Travis Sturzl ***@***.***> wrote:
I'm a bit naive here so forgive any silly questions. Can we not know the
pid namespace for the fork until the fork has already happened? It seems
like the namespace is derived from the Spec which I assume is known upfront
since it seems like the initial process is just passing the loaded spec as
is. So those namespaces presumably should be known before the fork::clone
ever happens. Could we not just apply setns on the first process? Am I
missing something here?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#185 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEY66HTZD633HR7SW6TH3UDT4CVGDANCNFSM5BS22B4Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
@yihuaf Maybe this PR will be helpful to you.
And this slide. |
I don't think this will work because for rootless containers the main process has to write the uid and gid mappings for the init process and it cannot do that if it is in the same user namespace. |
Yes, I agree. Double fork it is. I will put together the PR over the weekend. |
@yihuaf I believe the goal of this issue is to pass the below integration test cases. Is that correct? When I organized integration tests, I found that this case is failed. Please carefully that these test cases use unshare command, so using the current youki breaks your environment. |
The goal of this is to fix not entering into pid namespace correctly for |
This is actually a bug, not an enhancement. In fact, this is a regression because it broke |
This will leadyouki exec
to fail at the moment.Edit: this is just the side effect, where
/proc/self
is not set correctly. The root cause is that theyouki exec
process didn't enter the correct pid namespace. Thesetns
for pid namespace require an additional fork/clone to enter into the right namepsace.The text was updated successfully, but these errors were encountered: