Skip to content

Commit 7ce4d0a

Browse files
Kenta Tadacyphar
authored and
Kenta Tada
committed
config: Add DisableSpeculationMitigations
It disables speculative execution mitigations in the container. For more information about that, please refer to: opencontainers/runc#2430 Co-Authored-By: Aleksa Sarai <cyphar@cyphar.com> Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
1 parent 3e4195d commit 7ce4d0a

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

config.md

+18
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,23 @@ For Linux-based systems, the `process` object supports the following process-spe
208208
For more information on how these two settings work together, see [the memory cgroup documentation section 10. OOM Contol][cgroup-v1-memory_2].
209209
* **`selinuxLabel`** (string, OPTIONAL) specifies the SELinux label for the process.
210210
For more information about SELinux, see [SELinux documentation][selinux].
211+
* **`disableSpeculationMitigations`** (object, OPTIONAL) specifies whether CPU speculative execution mitigations should be disabled for the process. Several mitigations are auto-enabled under Linux, and can cause a noticeable performance impact (depending on your workload). Note that enabling this option may reduce the security properties of containers created with this configuration. See [the kernel documentation][speculative-control] for more information.
212+
* **`defaultRule`** *(string, REQUIRED)* sets up the default rule to enable or disable the mitigations.
213+
* `enable` - The mitigation of speculations without `exceptions` is disabled.
214+
* `disable` - The mitigation of speculations without `exceptions` is enabled.
215+
* `force-disable` - Same as disable, but it cannot be undone.
216+
* `disable-noexec` - Same as disable, but the state will be cleared on execve(2).
217+
* **`exceptions`** *(array of objects, OPTIONAL)* - the configuration of specific mitigations.
218+
Each entry has the following structure:
219+
* **`mitigation`** *(string, REQUIRED)* - the name of specific mitigation.
220+
A valid list of mitigations.
221+
* `store-bypass` - Speculative Store Bypass
222+
* `indirect-branch` - Indirect Branch Speculation in User Processes
223+
* **`rule`** *(string, REQUIRED)* - enables or disables the specific mitigation.
224+
* `enable` - The mitigation of this particular speculation is disabled.
225+
* `disable` - The mitigation of this particular speculation is enabled.
226+
* `force-disable` - Same as disable, but it cannot be undone.
227+
* `disable-noexec` - Same as disable, but the state will be cleared on execve(2).
211228

212229
### <a name="configUser" />User
213230

@@ -973,3 +990,4 @@ Here is a full example `config.json` for reference.
973990
[stdin.3]: http://man7.org/linux/man-pages/man3/stdin.3.html
974991
[uts-namespace.7]: http://man7.org/linux/man-pages/man7/namespaces.7.html
975992
[zonecfg.1m]: http://docs.oracle.com/cd/E86824_01/html/E54764/zonecfg-1m.html
993+
[speculative-control]: https://www.kernel.org/doc/html/latest/userspace-api/spec_ctrl.html

schema/config-schema.json

+15
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,21 @@
166166
}
167167
}
168168
}
169+
},
170+
"disableSpeculationMitigations": {
171+
"type": "object",
172+
"required": [
173+
"defaultRule"
174+
],
175+
"properties": {
176+
"defaultRule": {
177+
"type": "string"
178+
},
179+
"exceptions": {
180+
"type": "array",
181+
"$ref": "defs.json#/definitions/Exception"
182+
}
183+
}
169184
}
170185
}
171186
},

schema/defs.json

+15
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,21 @@
153153
},
154154
"annotations": {
155155
"$ref": "#/definitions/mapStringString"
156+
},
157+
"Exception": {
158+
"type": "object",
159+
"properties": {
160+
"mitigation": {
161+
"type": "string"
162+
},
163+
"rule": {
164+
"type": "string"
165+
}
166+
},
167+
"required": [
168+
"mitigation",
169+
"rule"
170+
]
156171
}
157172
}
158173
}

specs-go/config.go

+14
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ type Process struct {
5858
OOMScoreAdj *int `json:"oomScoreAdj,omitempty" platform:"linux"`
5959
// SelinuxLabel specifies the selinux context that the container process is run as.
6060
SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
61+
// DisableSpeculationMitigations disables speculative execution mitigations
62+
DisableSpeculationMitigations *LinuxDisableSpeculationMitigations `json:"disableSpeculationMitigations,omitempty" platform:"linux"`
6163
}
6264

6365
// LinuxCapabilities specifies the whitelist of capabilities that are kept for a process.
@@ -75,6 +77,18 @@ type LinuxCapabilities struct {
7577
Ambient []string `json:"ambient,omitempty" platform:"linux"`
7678
}
7779

80+
// LinuxDisableSpeculationMitigations sets up the rule of speculative execution mitigations.
81+
type LinuxDisableSpeculationMitigations struct {
82+
DefaultRule string `json:"defaultRule"`
83+
Exceptions []SpecExceptions `json:"exceptions,omitempty"`
84+
}
85+
86+
// SpecExceptions is used to specify the setting of speculative execution mitigations.
87+
type SpecExceptions struct {
88+
Mitigation string `json:"mitigation"`
89+
Rule string `json:"rule"`
90+
}
91+
7892
// Box specifies dimensions of a rectangle. Used for specifying the size of a console.
7993
type Box struct {
8094
// Height is the vertical dimension of a box.

0 commit comments

Comments
 (0)