Skip to content
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

Add enforcement of sending signals to arbitrary processes in a container #1525

Merged
merged 1 commit into from
Sep 23, 2022
Merged

Add enforcement of sending signals to arbitrary processes in a container #1525

merged 1 commit into from
Sep 23, 2022

Conversation

matajoh
Copy link
Member

@matajoh matajoh commented Sep 22, 2022

Most people tend to think of a container as thing that does a single thing and by extension, as a thing that is a single process. This isn't the case but it is the mental model that people bring to containers. It also happens to be an incredibly common scenario where a container "equals" a single process.

Our model for representing "container constraints" in the policy engine in GCS doesn't break out the init process of a container into a process representation. Instead, signals going to an init process are represented as signals "on the container" and signals going to other processes in the container are represented as signals on an "exec_process".

This makes understanding how to apply constraints to a container easier for folks getting started with confidential containers. It also means that we need to have two different bits of code for enforcing signal constraints on processes in GCS.

For any pid and container id combo we do the following:

If the pid is for the init process of a container, then we know to use the container signal list for determining if sending the signal is allowed.

If the pid isn't for an init process, then we have a bit more work to do. We don't have any mapping of a pid to policy entry if the pid isn't for the init process of a container. But, we can still map from the incoming pid to set of 0 or more valid policy exec_process entries.

GCS stores a collection, on a per container basis, of all processes that were started including the OCI Spec for each process started. We can match the pid to the OCI Spec used to start the process with said pid. We can then use the command from that process to find any valid exec process entries in the policy for the container and see if any of them allow the signal in question. Any matching exec process entries can then be used to do further narrowing on possible container matches in the policy for the given container id.

Most people tend to think of a container as thing that does a single thing
and by extension, as a thing that is a single process. This isn't the case
but it is the mental model that people bring to containers. It also happens
to be an incredibly common scenario where a container "equals" a single process.

Our model for representing "container constraints" in the policy engine in GCS
doesn't break out the init process of a container into a process representation.
Instead, signals going to an init process are represented as signals "on the
container" and signals going to other processes in the container are represented
as signals on an "exec_process".

This makes understanding how to apply constraints to a container easier for
folks getting started with confidential containers. It also means that we
need to have two different bits of code for enforcing signal constraints on
processes in GCS.

For any pid and container id combo we do the following:

If the pid is for the init process of a container, then we know to use the
container signal list for determining if sending the signal is allowed.

If the pid isn't for an init process, then we have a bit more work to do.
We don't have any mapping of a pid to policy entry if the pid isn't for
the init process of a container. But, we can still map from the incoming
pid to set of 0 or more valid policy exec_process entries.

GCS stores a collection, on a per container basis, of all processes that were
started including the OCI Spec for each process started. We can match the
pid to the OCI Spec used to start the process with said pid. We can then use
the command from that process to find any valid exec process entries in the
policy for the container and see if any of them allow the signal in question.
Any matching exec process entries can then be used to do further narrowing on
possible container matches in the policy for the given container id.

Signed-off-by: Sean T. Allen <seanallen@microsoft.com>
Signed-off-by: Matthew A Johnson <matjoh@microsoft.com>
@matajoh matajoh requested a review from a team as a code owner September 22, 2022 20:30
@matajoh
Copy link
Member Author

matajoh commented Sep 23, 2022

@anmaxvl @dcantah

@@ -467,6 +467,24 @@ func (h *Host) SignalContainerProcess(ctx context.Context, containerID string, p
return err
}

signalingInitProcess := (processID == c.initProcess.pid)
Copy link
Contributor

Choose a reason for hiding this comment

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

we discussed this offline and will revisit this use case later. With current implementation, old behavior shouldn't change.

@anmaxvl anmaxvl merged commit b2c8eb9 into microsoft:main Sep 23, 2022
@anmaxvl anmaxvl deleted the signal-process-enforcement branch September 23, 2022 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants