-
Notifications
You must be signed in to change notification settings - Fork 302
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
Fix double-free of process user in crun exec #1538
Conversation
239952a
to
6e53bca
Compare
Ephemeral COPR build failed. @containers/packit-build please check. |
The process struct cleanup in crun_command_exec was doubly freeing the process->user pointer, which was previously freed by the container struct cleanup in libcrun_container_exec_with_options. Signed-off-by: Brandon Duffany <brandon@buildbuddy.io>
6e53bca
to
f72483a
Compare
podman system tests failed. @containers/packit-build please check. |
Ephemeral COPR build failed. @containers/packit-build please check. |
podman system tests failed. @containers/packit-build please check. |
Ephemeral COPR build failed. @containers/packit-build please check. |
podman system tests failed. @containers/packit-build please check. |
@@ -3620,7 +3644,7 @@ libcrun_container_exec_with_options (libcrun_context_t *context, const char *id, | |||
process->apparmor_profile = xstrdup (container->container_def->process->apparmor_profile); | |||
|
|||
if (process->user == NULL && container->container_def->process->user) | |||
process->user = container->container_def->process->user; | |||
process->user = process_user_dup (container->container_def->process->user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function owns container
.
Could we just steal the reference to process->user?
process->user = container->container_def->process->user;
container->container_def->process->user = NULL;
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered that approach, but container
gets passed to libcrun_join_process
and exec_process_entrypoint
which both have some complex logic, and I wasn't sure whether those functions need to read the container->container_def->process->user
field. (Even if they aren't reading it today, they might try to read it in the future.)
Let me know if you think this is not much of a concern though - happy to do whatever you think is practical here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, better to not mess with the fields as it is difficult to track what would happen if we reset it.
I can't think of any better way (except changing libocispec to generate "clone" operations, but that is too much work for such a simple fix), so I'll just merge the current version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened a new PR to use libocispec: #1554
LGTM |
This PR regresses the supplemental groups critest: https://github.com/cri-o/cri-o/actions/runs/10680190170/job/29601173374
|
Because the user is assigned by reference, the process struct cleanup in
crun_command_exec
was doubly freeing theprocess->user
pointer, which was previously freed by the container struct cleanup inlibcrun_container_exec_with_options
.Fixes #1537