Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/libcrun/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,16 @@ container_init (void *args, char *notify_socket, int sync_socket, libcrun_error_
This is a best effort operation, because the seccomp filter is already in place and it could
stop some syscalls used by mark_or_close_fds_ge_than.
*/
ret = mark_or_close_fds_ge_than (entrypoint_args->container, entrypoint_args->context->preserve_fds + 3, true, err);
if (entrypoint_args->custom_handler->vtable->close_fds)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the if statement condition evaluates to true, then no error is created.
I think using crun_error_release (err); (in line 1656) requires that we know for sure err is equal to
NULL or pointing to an allocated error. It's not clear at first sight whether that requirement is fulfilled.

One idea is to replace line 897

  return mark_or_close_fds_ge_than (first_fd_to_close, true, NULL);

with

  return mark_or_close_fds_ge_than (first_fd_to_close, true, err);

and add err as a function argument to libkrun_close_fds()

{
ret = entrypoint_args->custom_handler->vtable->close_fds (entrypoint_args->custom_handler->cookie,
entrypoint_args->container,
entrypoint_args->context->preserve_fds);
}
else
{
ret = mark_or_close_fds_ge_than (entrypoint_args->container, entrypoint_args->context->preserve_fds + 3, true, err);
}
if (UNLIKELY (ret < 0))
crun_error_release (err);

Expand Down
2 changes: 2 additions & 0 deletions src/libcrun/custom-handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ struct custom_handler_s
int (*modify_oci_configuration) (void *cookie, libcrun_context_t *context,
runtime_spec_schema_config_schema *def,
libcrun_error_t *err);

int (*close_fds) (void *cookie, libcrun_container_t *container, int preserve_fds);
};

struct custom_handler_manager_s;
Expand Down
Loading
Loading