Skip to content

Commit cdac379

Browse files
committed
fixup: Add Seccomp Notify support
Fixup following reviews Signed-off-by: Alban Crequy <[email protected]>
1 parent 13f431f commit cdac379

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

config.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ The definition of `createContainer` hooks is currently underspecified and hooks
460460

461461
### <a name="configHooksSendSeccompFd" />SendSeccompFd Hooks
462462

463-
The `sendSeccompFd` hooks MUST only be called if the seccomp policy contains `SCMP_ACT_NOTIFY`.
463+
The `sendSeccompFd` hooks MUST only be called if the seccomp policy contains `SCMP_ACT_NOTIFY` actions.
464464

465465
The `sendSeccompFd` hooks MUST be called after the [`start`](runtime.md#start) operation is called and after the seccomp policy is installed but [before the user-specified program command is executed](runtime.md#lifecycle).
466466
The `sendSeccompFd` hooks MAY additionally be called while the container is in the [`running` state](runtime.md#runtimeState), for example during an `exec` operation.
@@ -475,31 +475,23 @@ The seccomp state is a data structure passed via stdin to the SendSeccompFd hook
475475
It includes the following properties:
476476

477477
* **`ociVersion`** (string, REQUIRED) is version of the Open Container Initiative Runtime Specification with which the seccomp state complies.
478-
* **`phase`** (string, REQUIRED) is the phase at which the seccomp file descriptor is created.
479-
The value MAY be one of:
480-
481-
* `start`: the seccomp filter is created following the [`start`](runtime.md#start) command
482-
* `exec`: the seccomp filter is created following an `exec` command
483-
484-
Additional values MAY be defined by the runtime, however, they MUST be used to represent new values not defined above.
485-
* **`seccompFd`** (int, REQUIRED) is the file descriptor for Seccomp User Notification passed via process inheritance to the SendSeccompFd hooks.
486-
* **`pid`** (int, REQUIRED) is the process ID on which the seccomp filter is applied. In the `start` phase, this is the same as `state.pid`. In the `exec` phase, this is a different pid than `state.pid`.
487-
* **`pidFd`** (int, OPTIONAL) is a pidfd for the process on which the seccomp filter is applied. This file descriptor is also passed via process inheritance to the SendSeccompFd hooks.
478+
* **`seccompFd`** (int, REQUIRED) is the file descriptor for Seccomp User Notification passed via process inheritance to the SendSeccompFd hooks. The value MUST NOT be zero: zero is reserved for stdin.
479+
* **`pid`** (int, REQUIRED) is the process ID on which the seccomp filter is applied.
480+
* **`pidFd`** (int, OPTIONAL) is a pid file descriptor for the process on which the seccomp filter is applied. This file descriptor is also passed via process inheritance to the SendSeccompFd hooks. As the field is optional, the value MAY be zero, meaning `pidFd` is not passed to the hook. If passed, the file descriptor MUST NOT be zero: zero is reserved for stdin.
488481
* **`state`** (map, REQUIRED) is the [state](runtime.md#state) of the container.
489482

490483
When serialized in JSON, the format MUST adhere to the following pattern:
491484

492485
```json
493486
{
494487
"ociVersion": "0.2.0",
495-
"phase": "start",
496488
"seccompFd": 3,
497489
"pid": 4422,
498490
"pidFd": 4,
499491
"state": {
500492
"ociVersion": "0.2.0",
501493
"id": "oci-container1",
502-
"status": "running",
494+
"status": "creating",
503495
"pid": 4422,
504496
"bundle": "/containers/redis",
505497
"annotations": {
@@ -509,6 +501,10 @@ When serialized in JSON, the format MUST adhere to the following pattern:
509501
}
510502
```
511503

504+
Note that if `state.status` is `creating`, the seccomp filter is created following the [`start`](runtime.md#start) command and `.pid` has the same value as `.state.pid`.
505+
And if `state.status` is `running`, the seccomp filter is created following an `exec` command and `.pid` has a different value than `.state.pid`.
506+
507+
512508
### <a name="configHooksStartContainer" />StartContainer Hooks
513509

514510
The `startContainer` hooks MUST be called [before the user-specified process is executed](runtime.md#lifecycle) as part of the [`start`](runtime.md#start) operation.

specs-go/state.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,9 @@ type State struct {
3636
Annotations map[string]string `json:"annotations,omitempty"`
3737
}
3838

39-
type SeccompPhase string
40-
41-
const (
42-
// SeccompPhaseStart indicates that the seccomp filter is applied to
43-
// the main process of the container during container start
44-
SeccompPhaseStart SeccompPhase = "start"
45-
46-
// SeccompPhaseExec indicates that the seccomp filter is applied to a
47-
// new process that entered the container while it's running
48-
SeccompPhaseExec SeccompPhase = "exec"
49-
)
50-
5139
type SeccompState struct {
5240
// Version is the version of the specification that is supported.
5341
Version string `json:"ociVersion"`
54-
// Phase indicates whether this seccomp filter is applied during
55-
// container start or on a process that enters the container later on
56-
Phase SeccompPhase `json:"seccompPhase"`
5742
// SeccompFd is the file descriptor for Seccomp User Notification
5843
SeccompFd int `json:"seccompFd"`
5944
// Pid is the process ID on which the seccomp filter is applied

0 commit comments

Comments
 (0)